Skip to content

Commit

Permalink
Merge pull request #304 from jweiland-net/newOsmGeocodeUri
Browse files Browse the repository at this point in the history
New osm geocode uri
  • Loading branch information
sfroemkenjw authored Nov 8, 2023
2 parents b45ef7b + 31a5918 commit 4cf56c9
Show file tree
Hide file tree
Showing 14 changed files with 132 additions and 42 deletions.
24 changes: 4 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup PHP ${{ matrix.php }}, with composer and extensions
uses: shivammathur/setup-php@v2
Expand All @@ -43,35 +43,19 @@ jobs:
- name: Validate composer.json and composer.lock
run: composer validate

- name: Downgrade composer to 2.1 until problem with stream-wrapper is solved
# @see: https://github.com/composer/composer/issues/10387
# @see: https://github.com/sebastianbergmann/phpunit/pull/4846
run: composer self-update 2.1.14

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache composer dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies with typo3/cms-core:${{ matrix.typo3 }}
run: |
composer require typo3/cms-core:${{ matrix.typo3 }} --no-progress
# EXT:extensionmanager is needed by static_info_tables for TYPO3 10
composer require typo3/cms-extensionmanager:${{ matrix.typo3 }} --no-progress
git checkout composer.json
- name: php-cs-fixer
run: composer ci:php:fixer

- name: Lint PHP
run: composer ci:php:lint

- name: php-cs-fixer
run: composer ci:php:fixer

- name: Unit Tests
run: php .build/vendor/bin/phpunit -c .build/vendor/nimut/testing-framework/res/Configuration/UnitTests.xml Tests/Unit

Expand Down
29 changes: 17 additions & 12 deletions Build/php-cs-fixer/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,32 +30,36 @@
->setRiskyAllowed(true)
->setRules([
'@DoctrineAnnotation' => true,
'@PER' => true,
// @todo: Switch to @PER-CS2.0 once php-cs-fixer's todo list is done: https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7247
'@PER-CS1.0' => true,
'header_comment' => [
'header' => $headerComment,
],
'array_syntax' => ['syntax' => 'short'],
'blank_line_after_opening_tag' => true,
'braces' => ['allow_single_line_closure' => true],
'cast_spaces' => ['space' => 'none'],
'compact_nullable_typehint' => true,
// @todo: Can be dropped once we enable @PER-CS2.0
'concat_space' => ['spacing' => 'one'],
'declare_equal_normalize' => ['space' => 'none'],
'declare_parentheses' => true,
'dir_constant' => true,
// @todo: Can be dropped once we enable @PER-CS2.0
'function_declaration' => [
'closure_fn_spacing' => 'none',
],
'function_to_constant' => ['functions' => ['get_called_class', 'get_class', 'get_class_this', 'php_sapi_name', 'phpversion', 'pi']],
'function_typehint_space' => true,
'lowercase_cast' => true,
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
'type_declaration_spaces' => true,
'global_namespace_import' => ['import_classes' => false, 'import_constants' => false, 'import_functions' => false],
'list_syntax' => ['syntax' => 'short'],
// @todo: Can be dropped once we enable @PER-CS2.0
'method_argument_space' => true,
'modernize_strpos' => true,
'modernize_types_casting' => true,
'native_function_casing' => true,
'new_with_braces' => true,
'no_alias_functions' => true,
'no_blank_lines_after_phpdoc' => true,
'no_empty_phpdoc' => true,
'no_empty_statement' => true,
'no_extra_blank_lines' => true,
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_null_property_initialization' => true,
'no_short_bool_cast' => true,
Expand All @@ -66,8 +70,7 @@
'no_unused_imports' => true,
'no_useless_else' => true,
'no_useless_nullsafe_operator' => true,
'no_whitespace_in_blank_line' => true,
'ordered_imports' => true,
'ordered_imports' => ['imports_order' => ['class', 'function', 'const'], 'sort_algorithm' => 'alpha'],
'php_unit_construct' => ['assertions' => ['assertEquals', 'assertSame', 'assertNotEquals', 'assertNotSame']],
'php_unit_mock_short_will_return' => true,
'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
Expand All @@ -80,8 +83,10 @@
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
'return_type_declaration' => ['space_before' => 'none'],
'single_quote' => true,
'single_space_around_construct' => true,
'single_line_comment_style' => ['comment_types' => ['hash']],
'single_trait_insert_per_statement' => true,
// @todo: Can be dropped once we enable @PER-CS2.0
'single_line_empty_body' => true,
'trailing_comma_in_multiline' => ['elements' => ['arrays']],
'whitespace_after_comma_in_array' => ['ensure_single_space' => true],
'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false],
Expand Down
2 changes: 1 addition & 1 deletion Classes/Configuration/ExtConf.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public function setGoogleMapsGeocodeApiKey(string $googleMapsGeocodeApiKey): voi
public function getOpenStreetMapGeocodeUri(): string
{
if ($this->openStreetMapGeocodeUri === '') {
$this->openStreetMapGeocodeUri = 'https://nominatim.openstreetmap.org/search/%s?format=json&addressdetails=1';
$this->openStreetMapGeocodeUri = 'https://nominatim.openstreetmap.org/search?q=%s&format=json&addressdetails=1';
}

return $this->openStreetMapGeocodeUri;
Expand Down
4 changes: 1 addition & 3 deletions Classes/Controller/CityMapController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
*/
class CityMapController extends AbstractController
{
public function showAction(): void
{
}
public function showAction(): void {}

public function searchAction(string $street): void
{
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Repository/PoiCollectionRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ protected function getColumnsForPoiCollectionTable(): array
$connection = $this->getConnectionPool()->getConnectionForTable('tx_maps2_domain_model_poicollection');
if ($connection->getSchemaManager() instanceof AbstractSchemaManager) {
$columns = array_map(
static fn ($column): string => 'pc.' . $column,
static fn($column): string => 'pc.' . $column,
array_keys(
$connection->getSchemaManager()->listTableColumns('tx_maps2_domain_model_poicollection') ?? []
)
Expand Down
90 changes: 90 additions & 0 deletions Classes/Update/NewGeocodeUriForOsmUpdate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?php

declare(strict_types=1);

/*
* This file is part of the package jweiland/maps2.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/

namespace JWeiland\Maps2\Update;

use TYPO3\CMS\Core\Configuration\Exception\ExtensionConfigurationExtensionNotConfiguredException;
use TYPO3\CMS\Core\Configuration\Exception\ExtensionConfigurationPathDoesNotExistException;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;

/**
* Somewhere in october 2023 OSM has deprecated/removed the use of addresses as path segment in Geocode URI.
* This UpgradeWizard migrates extension settings to new URI where address is a query parameter now.
*/
class NewGeocodeUriForOsmUpdate implements UpgradeWizardInterface
{
private string $oldOsmGeocodeUri = 'https://nominatim.openstreetmap.org/search/%s?format=json&addressdetails=1';

private string $newOsmGeocodeUri = 'https://nominatim.openstreetmap.org/search?q=%s&format=json&addressdetails=1';

public function getIdentifier(): string
{
return 'maps2NewOsmGeocodeUriExtConf';
}

public function getTitle(): string
{
return '[maps2] Migrate to new OSM Geocode URI in extension settings';
}

public function getDescription(): string
{
return 'OpenStreetMap has changed its Geocoding URI. The address has to be set as additional query parameter' .
'now. Adding the address as path segment seems to be removed somewhere in October 2023.';
}

public function updateNecessary(): bool
{
return $this->getOsmGeocodeUri() === $this->oldOsmGeocodeUri;
}

public function executeUpdate(): bool
{
if ($this->getOsmGeocodeUri() === $this->oldOsmGeocodeUri) {
try {
$maps2ExtensionConfiguration = $this->getExtensionConfiguration()->get('maps2');
if (
is_array($maps2ExtensionConfiguration)
&& array_key_exists('openStreetMapGeocodeUri', $maps2ExtensionConfiguration)
) {
$maps2ExtensionConfiguration['openStreetMapGeocodeUri'] = $this->newOsmGeocodeUri;
}
$this->getExtensionConfiguration()->set('maps2', $maps2ExtensionConfiguration);

return true;
} catch (ExtensionConfigurationExtensionNotConfiguredException | ExtensionConfigurationPathDoesNotExistException $e) {
}
}

return false;
}

private function getOsmGeocodeUri(): string
{
try {
return $this->getExtensionConfiguration()->get('maps2', 'openStreetMapGeocodeUri');
} catch (ExtensionConfigurationExtensionNotConfiguredException | ExtensionConfigurationPathDoesNotExistException $e) {
return '';
}
}

private function getExtensionConfiguration(): ExtensionConfiguration
{
return GeneralUtility::makeInstance(ExtensionConfiguration::class);
}

public function getPrerequisites(): array
{
return [];
}
}
10 changes: 10 additions & 0 deletions Documentation/AdministratorManual/Upgrade/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ Upgrade

If you upgrade EXT:maps2 to a newer version, please read this section carefully!

Upgrade to Version 10.0.9
=========================

Somewhere in October 2023 the usage of addresses as path segment in
OpenStreetMap Geocoding URIs has been deprecated/removed. Please execute
the UpgradeWizard to activate the new parameter based OSM Geocoding URI. This
UpgradeWizard will only update that value, if it is the original old URI. Any
modified URIs will be kept untouched.


Upgrade to Version 10.0.0
=========================

Expand Down
1 change: 1 addition & 0 deletions Documentation/ChangeLog/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Version 10.0.9
==============

* BUGFIX: Exclude external Google Maps JS script from concatenation
* BUGFIX: Update to new OSM Geocode URI. Please execute UpgradeWizard
* DOCU: Set indents to 4 spaces

Version 10.0.8
Expand Down
2 changes: 1 addition & 1 deletion Documentation/Settings.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

project = maps2 (Maps2)
version = 10.0
release = 10.0.8
release = 10.0.9
t3author = Stefan Froemken
copyright = since 2013 by jweiland.net

Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/Configuration/ExtConfTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ public function setGoogleMapsGeocodeApiKeySetsGoogleMapsGeocodeApiKey(): void
public function getOpenStreetMapGeocodeUriInitiallyReturnsPreConfiguredUri(): void
{
self::assertSame(
'https://nominatim.openstreetmap.org/search/%s?format=json&addressdetails=1',
'https://nominatim.openstreetmap.org/search?q=%s&format=json&addressdetails=1',
$this->subject->getOpenStreetMapGeocodeUri()
);
}
Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"typo3/cms-core": "^10.4.19 || ^11.5"
},
"require-dev": {
"roave/security-advisories": "dev-latest",
"friendsofphp/php-cs-fixer": "^3.4",
"nimut/testing-framework": "^6.0",
"phpunit/phpunit": "^9.5",
Expand Down
2 changes: 1 addition & 1 deletion ext_conf_template.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ googleMapsJavaScriptApiKey =
googleMapsGeocodeApiKey =

# cat=osm; type=string; label=LLL:EXT:maps2/Resources/Private/Language/ExtConf.xlf:openStreetMapGeocodeUri
openStreetMapGeocodeUri = https://nominatim.openstreetmap.org/search/%s?format=json&addressdetails=1
openStreetMapGeocodeUri = https://nominatim.openstreetmap.org/search?q=%s&format=json&addressdetails=1

# cat=design/color; type=string; label=LLL:EXT:maps2/Resources/Private/Language/ExtConf.xlf:strokeColor
strokeColor = #FF0000
Expand Down
2 changes: 1 addition & 1 deletion ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
$EM_CONF[$_EXTKEY] = [
'title' => 'Maps2',
'description' => 'Create maps with Marker, Area, Routes or Radius based on Google Maps or OpenStreetMap',
'version' => '10.0.8',
'version' => '10.0.9',
'category' => 'plugin',
'state' => 'stable',
'clearCacheOnLoad' => true,
Expand Down
3 changes: 3 additions & 0 deletions ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@
// Migrate old POI record into configuration_map of poicollection table
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['maps2MigratePoiRecord']
= \JWeiland\Maps2\Update\MigratePoiRecordsToConfigurationMapUpdate::class;
// Migrate to new OSM Geocode URI in extension settings
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['maps2NewOsmGeocodeUriExtConf']
= \JWeiland\Maps2\Update\NewGeocodeUriForOsmUpdate::class;

$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1530778687] = [
'nodeName' => 'maps2InfoWindowContent',
Expand Down

0 comments on commit 4cf56c9

Please sign in to comment.