From 9ddf18b54d7aac181fc5645b1408f326bbf66493 Mon Sep 17 00:00:00 2001 From: Michael Lee <lee.5151@osu.edu> Date: Tue, 9 Nov 2021 12:59:34 -0500 Subject: [PATCH] update simple_sitemap 3.10 => 3.11 --- composer.json | 2 +- composer.lock | 22 +++--- vendor/composer/installed.json | 22 +++--- vendor/composer/installed.php | 10 +-- web/modules/simple_sitemap/composer.json | 6 +- .../simple_sitemap_engines.settings.yml | 2 +- .../simple_sitemap_engines.info.yml | 6 +- .../simple_sitemap_engines.install | 10 +++ .../src/Entity/SearchEngine.php | 1 - .../simple_sitemap_views.info.yml | 6 +- .../UrlGenerator/ViewsUrlGenerator.php | 7 +- .../SimpleSitemapDisplayExtender.php | 65 ++++++++++++++++- .../src/SimpleSitemapViews.php | 68 ++++++++++++++---- ...ws.view.simple_sitemap_views_test_view.yml | 69 +++++++++++++++++++ .../simple_sitemap_views_test.info.yml | 6 +- .../src/Functional/SimpleSitemapViewsTest.php | 25 +++++-- .../Functional/SimpleSitemapViewsTestBase.php | 10 +++ .../simple_sitemap/simple_sitemap.info.yml | 6 +- .../simple_sitemap/simple_sitemap.module | 2 +- .../simple_sitemap/src/EntityHelper.php | 2 +- .../UrlGenerator/EntityUrlGenerator.php | 5 +- 21 files changed, 282 insertions(+), 70 deletions(-) diff --git a/composer.json b/composer.json index 3ab95dc2ff..b1ed7cf9b5 100644 --- a/composer.json +++ b/composer.json @@ -155,7 +155,7 @@ "drupal/search_api_db": "1.19", "drupal/simple_gmap": "3.0.1", "drupal/simple_instagram_feed": "^3.11", - "drupal/simple_sitemap": "3.10", + "drupal/simple_sitemap": "3.11", "drupal/simplesamlphp_auth": "3.2", "drupal/smtp": "1.0", "drupal/social_media": "1.9-rc2", diff --git a/composer.lock b/composer.lock index 2e4118d494..49dd470232 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "dee17df1727a8fa0b885fa33c86cafba", + "content-hash": "1c19ed0468755fea7a55c7a1fd175fd3", "packages": [ { "name": "alchemy/zippy", @@ -6799,17 +6799,17 @@ }, { "name": "drupal/simple_sitemap", - "version": "3.10.0", + "version": "3.11.0", "source": { "type": "git", "url": "https://git.drupalcode.org/project/simple_sitemap.git", - "reference": "8.x-3.10" + "reference": "8.x-3.11" }, "dist": { "type": "zip", - "url": "https://ftp.drupal.org/files/projects/simple_sitemap-8.x-3.10.zip", - "reference": "8.x-3.10", - "shasum": "4836e5d5bae0b4348406c832f81eabfaf16483e3" + "url": "https://ftp.drupal.org/files/projects/simple_sitemap-8.x-3.11.zip", + "reference": "8.x-3.11", + "shasum": "5fdd4ed5af5e37e3c707e401d094a179f52e7711" }, "require": { "drupal/core": "^8 || ^9", @@ -6818,8 +6818,8 @@ "type": "drupal-module", "extra": { "drupal": { - "version": "8.x-3.10", - "datestamp": "1617840662", + "version": "8.x-3.11", + "datestamp": "1634344305", "security-coverage": { "status": "covered", "message": "Covered by Drupal's security advisory policy" @@ -6837,9 +6837,9 @@ ], "authors": [ { - "name": "Pawel Ginalski (gbyte.co)", - "homepage": "https://www.drupal.org/u/gbyte.co", - "email": "contact@gbyte.co", + "name": "Pawel Ginalski (gbyte)", + "homepage": "https://www.drupal.org/u/gbyte", + "email": "contact@gbyte.dev", "role": "Maintainer" }, { diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index c3d3fbae53..63694ba7c6 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -7068,18 +7068,18 @@ }, { "name": "drupal/simple_sitemap", - "version": "3.10.0", - "version_normalized": "3.10.0.0", + "version": "3.11.0", + "version_normalized": "3.11.0.0", "source": { "type": "git", "url": "https://git.drupalcode.org/project/simple_sitemap.git", - "reference": "8.x-3.10" + "reference": "8.x-3.11" }, "dist": { "type": "zip", - "url": "https://ftp.drupal.org/files/projects/simple_sitemap-8.x-3.10.zip", - "reference": "8.x-3.10", - "shasum": "4836e5d5bae0b4348406c832f81eabfaf16483e3" + "url": "https://ftp.drupal.org/files/projects/simple_sitemap-8.x-3.11.zip", + "reference": "8.x-3.11", + "shasum": "5fdd4ed5af5e37e3c707e401d094a179f52e7711" }, "require": { "drupal/core": "^8 || ^9", @@ -7088,8 +7088,8 @@ "type": "drupal-module", "extra": { "drupal": { - "version": "8.x-3.10", - "datestamp": "1617840662", + "version": "8.x-3.11", + "datestamp": "1634344305", "security-coverage": { "status": "covered", "message": "Covered by Drupal's security advisory policy" @@ -7108,9 +7108,9 @@ ], "authors": [ { - "name": "Pawel Ginalski (gbyte.co)", - "homepage": "https://www.drupal.org/u/gbyte.co", - "email": "contact@gbyte.co", + "name": "Pawel Ginalski (gbyte)", + "homepage": "https://www.drupal.org/u/gbyte", + "email": "contact@gbyte.dev", "role": "Maintainer" }, { diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index ddc65fc6a3..5d84db3f81 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -5,7 +5,7 @@ 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), - 'reference' => 'df61ac4c80357a6ff9e6e56957f55630f42d3212', + 'reference' => 'b1aa9db618db05fa20645711143c5efd92e8829d', 'name' => 'osu-asc-webservices/d8-upstream', 'dev' => true, ), @@ -1568,12 +1568,12 @@ 'dev_requirement' => false, ), 'drupal/simple_sitemap' => array( - 'pretty_version' => '3.10.0', - 'version' => '3.10.0.0', + 'pretty_version' => '3.11.0', + 'version' => '3.11.0.0', 'type' => 'drupal-module', 'install_path' => __DIR__ . '/../../web/modules/simple_sitemap', 'aliases' => array(), - 'reference' => '8.x-3.10', + 'reference' => '8.x-3.11', 'dev_requirement' => false, ), 'drupal/simplesamlphp_auth' => array( @@ -2104,7 +2104,7 @@ 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), - 'reference' => 'df61ac4c80357a6ff9e6e56957f55630f42d3212', + 'reference' => 'b1aa9db618db05fa20645711143c5efd92e8829d', 'dev_requirement' => false, ), 'pantheon-systems/quicksilver-pushback' => array( diff --git a/web/modules/simple_sitemap/composer.json b/web/modules/simple_sitemap/composer.json index 18450ea707..0fc798ba86 100644 --- a/web/modules/simple_sitemap/composer.json +++ b/web/modules/simple_sitemap/composer.json @@ -5,9 +5,9 @@ "homepage": "https://drupal.org/project/simple_sitemap", "authors": [ { - "name": "Pawel Ginalski (gbyte.co)", - "email": "contact@gbyte.co", - "homepage": "https://www.drupal.org/u/gbyte.co", + "name": "Pawel Ginalski (gbyte)", + "email": "contact@gbyte.dev", + "homepage": "https://www.drupal.org/u/gbyte", "role": "Maintainer" } ], diff --git a/web/modules/simple_sitemap/modules/simple_sitemap_engines/config/install/simple_sitemap_engines.settings.yml b/web/modules/simple_sitemap/modules/simple_sitemap_engines/config/install/simple_sitemap_engines.settings.yml index 4c544c1d14..bd3d661f5d 100644 --- a/web/modules/simple_sitemap/modules/simple_sitemap_engines/config/install/simple_sitemap_engines.settings.yml +++ b/web/modules/simple_sitemap/modules/simple_sitemap_engines/config/install/simple_sitemap_engines.settings.yml @@ -1,2 +1,2 @@ enabled: true -submission_interval: 86400 +submission_interval: 24 diff --git a/web/modules/simple_sitemap/modules/simple_sitemap_engines/simple_sitemap_engines.info.yml b/web/modules/simple_sitemap/modules/simple_sitemap_engines/simple_sitemap_engines.info.yml index b4fcceb42f..bd11eb5d69 100644 --- a/web/modules/simple_sitemap/modules/simple_sitemap_engines/simple_sitemap_engines.info.yml +++ b/web/modules/simple_sitemap/modules/simple_sitemap_engines/simple_sitemap_engines.info.yml @@ -8,7 +8,7 @@ core_version_requirement: ^8 || ^9 dependencies: - simple_sitemap:simple_sitemap -# Information added by Drupal.org packaging script on 2021-04-07 -version: '8.x-3.10' +# Information added by Drupal.org packaging script on 2021-10-16 +version: '8.x-3.11' project: 'simple_sitemap' -datestamp: 1617833759 +datestamp: 1634343987 diff --git a/web/modules/simple_sitemap/modules/simple_sitemap_engines/simple_sitemap_engines.install b/web/modules/simple_sitemap/modules/simple_sitemap_engines/simple_sitemap_engines.install index 1a52b73c53..83448d61d2 100644 --- a/web/modules/simple_sitemap/modules/simple_sitemap_engines/simple_sitemap_engines.install +++ b/web/modules/simple_sitemap/modules/simple_sitemap_engines/simple_sitemap_engines.install @@ -38,3 +38,13 @@ function simple_sitemap_engines_update_8301() { } } } + +/** + * Fixing erroneous default submission interval if not yet overwritten. + */ +function simple_sitemap_engines_update_8302() { + $config = \Drupal::configFactory()->getEditable('simple_sitemap_engines.settings'); + if ($config->get('submission_interval') === 86400) { + $config->set('submission_interval', 24)->save(); + } +} diff --git a/web/modules/simple_sitemap/modules/simple_sitemap_engines/src/Entity/SearchEngine.php b/web/modules/simple_sitemap/modules/simple_sitemap_engines/src/Entity/SearchEngine.php index 40290f94a7..2628767fdb 100644 --- a/web/modules/simple_sitemap/modules/simple_sitemap_engines/src/Entity/SearchEngine.php +++ b/web/modules/simple_sitemap/modules/simple_sitemap_engines/src/Entity/SearchEngine.php @@ -26,7 +26,6 @@ * "label", * "url", * "sitemap_variants", - * "last_submitted", * } * ) */ diff --git a/web/modules/simple_sitemap/modules/simple_sitemap_views/simple_sitemap_views.info.yml b/web/modules/simple_sitemap/modules/simple_sitemap_views/simple_sitemap_views.info.yml index 01d23e034b..57e79884ef 100644 --- a/web/modules/simple_sitemap/modules/simple_sitemap_views/simple_sitemap_views.info.yml +++ b/web/modules/simple_sitemap/modules/simple_sitemap_views/simple_sitemap_views.info.yml @@ -9,7 +9,7 @@ dependencies: - simple_sitemap:simple_sitemap - drupal:views -# Information added by Drupal.org packaging script on 2021-04-07 -version: '8.x-3.10' +# Information added by Drupal.org packaging script on 2021-10-16 +version: '8.x-3.11' project: 'simple_sitemap' -datestamp: 1617833759 +datestamp: 1634343987 diff --git a/web/modules/simple_sitemap/modules/simple_sitemap_views/src/Plugin/simple_sitemap/UrlGenerator/ViewsUrlGenerator.php b/web/modules/simple_sitemap/modules/simple_sitemap_views/src/Plugin/simple_sitemap/UrlGenerator/ViewsUrlGenerator.php index 5c203ed297..f04a094a6b 100755 --- a/web/modules/simple_sitemap/modules/simple_sitemap_views/src/Plugin/simple_sitemap/UrlGenerator/ViewsUrlGenerator.php +++ b/web/modules/simple_sitemap/modules/simple_sitemap_views/src/Plugin/simple_sitemap/UrlGenerator/ViewsUrlGenerator.php @@ -127,8 +127,13 @@ public function getDataSets() { 'view_id' => $view->id(), 'display_id' => $view->current_display, ]; + + $extender = $this->sitemapViews->getDisplayExtender($view); + // View path without arguments. - $data_sets[] = $base_data_set + ['arguments' => NULL]; + if (!$extender->hasRequiredArguments()) { + $data_sets[] = $base_data_set + ['arguments' => NULL]; + } // Process indexed arguments. if ($args_ids = $this->sitemapViews->getIndexableArguments($view, $this->sitemapVariant)) { diff --git a/web/modules/simple_sitemap/modules/simple_sitemap_views/src/Plugin/views/display_extender/SimpleSitemapDisplayExtender.php b/web/modules/simple_sitemap/modules/simple_sitemap_views/src/Plugin/views/display_extender/SimpleSitemapDisplayExtender.php index accb215f2f..ff735503d5 100755 --- a/web/modules/simple_sitemap/modules/simple_sitemap_views/src/Plugin/views/display_extender/SimpleSitemapDisplayExtender.php +++ b/web/modules/simple_sitemap/modules/simple_sitemap_views/src/Plugin/views/display_extender/SimpleSitemapDisplayExtender.php @@ -104,6 +104,7 @@ protected function defineOptions() { */ public function buildOptionsForm(&$form, FormStateInterface $form_state) { if ($this->hasSitemapSettings() && $form_state->get('section') == 'simple_sitemap') { + $has_required_arguments = $this->hasRequiredArguments(); $arguments_options = $this->getArgumentsOptions(); $form['variants'] = [ @@ -166,6 +167,11 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { '#states' => $states, ]; + // Required arguments are always indexed. + foreach ($this->getRequiredArguments() as $argument_id) { + $variant_form['arguments'][$argument_id]['#disabled'] = TRUE; + } + // Max links with arguments. $variant_form['max_links'] = [ '#type' => 'number', @@ -173,7 +179,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { '#description' => $this->t('The maximum number of link variations to be indexed for this display. If left blank, each argument will create link variations for this display. Use with caution, as a large number of argument values​can significantly increase the number of sitemap links.'), '#default_value' => $settings['max_links'], '#min' => 1, - '#access' => !empty($arguments_options), + '#access' => !empty($arguments_options) || $has_required_arguments, '#states' => $states, ]; } @@ -188,8 +194,11 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { */ public function validateOptionsForm(&$form, FormStateInterface $form_state) { if ($this->hasSitemapSettings() && $form_state->get('section') == 'simple_sitemap') { + $required_arguments = $this->getRequiredArguments(); + foreach (array_keys($this->variants) as $variant) { - $arguments = $form_state->getValue(['variants', $variant, 'arguments'], []); + $arguments = &$form_state->getValue(['variants', $variant, 'arguments'], []); + $arguments = array_merge($arguments, $required_arguments); $errors = $this->validateIndexedArguments($arguments); foreach ($errors as $message) { @@ -287,6 +296,14 @@ public function getSitemapSettings($variant) { if (isset($this->options['variants'][$variant])) { $settings = $this->options['variants'][$variant] + $settings; } + + if (empty($this->displayHandler->getHandlers('argument'))) { + $settings['arguments'] = []; + } + else { + $required_arguments = $this->getRequiredArguments(); + $settings['arguments'] = array_merge($settings['arguments'], $required_arguments); + } return $settings; } @@ -300,6 +317,50 @@ public function hasSitemapSettings() { return $this->displayHandler instanceof DisplayRouterInterface; } + /** + * Gets required view arguments (presented in the path). + * + * @return array + * View arguments IDs. + */ + public function getRequiredArguments() { + $arguments = $this->displayHandler->getHandlers('argument'); + + if (!empty($arguments)) { + $bits = explode('/', $this->displayHandler->getPath()); + $arg_counter = 0; + + foreach ($bits as $bit) { + if ($bit == '%' || strpos($bit, '%') === 0) { + $arg_counter++; + } + } + + if ($arg_counter > 0) { + $arguments = array_slice(array_keys($arguments), 0, $arg_counter); + return array_combine($arguments, $arguments); + } + } + return []; + } + + /** + * Determines if the view path contains required arguments. + * + * @return bool + * TRUE if the path contains required arguments, FALSE if not. + */ + public function hasRequiredArguments() { + $bits = explode('/', $this->displayHandler->getPath()); + + foreach ($bits as $bit) { + if ($bit == '%' || strpos($bit, '%') === 0) { + return TRUE; + } + } + return FALSE; + } + /** * Returns available view arguments options. * diff --git a/web/modules/simple_sitemap/modules/simple_sitemap_views/src/SimpleSitemapViews.php b/web/modules/simple_sitemap/modules/simple_sitemap_views/src/SimpleSitemapViews.php index 47d580a274..4f5839302f 100755 --- a/web/modules/simple_sitemap/modules/simple_sitemap_views/src/SimpleSitemapViews.php +++ b/web/modules/simple_sitemap/modules/simple_sitemap_views/src/SimpleSitemapViews.php @@ -137,19 +137,17 @@ public function disable() { } /** - * Gets the sitemap settings for view display. + * Gets the display extender. * * @param \Drupal\views\ViewExecutable $view * A view executable instance. - * @param string $variant - * The name of the sitemap variant. * @param string|null $display_id * The display id. If empty uses the current display. * - * @return array|null - * The sitemap settings if the display is indexed, NULL otherwise. + * @return \Drupal\simple_sitemap_views\Plugin\views\display_extender\SimpleSitemapDisplayExtender|null + * The display extender. */ - public function getSitemapSettings(ViewExecutable $view, $variant, $display_id = NULL) { + public function getDisplayExtender(ViewExecutable $view, $display_id = NULL) { // Ensure the display was correctly set. if (!$view->setDisplay($display_id)) { return NULL; @@ -158,8 +156,30 @@ public function getSitemapSettings(ViewExecutable $view, $variant, $display_id = $extenders = $view->display_handler->getExtenders(); $extender = isset($extenders[self::PLUGIN_ID]) ? $extenders[self::PLUGIN_ID] : NULL; + if ($extender instanceof SimpleSitemapDisplayExtender) { + return $extender; + } + return NULL; + } + + /** + * Gets the sitemap settings for view display. + * + * @param \Drupal\views\ViewExecutable $view + * A view executable instance. + * @param string $variant + * The name of the sitemap variant. + * @param string|null $display_id + * The display id. If empty uses the current display. + * + * @return array|null + * The sitemap settings if the display is indexed, NULL otherwise. + */ + public function getSitemapSettings(ViewExecutable $view, $variant, $display_id = NULL) { + $extender = $this->getDisplayExtender($view, $display_id); + // Retrieve the sitemap settings from the extender. - if ($extender instanceof SimpleSitemapDisplayExtender && $extender->hasSitemapSettings()) { + if ($extender && $extender->hasSitemapSettings()) { $settings = $extender->getSitemapSettings($variant); if ($settings['index']) { @@ -187,14 +207,31 @@ public function getIndexableArguments(ViewExecutable $view, $variant, $display_i $indexable_arguments = []; // Find indexable arguments. - if ($settings && !empty($settings['arguments'])) { + if ($settings) { $arguments = array_keys($view->display_handler->getHandlers('argument')); + $bits = explode('/', $view->getPath()); + $arg_index = 0; + + // Required arguments. + foreach ($bits as $bit) { + if ($bit == '%' || strpos($bit, '%') === 0) { + $indexable_arguments[] = isset($arguments[$arg_index]) ? $arguments[$arg_index] : $bit; + $arg_index++; + } + } + + if (!empty($settings['arguments'])) { + if ($arg_index > 0) { + $arguments = array_slice($arguments, $arg_index); + } - foreach ($arguments as $argument_id) { - if (empty($settings['arguments'][$argument_id])) { - break; + // Optional arguments. + foreach ($arguments as $argument_id) { + if (empty($settings['arguments'][$argument_id])) { + break; + } + $indexable_arguments[] = $argument_id; } - $indexable_arguments[] = $argument_id; } } return $indexable_arguments; @@ -436,9 +473,10 @@ public function getIndexableViews() { } // Load views with display plugins that use the route. - $query = $this->viewStorage->getQuery(); - $query->condition('status', TRUE); - $query->condition("display.*.display_plugin", $this->getRouterDisplayPluginIds(), 'IN'); + $query = $this->viewStorage->getQuery() + ->condition('status', TRUE) + ->condition("display.*.display_plugin", $this->getRouterDisplayPluginIds(), 'IN') + ->accessCheck(TRUE); $view_ids = $query->execute(); // If there are no such views, then return an empty array. diff --git a/web/modules/simple_sitemap/modules/simple_sitemap_views/tests/modules/simple_sitemap_views_test/config/install/views.view.simple_sitemap_views_test_view.yml b/web/modules/simple_sitemap/modules/simple_sitemap_views/tests/modules/simple_sitemap_views_test/config/install/views.view.simple_sitemap_views_test_view.yml index acd3a247c8..6c28a2d45b 100644 --- a/web/modules/simple_sitemap/modules/simple_sitemap_views/tests/modules/simple_sitemap_views_test/config/install/views.view.simple_sitemap_views_test_view.yml +++ b/web/modules/simple_sitemap/modules/simple_sitemap_views/tests/modules/simple_sitemap_views_test/config/install/views.view.simple_sitemap_views_test_view.yml @@ -281,3 +281,72 @@ display: - 'user.node_grants:view' - user.permissions tags: { } + page_2: + display_plugin: page + id: page_2 + display_title: 'Page 2' + position: 2 + display_options: + display_extenders: + simple_sitemap_display_extender: + variants: + default: + index: true + priority: '0.5' + changefreq: '' + arguments: { } + max_links: 2 + path: simple-sitemap-views-test-view-2/%node_type/% + rendering_language: en + arguments: + type: + id: type + table: node_field_data + field: type + relationship: none + group_type: group + admin_label: '' + default_action: ignore + exception: + value: all + title_enable: false + title: All + title_enable: false + title: '' + default_argument_type: fixed + default_argument_options: + argument: '' + default_argument_skip_url: false + summary_options: + base_path: '' + count: true + items_per_page: 25 + override: false + summary: + sort_order: asc + number_of_records: 0 + format: default_summary + specify_validation: false + validate: + type: none + fail: 'not found' + validate_options: { } + glossary: false + limit: 0 + case: none + path_case: none + transform_dash: false + break_phrase: false + entity_type: node + entity_field: type + plugin_id: node_type + defaults: + arguments: false + cache_metadata: + max-age: -1 + contexts: + - 'languages:language_interface' + - url + - 'user.node_grants:view' + - user.permissions + tags: { } diff --git a/web/modules/simple_sitemap/modules/simple_sitemap_views/tests/modules/simple_sitemap_views_test/simple_sitemap_views_test.info.yml b/web/modules/simple_sitemap/modules/simple_sitemap_views/tests/modules/simple_sitemap_views_test/simple_sitemap_views_test.info.yml index bbda1a92c7..56cb4490c7 100644 --- a/web/modules/simple_sitemap/modules/simple_sitemap_views/tests/modules/simple_sitemap_views_test/simple_sitemap_views_test.info.yml +++ b/web/modules/simple_sitemap/modules/simple_sitemap_views/tests/modules/simple_sitemap_views_test/simple_sitemap_views_test.info.yml @@ -7,7 +7,7 @@ core_version_requirement: ^8 || ^9 dependencies: - simple_sitemap:simple_sitemap_views -# Information added by Drupal.org packaging script on 2021-04-07 -version: '8.x-3.10' +# Information added by Drupal.org packaging script on 2021-10-16 +version: '8.x-3.11' project: 'simple_sitemap' -datestamp: 1617833759 +datestamp: 1634343987 diff --git a/web/modules/simple_sitemap/modules/simple_sitemap_views/tests/src/Functional/SimpleSitemapViewsTest.php b/web/modules/simple_sitemap/modules/simple_sitemap_views/tests/src/Functional/SimpleSitemapViewsTest.php index 36f8035f12..bc2e27c6b1 100644 --- a/web/modules/simple_sitemap/modules/simple_sitemap_views/tests/src/Functional/SimpleSitemapViewsTest.php +++ b/web/modules/simple_sitemap/modules/simple_sitemap_views/tests/src/Functional/SimpleSitemapViewsTest.php @@ -46,6 +46,11 @@ public function testIndexableViews() { $this->assertContains('type', $indexable_arguments); $this->assertContains('title', $indexable_arguments); $this->assertNotContains('nid', $indexable_arguments); + + // Check the indexing status of the required arguments. + $indexable_arguments = $this->sitemapViews->getIndexableArguments($this->testView2, $this->sitemapVariant); + $this->assertContains('type', $indexable_arguments); + $this->assertContains('%', $indexable_arguments); } /** @@ -77,6 +82,10 @@ public function testAddArgumentsToIndex() { $args = ['page', $this->node2->getTitle()]; $this->sitemapViews->addArgumentsToIndex($this->testView, $args); $this->assertIndexSize(2); + + // Required arguments must be indexed. + $this->sitemapViews->addArgumentsToIndex($this->testView2, ['page', 1]); + $this->assertIndexSize(3); } /** @@ -89,14 +98,22 @@ public function testViewsUrlGenerator() { $title = $this->node->getTitle(); $this->sitemapViews->addArgumentsToIndex($this->testView, ['page']); $this->sitemapViews->addArgumentsToIndex($this->testView, ['page', $title]); + $this->sitemapViews->addArgumentsToIndex($this->testView2, ['page', 1]); $this->generator->generateSitemap('backend'); + $url1 = $this->testView->getUrl()->toString(); + $url2 = $this->testView->getUrl(['page', NULL, NULL])->toString(); + $url3 = $this->testView->getUrl(['page', $title, NULL])->toString(); + $url4 = $this->testView2->getUrl()->toString(); + $url5 = $this->testView2->getUrl(['page', 1])->toString(); + // Check that the sitemap contains view display URLs. $this->drupalGet($this->defaultSitemapUrl); - $test_view_url = $this->testView->getUrl()->toString(); - $this->assertSession()->responseContains($test_view_url); - $this->assertSession()->responseContains("$test_view_url/page"); - $this->assertSession()->responseContains("$test_view_url/page/$title"); + $this->assertSession()->responseContains($url1); + $this->assertSession()->responseContains($url2); + $this->assertSession()->responseContains($url3); + $this->assertSession()->responseNotContains($url4); + $this->assertSession()->responseContains($url5); } /** diff --git a/web/modules/simple_sitemap/modules/simple_sitemap_views/tests/src/Functional/SimpleSitemapViewsTestBase.php b/web/modules/simple_sitemap/modules/simple_sitemap_views/tests/src/Functional/SimpleSitemapViewsTestBase.php index 782e8e96ec..9bfb92308e 100644 --- a/web/modules/simple_sitemap/modules/simple_sitemap_views/tests/src/Functional/SimpleSitemapViewsTestBase.php +++ b/web/modules/simple_sitemap/modules/simple_sitemap_views/tests/src/Functional/SimpleSitemapViewsTestBase.php @@ -40,6 +40,13 @@ abstract class SimpleSitemapViewsTestBase extends SimplesitemapTestBase { */ protected $testView; + /** + * Test view 2. + * + * @var \Drupal\views\ViewExecutable + */ + protected $testView2; + /** * The sitemap variant. * @@ -59,6 +66,9 @@ protected function setUp() { $this->testView = Views::getView('simple_sitemap_views_test_view'); $this->testView->setDisplay('page_1'); + + $this->testView2 = Views::getView('simple_sitemap_views_test_view'); + $this->testView2->setDisplay('page_2'); } /** diff --git a/web/modules/simple_sitemap/simple_sitemap.info.yml b/web/modules/simple_sitemap/simple_sitemap.info.yml index 6b4d4ca396..2192969777 100644 --- a/web/modules/simple_sitemap/simple_sitemap.info.yml +++ b/web/modules/simple_sitemap/simple_sitemap.info.yml @@ -6,7 +6,7 @@ package: SEO core: 8.x core_version_requirement: ^8 || ^9 -# Information added by Drupal.org packaging script on 2021-04-07 -version: '8.x-3.10' +# Information added by Drupal.org packaging script on 2021-10-16 +version: '8.x-3.11' project: 'simple_sitemap' -datestamp: 1617833759 +datestamp: 1634343987 diff --git a/web/modules/simple_sitemap/simple_sitemap.module b/web/modules/simple_sitemap/simple_sitemap.module index dacec83fb3..ad0098166e 100644 --- a/web/modules/simple_sitemap/simple_sitemap.module +++ b/web/modules/simple_sitemap/simple_sitemap.module @@ -131,7 +131,7 @@ function simple_sitemap_entity_form_submit($form, FormStateInterface &$form_stat } // Regenerate sitemaps according to user setting. - if ($values['simple_sitemap_regenerate_now']) { + if (!empty($values['simple_sitemap_regenerate_now'])) { $generator->setVariants(TRUE) ->rebuildQueue() ->generateSitemap(); diff --git a/web/modules/simple_sitemap/src/EntityHelper.php b/web/modules/simple_sitemap/src/EntityHelper.php index 6b205d4ee4..b1bc875ecf 100644 --- a/web/modules/simple_sitemap/src/EntityHelper.php +++ b/web/modules/simple_sitemap/src/EntityHelper.php @@ -210,7 +210,7 @@ public function getEntityInstanceIds($entity_type_id, $bundle_name = NULL) { $entity_query->condition($keys['bundle'], $bundle_name); } - return $entity_query->execute(); + return $entity_query->accessCheck(TRUE)->execute(); } } diff --git a/web/modules/simple_sitemap/src/Plugin/simple_sitemap/UrlGenerator/EntityUrlGenerator.php b/web/modules/simple_sitemap/src/Plugin/simple_sitemap/UrlGenerator/EntityUrlGenerator.php index 1d8f7ebd90..8c90982d30 100644 --- a/web/modules/simple_sitemap/src/Plugin/simple_sitemap/UrlGenerator/EntityUrlGenerator.php +++ b/web/modules/simple_sitemap/src/Plugin/simple_sitemap/UrlGenerator/EntityUrlGenerator.php @@ -214,7 +214,10 @@ protected function processDataSet($data_set) { * @inheritdoc */ public function generate($data_set) { - $path_data_sets = $this->processDataSet($data_set); + if (empty($path_data_sets = $this->processDataSet($data_set))) { + return []; + } + $url_variant_sets = []; foreach ($path_data_sets as $key => $path_data) { if (isset($path_data['url']) && $path_data['url'] instanceof Url) { -- GitLab