diff --git a/composer.json b/composer.json index 8e3a9bce102b445406a28dc8fdfa5966cf3c0516..af9d30de5df381b6d8d9e434eeeda39c317f0fd0 100644 --- a/composer.json +++ b/composer.json @@ -149,7 +149,7 @@ "drupal/module_filter": "3.1", "drupal/pantheon_advanced_page_cache": "1.1", "drupal/paragraphs": "1.12", - "drupal/pathauto": "1.6", + "drupal/pathauto": "1.8", "drupal/realname": "1.0.0-rc2", "drupal/rebuild_cache_access": "1.7", "drupal/recaptcha": "2.5", diff --git a/composer.lock b/composer.lock index b3eee3a9857336263eb2f6b499b80aedc5b5626c..2e3443f551b7d3881de80a337e06cecc54b84564 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": "97a7b4312e4113ee81b8d863f237ad12", + "content-hash": "cfe4ca74b7ac7f2fe74f10218f6c2667", "packages": [ { "name": "alchemy/zippy", @@ -6551,35 +6551,40 @@ }, { "name": "drupal/pathauto", - "version": "1.6.0", + "version": "1.8.0", "source": { "type": "git", "url": "https://git.drupalcode.org/project/pathauto.git", - "reference": "8.x-1.6" + "reference": "8.x-1.8" }, "dist": { "type": "zip", - "url": "https://ftp.drupal.org/files/projects/pathauto-8.x-1.6.zip", - "reference": "8.x-1.6", - "shasum": "eb976ae110d73c06fafb1b657adb967dd2cb8246" + "url": "https://ftp.drupal.org/files/projects/pathauto-8.x-1.8.zip", + "reference": "8.x-1.8", + "shasum": "ede3216abb9c4f77709338d9147334c595046329" }, "require": { - "drupal/core": "^8.6", + "drupal/core": "^8.8 || ^9", "drupal/ctools": "*", "drupal/token": "*" }, + "suggest": { + "drupal/redirect": "When installed Pathauto will provide a new \"Update Action\" in case your URLs change. This is the recommended update action and is considered the best practice for SEO and usability." + }, "type": "drupal-module", "extra": { - "branch-alias": { - "dev-1.x": "1.x-dev" - }, "drupal": { - "version": "8.x-1.6", - "datestamp": "1575467285", + "version": "8.x-1.8", + "datestamp": "1588103046", "security-coverage": { "status": "covered", "message": "Covered by Drupal's security advisory policy" } + }, + "drush": { + "services": { + "drush.services.yml": "^9 || ^10" + } } }, "notification-url": "https://packages.drupal.org/8/downloads", @@ -6607,7 +6612,9 @@ "description": "Provides a mechanism for modules to automatically generate aliases for the content they manage.", "homepage": "https://www.drupal.org/project/pathauto", "support": { - "source": "https://git.drupalcode.org/project/pathauto" + "source": "https://cgit.drupalcode.org/pathauto", + "issues": "https://www.drupal.org/project/issues/pathauto", + "documentation": "https://www.drupal.org/docs/8/modules/pathauto" } }, { diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index d01d34d36b8815e914af6479d8c1cf02ed2b6d93..194494f1f79bd594ba6991dd2ef5a4ea26c7e3a4 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -6750,36 +6750,41 @@ }, { "name": "drupal/pathauto", - "version": "1.6.0", - "version_normalized": "1.6.0.0", + "version": "1.8.0", + "version_normalized": "1.8.0.0", "source": { "type": "git", "url": "https://git.drupalcode.org/project/pathauto.git", - "reference": "8.x-1.6" + "reference": "8.x-1.8" }, "dist": { "type": "zip", - "url": "https://ftp.drupal.org/files/projects/pathauto-8.x-1.6.zip", - "reference": "8.x-1.6", - "shasum": "eb976ae110d73c06fafb1b657adb967dd2cb8246" + "url": "https://ftp.drupal.org/files/projects/pathauto-8.x-1.8.zip", + "reference": "8.x-1.8", + "shasum": "ede3216abb9c4f77709338d9147334c595046329" }, "require": { - "drupal/core": "^8.6", + "drupal/core": "^8.8 || ^9", "drupal/ctools": "*", "drupal/token": "*" }, + "suggest": { + "drupal/redirect": "When installed Pathauto will provide a new \"Update Action\" in case your URLs change. This is the recommended update action and is considered the best practice for SEO and usability." + }, "type": "drupal-module", "extra": { - "branch-alias": { - "dev-1.x": "1.x-dev" - }, "drupal": { - "version": "8.x-1.6", - "datestamp": "1575467285", + "version": "8.x-1.8", + "datestamp": "1588103046", "security-coverage": { "status": "covered", "message": "Covered by Drupal's security advisory policy" } + }, + "drush": { + "services": { + "drush.services.yml": "^9 || ^10" + } } }, "installation-source": "dist", @@ -6808,7 +6813,9 @@ "description": "Provides a mechanism for modules to automatically generate aliases for the content they manage.", "homepage": "https://www.drupal.org/project/pathauto", "support": { - "source": "https://git.drupalcode.org/project/pathauto" + "source": "https://cgit.drupalcode.org/pathauto", + "issues": "https://www.drupal.org/project/issues/pathauto", + "documentation": "https://www.drupal.org/docs/8/modules/pathauto" } }, { diff --git a/web/modules/pathauto/README.md b/web/modules/pathauto/README.md index f3c04bc7cde53a3ad0e119af6e2be90bbcd6077a..bdc27cf645a6e73a89200043e15de1ecf5ea1e3d 100644 --- a/web/modules/pathauto/README.md +++ b/web/modules/pathauto/README.md @@ -2,13 +2,12 @@ CONTENTS OF THIS FILE --------------------- * Introduction - * Benefits * Requirements * Recommended Modules * Installation * Configuration * Notices - * Faqs + * Troubleshooting * Maintainers @@ -16,24 +15,24 @@ INTRODUCTION ------------ The Pathauto module provides support functions for other modules to -automatically generate aliases based on appropriate criteria, with a +automatically generate aliases based on appropriate criteria and tokens, with a central settings path for site administrators. Implementations are provided for core entity types: content, taxonomy terms, and users (including blogs and forum pages). -Pathauto also provides a way to delete large numbers of aliases.This feature -is available at Administer > Configuration > Search and metadata > URL aliases > Delete aliases. +Pathauto also provides a way to delete large numbers of aliases. This feature is +available at Administer > Configuration > Search and metadata > URL aliases > +Delete aliases. +Pathauto is beneficial for search engine optimization (SEO) and for ease-of-use +for visitors. -BENEFITS --------- + * For a full description of the module, visit the project page: + https://www.drupal.org/project/pathauto -Besides making the page address more reflective of its content than -"node/138", it's important to know that modern search engines give -heavy weight to search terms which appear in a page's URL. By -automatically using keywords based directly on the page content in the URL, -relevant search engine hits for your page can be significantly enhanced. + * To submit bug reports and feature suggestions, or track changes: + https://www.drupal.org/project/issues/pathauto REQUIREMENTS @@ -56,71 +55,68 @@ RECOMMENDED MODULES INSTALLATION ------------ -Install the module as you would normally install a -contributed Drupal module. Visit https://www.drupal.org/node/1897420 for -further information. Note that there are two dependencies. + * Install as you would normally install a contributed Drupal module. Visit + https://www.drupal.org/node/1897420 for further information. CONFIGURATION ------------- - 1. Navigate to Administration > Extend and enable the Pathauto module. - 2. Configure the module at admin/config/search/path/patterns - add a new - pattern by creating and clicking "Add Pathauto pattern". - 3. Fill out "Path pattern" with fx [node:title], choose which content - types this applies to,give it a label (the name) and save it. - 4. When you save new content from now on, it should automatically be - assigned an alternative URL. + 1. Configure the module at Administration > Configuration > Search and metadata + > URL aliases > Patterns (admin/config/search/path/patterns). Add a new + pattern by clicking "Add Pathauto pattern". + 2. Select the entity type for "Pattern Type", and provide an administrative + label. + 2. Fill out "Path pattern" with a token replacement pattern, such as + [node:title]. Use the "Browse available tokens" link to view available + variables to construct a URL alias pattern. + 3. Click "Save" to save your pattern. When you save new content from now on, it + will automatically be assigned the pathauto-configured URL alias. NOTICES ------- -Pathauto just adds URL aliases to content, users, and taxonomy terms. -Because it's an alias, the standard Drupal URL (for example node/123 or -taxonomy/term/1) will still function as normal. If you have external links -to your site pointing to standard Drupal URLs, or hardcoded links in a module, -template, content or menu which point to standard Drupal URLs it will bypass +Pathauto adds URL aliases to content, users, and taxonomy terms. Because the +patterns are an alias, the standard Drupal URL (for example node/123 or +taxonomy/term/1) will still function as normal. If you have external links to +your site pointing to standard Drupal URLs, or hardcoded links in a module, +template, content, or menu which point to standard Drupal URLs, it will bypass the alias set by Pathauto. -There are reasons you might not want two URLs for the same content on your -site. If this applies to you, please note that you will need to update any -hard coded links in your content or blocks. +There are reasons you might not want two URLs for the same content on your site. +If this applies to you, you will need to update any hard coded links in your +content or blocks. -If you use the "system path" (i.e. node/10) for menu items and settings like -that, Drupal will replace it with the url alias. +If you use the "system path" (i.e. node/10) for menu items and settings, Drupal +will replace it with the URL alias. -FAQs ----- +TROUBLESHOOTING +--------------- -* URLs (not) Getting Replaced With Aliases? - Please bear in mind that only URLs passed through Drupal's Drupal's URL and - Link APIs will be replaced with their aliases during page output. If - a module or your template contains hardcoded links, such as - 'href="node/$node->nid"', those won't get replaced with their corresponding - aliases. +Q: Why are URLs not getting replaced with aliases? +A: Only URLs passed through the Drupal URL and Link APIs will be replaced + with their aliases during page output. If a module or a template contains + hardcoded links (such as 'href="node/$node->nid"'), those will not get + replaced with their corresponding aliases. -* Disabling Pathauto for a specific content type (or taxonomy)? - When the pattern for a content type is left blank, the default pattern will - be used. But if the default pattern is also blank, Pathauto will be disabled +Q: How do you disable Pathauto for a specific content type (or taxonomy)? +A: When the pattern for a content type is left blank, the default pattern will + be used. If the default pattern is also blank, Pathauto will be disabled for that content type. MAINTAINERS ----------- -The original module combined the functionality of Mike Ryan's autopath with -Tommy Sundstrom's path_automatic. - -Significant enhancements were contributed by jdmquin @ www.bcdems.net. - -Matt England added the tracker support (tracker support has been removed in -recent changes). - -Other suggestions and patches contributed by the Drupal community. - Current maintainers: * Dave Reid - http://www.davereid.net * Sascha Grossenbacher - https://www.drupal.org/u/berdir + +The original Pathauto release combined the functionality of Mike Ryan's autopath +with Tommy Sundstrom's path_automatic. Significant enhancements were contributed +by jdmquin @ www.bcdems.net. Matt England added the (now deprecated) tracker +support. Other suggestions and patches have been contributed by the Drupal +community. diff --git a/web/modules/pathauto/composer.json b/web/modules/pathauto/composer.json new file mode 100644 index 0000000000000000000000000000000000000000..5f90dfab3adc42d86512b2e78cc0bd816f31c2b1 --- /dev/null +++ b/web/modules/pathauto/composer.json @@ -0,0 +1,26 @@ +{ + "name": "drupal/pathauto", + "description": "Provides a mechanism for modules to automatically generate aliases for the content they manage.", + "type": "drupal-module", + "license": "GPL-2.0-or-later", + "homepage": "https://www.drupal.org/project/pathauto", + "support": { + "issues": "https://www.drupal.org/project/issues/pathauto", + "documentation": "https://www.drupal.org/docs/8/modules/pathauto", + "source": "https://cgit.drupalcode.org/pathauto" + }, + "require": { + "drupal/token": "*", + "drupal/ctools": "*" + }, + "suggest": { + "drupal/redirect": "When installed Pathauto will provide a new \"Update Action\" in case your URLs change. This is the recommended update action and is considered the best practice for SEO and usability." + }, + "extra": { + "drush": { + "services": { + "drush.services.yml": "^9 || ^10" + } + } + } +} diff --git a/web/modules/pathauto/config/schema/pathauto_pattern.schema.yml b/web/modules/pathauto/config/schema/pathauto_pattern.schema.yml index 14a1ae7b6dad0904e8609f4408df1fe0bb62776c..3142ec3cc5d868730a2871f747cc76d17f1c02d3 100644 --- a/web/modules/pathauto/config/schema/pathauto_pattern.schema.yml +++ b/web/modules/pathauto/config/schema/pathauto_pattern.schema.yml @@ -8,8 +8,6 @@ pathauto.pattern.*: label: type: label label: 'Label' - uuid: - type: string type: type: string label: 'Pattern type' diff --git a/web/modules/pathauto/pathauto.info.yml b/web/modules/pathauto/pathauto.info.yml index 313503d66249c290245b12f7efaebf45209bb421..91df82602679539fbbf049cd13336ffb136eed03 100644 --- a/web/modules/pathauto/pathauto.info.yml +++ b/web/modules/pathauto/pathauto.info.yml @@ -1,12 +1,11 @@ name : 'Pathauto' description : 'Provides a mechanism for modules to automatically generate aliases for the content they manage.' -core: 8.x +core_version_requirement: ^8.8 || ^9 type: module dependencies: - ctools:ctools - drupal:path -- drupal:system (>=8.6) - token:token configure: entity.pathauto_pattern.collection @@ -14,7 +13,7 @@ configure: entity.pathauto_pattern.collection recommends: - redirect:redirect -# Information added by Drupal.org packaging script on 2019-12-04 -version: '8.x-1.6' +# Information added by Drupal.org packaging script on 2020-04-28 +version: '8.x-1.8' project: 'pathauto' -datestamp: 1575467315 +datestamp: 1588103048 diff --git a/web/modules/pathauto/pathauto.services.yml b/web/modules/pathauto/pathauto.services.yml index ece821dfa7f164a52c7aeb969301d929693c2d25..c6ba82549839c10eef613c8d5926903daa8ae2d2 100644 --- a/web/modules/pathauto/pathauto.services.yml +++ b/web/modules/pathauto/pathauto.services.yml @@ -12,7 +12,7 @@ services: - { name: backend_overridable } pathauto.alias_uniquifier: class: Drupal\pathauto\AliasUniquifier - arguments: ['@config.factory', '@pathauto.alias_storage_helper','@module_handler', '@router.route_provider', '@path.alias_manager'] + arguments: ['@config.factory', '@pathauto.alias_storage_helper','@module_handler', '@router.route_provider', '@path_alias.manager'] pathauto.verbose_messenger: class: Drupal\pathauto\VerboseMessenger arguments: ['@config.factory', '@current_user', '@messenger'] diff --git a/web/modules/pathauto/src/AliasCleaner.php b/web/modules/pathauto/src/AliasCleaner.php index f6c950826c818beaa34cb8f77c8117c4473fdb83..8cbf9ee352a514f863b980b36683eb36c1dd8709 100644 --- a/web/modules/pathauto/src/AliasCleaner.php +++ b/web/modules/pathauto/src/AliasCleaner.php @@ -231,16 +231,21 @@ public function cleanString($string, array $options = []) { $output = Html::decodeEntities($string); $output = PlainTextOutput::renderFromHtml($output); + // Replace or drop punctuation based on user settings. + $output = strtr($output, $this->cleanStringCache['punctuation']); + // Optionally transliterate. if ($this->cleanStringCache['transliterate']) { // If the reduce strings to letters and numbers is enabled, don't bother // replacing unknown characters with a question mark. Use an empty string // instead. $output = $this->transliteration->transliterate($output, $langcode, $this->cleanStringCache['reduce_ascii'] ? '' : '?'); + + // Replace or drop punctuation again as the transliteration process can + // convert special characters to punctuation. + $output = strtr($output, $this->cleanStringCache['punctuation']); } - // Replace or drop punctuation based on user settings. - $output = strtr($output, $this->cleanStringCache['punctuation']); // Reduce strings to letters and numbers. if ($this->cleanStringCache['reduce_ascii']) { diff --git a/web/modules/pathauto/src/AliasStorageHelper.php b/web/modules/pathauto/src/AliasStorageHelper.php index e654f6a4d5dc6d22929ce575f082e875b1d87572..8ed9b573c927117cef2288cec9d139b6ede19f60 100644 --- a/web/modules/pathauto/src/AliasStorageHelper.php +++ b/web/modules/pathauto/src/AliasStorageHelper.php @@ -7,9 +7,9 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Language\LanguageInterface; -use Drupal\Core\Path\AliasRepositoryInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\StringTranslation\TranslationInterface; +use Drupal\path_alias\AliasRepositoryInterface; /** * Provides helper methods for accessing alias storage. @@ -35,7 +35,7 @@ class AliasStorageHelper implements AliasStorageHelperInterface { /** * The alias repository. * - * @var \Drupal\Core\Path\AliasRepositoryInterface + * @var \Drupal\path_alias\AliasRepositoryInterface */ protected $aliasRepository; @@ -65,7 +65,7 @@ class AliasStorageHelper implements AliasStorageHelperInterface { * * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The config factory. - * @param \Drupal\Core\Path\AliasRepositoryInterface $alias_repository + * @param \Drupal\path_alias\AliasRepositoryInterface $alias_repository * The alias repository. * @param \Drupal\Core\Database\Connection $database * The database connection. diff --git a/web/modules/pathauto/src/AliasUniquifier.php b/web/modules/pathauto/src/AliasUniquifier.php index 5adcb94e835d30a544db9401d642d548df68f061..dc8a9e332d44ea2096a26e7073291a650d6b0796 100644 --- a/web/modules/pathauto/src/AliasUniquifier.php +++ b/web/modules/pathauto/src/AliasUniquifier.php @@ -6,8 +6,8 @@ use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Language\LanguageInterface; -use Drupal\Core\Path\AliasManagerInterface; use Drupal\Core\Routing\RouteProviderInterface; +use Drupal\path_alias\AliasManagerInterface; /** * Provides a utility for creating a unique path alias. @@ -45,7 +45,7 @@ class AliasUniquifier implements AliasUniquifierInterface { /** * The alias manager. * - * @var \Drupal\Core\Path\AliasManagerInterface + * @var \Drupal\path_alias\AliasManagerInterface */ protected $aliasManager; @@ -60,7 +60,7 @@ class AliasUniquifier implements AliasUniquifierInterface { * The module handler. * @param \Drupal\Core\Routing\RouteProviderInterface $route_provider * The route provider service. - * @param \Drupal\Core\Path\AliasManagerInterface $alias_manager + * @param \Drupal\path_alias\AliasManagerInterface $alias_manager * The alias manager. */ public function __construct(ConfigFactoryInterface $config_factory, AliasStorageHelperInterface $alias_storage_helper, ModuleHandlerInterface $module_handler, RouteProviderInterface $route_provider, AliasManagerInterface $alias_manager) { diff --git a/web/modules/pathauto/src/Form/PatternEditForm.php b/web/modules/pathauto/src/Form/PatternEditForm.php index f459f66d44a95c46ab148722adc2969a2d4c43c0..4c892d7dbbe45915b78062f3a94b51d766bfeeb9 100644 --- a/web/modules/pathauto/src/Form/PatternEditForm.php +++ b/web/modules/pathauto/src/Form/PatternEditForm.php @@ -72,7 +72,7 @@ public static function create(ContainerInterface $container) { * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager * The language manager service. */ - function __construct(AliasTypeManager $manager, EntityTypeBundleInfoInterface $entity_type_bundle_info, EntityTypeManagerInterface $entity_type_manager, LanguageManagerInterface $language_manager) { + public function __construct(AliasTypeManager $manager, EntityTypeBundleInfoInterface $entity_type_bundle_info, EntityTypeManagerInterface $entity_type_manager, LanguageManagerInterface $language_manager) { $this->manager = $manager; $this->entityTypeBundleInfo = $entity_type_bundle_info; $this->entityTypeManager = $entity_type_manager; @@ -139,7 +139,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { $default_bundles = []; $default_languages = []; - foreach ($this->entity->getSelectionConditions() as $condition_id => $condition) { + foreach ($this->entity->getSelectionConditions() as $condition) { if (in_array($condition->getPluginId(), ['entity_bundle:' . $entity_type->id(), 'node_type'])) { $default_bundles = $condition->getConfiguration()['bundles']; } @@ -256,7 +256,7 @@ public function buildEntity(array $form, FormStateInterface $form_state) { ] ] ); - $entity->addRelationship($language_mapping, t('Language')); + $entity->addRelationship($language_mapping, $this->t('Language')); } } diff --git a/web/modules/pathauto/src/LegacyAliasStorageHelper.php b/web/modules/pathauto/src/LegacyAliasStorageHelper.php deleted file mode 100644 index 0051b77deb0d4aad6b428b8fb83a93150d7e0623..0000000000000000000000000000000000000000 --- a/web/modules/pathauto/src/LegacyAliasStorageHelper.php +++ /dev/null @@ -1,249 +0,0 @@ -<?php - -namespace Drupal\pathauto; - -use Drupal\Core\Config\ConfigFactoryInterface; -use Drupal\Core\Database\Connection; -use Drupal\Core\Entity\EntityInterface; -use Drupal\Core\Language\LanguageInterface; -use Drupal\Core\Path\AliasStorageInterface; -use Drupal\Core\StringTranslation\StringTranslationTrait; -use Drupal\Core\StringTranslation\TranslationInterface; - -/** - * Provides helper methods for accessing alias storage. - */ -class LegacyAliasStorageHelper implements AliasStorageHelperInterface { - - use StringTranslationTrait; - - /** - * Alias schema max length. - * - * @var int - */ - protected $aliasSchemaMaxLength = 255; - - /** - * Config factory. - * - * @var \Drupal\Core\Config\ConfigFactoryInterface - */ - protected $configFactory; - - /** - * The alias storage. - * - * @var \Drupal\Core\Path\AliasStorageInterface - */ - protected $aliasStorage; - - /** - * The database connection. - * - * @var \Drupal\Core\Database\Connection - */ - protected $database; - - /** - * The messenger. - * - * @var \Drupal\pathauto\MessengerInterface - */ - protected $messenger; - - /** - * The config factory. - * - * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory - * The config factory. - * @param \Drupal\Core\Path\AliasStorageInterface $alias_storage - * The alias storage. - * @param \Drupal\Core\Database\Connection $database - * The database connection. - * @param MessengerInterface $messenger - * The messenger. - * @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation - * The string translation service. - */ - public function __construct(ConfigFactoryInterface $config_factory, AliasStorageInterface $alias_storage, Connection $database, MessengerInterface $messenger, TranslationInterface $string_translation) { - $this->configFactory = $config_factory; - $this->aliasStorage = $alias_storage; - $this->database = $database; - $this->messenger = $messenger; - $this->stringTranslation = $string_translation; - } - - /** - * {@inheritdoc} - */ - public function getAliasSchemaMaxLength() { - return $this->aliasSchemaMaxLength; - } - - /** - * {@inheritdoc} - */ - public function save(array $path, $existing_alias = NULL, $op = NULL) { - $config = $this->configFactory->get('pathauto.settings'); - - // Alert users if they are trying to create an alias that is the same as the - // internal path. - if ($path['source'] == $path['alias']) { - $this->messenger->addMessage($this->t('Ignoring alias %alias because it is the same as the internal path.', ['%alias' => $path['alias']])); - return NULL; - } - - // Skip replacing the current alias with an identical alias. - if (empty($existing_alias) || $existing_alias['alias'] != $path['alias']) { - $path += [ - 'pathauto' => TRUE, - 'original' => $existing_alias, - 'pid' => NULL, - ]; - - // If there is already an alias, respect some update actions. - if (!empty($existing_alias)) { - switch ($config->get('update_action')) { - case PathautoGeneratorInterface::UPDATE_ACTION_NO_NEW: - // Do not create the alias. - return NULL; - - case PathautoGeneratorInterface::UPDATE_ACTION_LEAVE: - // Create a new alias instead of overwriting the existing by leaving - // $path['pid'] empty. - break; - - case PathautoGeneratorInterface::UPDATE_ACTION_DELETE: - // The delete actions should overwrite the existing alias. - $path['pid'] = $existing_alias['pid']; - break; - } - } - - // Save the path array. - $this->aliasStorage->save($path['source'], $path['alias'], $path['language'], $path['pid']); - - if (!empty($existing_alias['pid'])) { - $this->messenger->addMessage($this->t( - 'Created new alias %alias for %source, replacing %old_alias.', - [ - '%alias' => $path['alias'], - '%source' => $path['source'], - '%old_alias' => $existing_alias['alias'], - ] - ) - ); - } - else { - $this->messenger->addMessage($this->t('Created new alias %alias for %source.', [ - '%alias' => $path['alias'], - '%source' => $path['source'], - ])); - } - - return $path; - } - } - - /** - * {@inheritdoc} - */ - public function loadBySource($source, $language = LanguageInterface::LANGCODE_NOT_SPECIFIED) { - $alias = $this->aliasStorage->load([ - 'source' => $source, - 'langcode' => $language, - ]); - // If no alias was fetched and if a language was specified, fallbacks to - // undefined language. - if (!$alias && ($language !== LanguageInterface::LANGCODE_NOT_SPECIFIED)) { - $alias = $this->aliasStorage->load([ - 'source' => $source, - 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, - ]); - } - return $alias; - } - - /** - * {@inheritdoc} - */ - public function deleteBySourcePrefix($source) { - $pids = $this->loadBySourcePrefix($source); - if ($pids) { - $this->deleteMultiple($pids); - } - } - - /** - * {@inheritdoc} - */ - public function deleteAll() { - $this->database->truncate('url_alias')->execute(); - } - - /** - * {@inheritdoc} - */ - public function deleteEntityPathAll(EntityInterface $entity, $default_uri = NULL) { - $this->deleteBySourcePrefix('/' . $entity->toUrl('canonical')->getInternalPath()); - if (isset($default_uri) && $entity->toUrl('canonical')->toString() != $default_uri) { - $this->deleteBySourcePrefix($default_uri); - } - } - - /** - * {@inheritdoc} - */ - public function loadBySourcePrefix($source) { - $select = $this->database->select('url_alias', 'u') - ->fields('u', ['pid']); - - $or_group = $select->orConditionGroup() - ->condition('source', $source) - ->condition('source', rtrim($source, '/') . '/%', 'LIKE'); - - return $select - ->condition($or_group) - ->execute() - ->fetchCol(); - } - - /** - * {@inheritdoc} - */ - public function countBySourcePrefix($source) { - $select = $this->database->select('url_alias', 'u') - ->fields('u', ['pid']); - - $or_group = $select->orConditionGroup() - ->condition('source', $source) - ->condition('source', rtrim($source, '/') . '/%', 'LIKE'); - - return $select - ->condition($or_group) - ->countQuery() - ->execute() - ->fetchField(); - } - - /** - * {@inheritdoc} - */ - public function countAll() { - return $this->database->select('url_alias') - ->countQuery() - ->execute() - ->fetchField(); - } - - /** - * {@inheritdoc} - */ - public function deleteMultiple($pids) { - foreach ($pids as $pid) { - $this->aliasStorage->delete(['pid' => $pid]); - } - } - -} diff --git a/web/modules/pathauto/src/PathautoPatternListBuilder.php b/web/modules/pathauto/src/PathautoPatternListBuilder.php index 10de0b655037fa8bb8b2d2a6c35499ebb9c3cda2..dd3ed4ef7d1a75bc88b0a7fd61335626fe0f1cf1 100644 --- a/web/modules/pathauto/src/PathautoPatternListBuilder.php +++ b/web/modules/pathauto/src/PathautoPatternListBuilder.php @@ -60,7 +60,7 @@ public function getDefaultOperations(EntityInterface $entity) { } $operations['duplicate'] = [ - 'title' => t('Duplicate'), + 'title' => $this->t('Duplicate'), 'weight' => 0, 'url' => $this->ensureDestination($entity->toUrl('duplicate-form')), ]; diff --git a/web/modules/pathauto/src/PathautoServiceProvider.php b/web/modules/pathauto/src/PathautoServiceProvider.php index f35faff261e20c15aa2f7c3a52b44333a55e72bf..ea05c45e287383b4f424c806836681042950e423 100644 --- a/web/modules/pathauto/src/PathautoServiceProvider.php +++ b/web/modules/pathauto/src/PathautoServiceProvider.php @@ -4,21 +4,19 @@ use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Core\DependencyInjection\ServiceProviderBase; -use Symfony\Component\DependencyInjection\Reference; /** - * Overrides the pathauto.alias_storage_helper service if needed. + * Remove the drush commands until path_alias module is enabled. */ class PathautoServiceProvider extends ServiceProviderBase { /** * {@inheritdoc} */ - public function alter(ContainerBuilder $container) { - if (version_compare(\Drupal::VERSION, '8.8', '<')) { - $definition = $container->getDefinition('pathauto.alias_storage_helper'); - $definition->setClass(LegacyAliasStorageHelper::class); - $definition->setArgument(1, new Reference('path.alias_storage')); + public function register(ContainerBuilder $container) { + $definitions = array_keys($container->getDefinitions()); + if (!in_array('path_alias.repository', $definitions)) { + $container->removeDefinition('pathauto.commands'); } } diff --git a/web/modules/pathauto/src/Plugin/Deriver/EntityAliasTypeDeriver.php b/web/modules/pathauto/src/Plugin/Deriver/EntityAliasTypeDeriver.php index 13fb422e61dca0f476c15076bd1f900441217b26..37f751c1d8eefda7fcecad5848db17812cef307e 100644 --- a/web/modules/pathauto/src/Plugin/Deriver/EntityAliasTypeDeriver.php +++ b/web/modules/pathauto/src/Plugin/Deriver/EntityAliasTypeDeriver.php @@ -6,7 +6,6 @@ use Drupal\Core\Entity\EntityFieldManagerInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\FieldableEntityInterface; -use Drupal\Core\Plugin\Context\ContextDefinition; use Drupal\Core\Plugin\Context\EntityContextDefinition; use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; @@ -86,8 +85,8 @@ public function getDerivativeDefinitions($base_plugin_definition) { $this->derivatives[$entity_type_id]['label'] = $entity_type->getLabel(); $this->derivatives[$entity_type_id]['types'] = [$this->tokenEntityMapper->getTokenTypeForEntityType($entity_type_id)]; $this->derivatives[$entity_type_id]['provider'] = $entity_type->getProvider(); - $this->derivatives[$entity_type_id]['context'] = [ - $entity_type_id => EntityContextDefinition::fromEntityType($entity_type)->setLabel($this->t('@label being aliased', ['@label' => $entity_type->getLabel()])) + $this->derivatives[$entity_type_id]['context_definitions'] = [ + $entity_type_id => new EntityContextDefinition("entity:$entity_type_id", $this->t('@label being aliased', ['@label' => $entity_type->getLabel()])) ]; } } diff --git a/web/modules/pathauto/src/Plugin/migrate/source/PathautoPattern.php b/web/modules/pathauto/src/Plugin/migrate/source/PathautoPattern.php index 56d7b4fb90a54436cd65c83cca15fdeaa38fe6f2..a2a92c8691d09381063862dfac96ddb8f762a8a6 100644 --- a/web/modules/pathauto/src/Plugin/migrate/source/PathautoPattern.php +++ b/web/modules/pathauto/src/Plugin/migrate/source/PathautoPattern.php @@ -2,8 +2,8 @@ namespace Drupal\pathauto\Plugin\migrate\source; -use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; +use Drupal\Core\Entity\EntityTypeBundleInfo; use Drupal\Core\State\StateInterface; use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate\Row; @@ -21,18 +21,18 @@ class PathautoPattern extends DrupalSqlBase { /** - * The entity type manager. + * The entity type bundle info. * - * @var \Drupal\Core\Entity\EntityTypeManagerInterface + * @var \Drupal\Core\Entity\EntityTypeBundleInfo */ - protected $entityTypeManager; + protected $entityTypeBundleInfo; /** * {@inheritdoc} */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityManagerInterface $entity_manager, EntityTypeManagerInterface $entity_type_manager) { - parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $state, $entity_manager); - $this->entityTypeManager = $entity_type_manager; + public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityTypeManagerInterface $entity_type_manager, EntityTypeBundleInfo $entity_bundle_info) { + parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $state, $entity_type_manager); + $this->entityTypeBundleInfo = $entity_bundle_info; } /** @@ -45,8 +45,8 @@ public static function create(ContainerInterface $container, array $configuratio $plugin_definition, $migration, $container->get('state'), - $container->get('entity.manager'), - $container->get('entity_type.manager') + $container->get('entity_type.manager'), + $container->get('entity_type.bundle.info') ); } @@ -104,7 +104,7 @@ public function prepareRow(Row $row) { $bundle = $matches[1]; // Check that the bundle exists. - $bundles = $this->entityManager->getBundleInfo($entity_type); + $bundles = $this->entityTypeBundleInfo->getBundleInfo($entity_type); if (!in_array($bundle, array_keys($bundles))) { // No matching bundle found in destination. return FALSE; diff --git a/web/modules/pathauto/src/Plugin/pathauto/AliasType/EntityAliasTypeBase.php b/web/modules/pathauto/src/Plugin/pathauto/AliasType/EntityAliasTypeBase.php index 81ef363b84c491d4b4f2f463d597123159211e0e..d01db94a44663deb07e1277b9321376b1dc0fca1 100644 --- a/web/modules/pathauto/src/Plugin/pathauto/AliasType/EntityAliasTypeBase.php +++ b/web/modules/pathauto/src/Plugin/pathauto/AliasType/EntityAliasTypeBase.php @@ -234,7 +234,7 @@ public function batchDelete(&$context) { PathautoState::bulkDelete($this->getEntityTypeId(), $pids_by_id); $context['sandbox']['count'] += count($pids_by_id); - $context['sandbox']['current'] = max($pids_by_id); + $context['sandbox']['current'] = !empty($pids_by_id) ? max($pids_by_id) : 0; $context['results']['deletions'][] = $this->getLabel(); if ($context['sandbox']['count'] != $context['sandbox']['total']) { diff --git a/web/modules/pathauto/src/Plugin/pathauto/AliasType/ForumAliasType.php b/web/modules/pathauto/src/Plugin/pathauto/AliasType/ForumAliasType.php index ee8a341e8bca735e578803e19b0825350dcf2d4b..96f487e0192c5d33e30c19e050e6b3f5cd96c65c 100644 --- a/web/modules/pathauto/src/Plugin/pathauto/AliasType/ForumAliasType.php +++ b/web/modules/pathauto/src/Plugin/pathauto/AliasType/ForumAliasType.php @@ -19,7 +19,7 @@ * label = @Translation("Forum"), * types = {"term"}, * provider = "forum", - * context = { + * context_definitions = { * "taxonomy_term" = @ContextDefinition("entity:taxonomy_term") * } * ) diff --git a/web/modules/pathauto/tests/modules/pathauto_custom_punctuation_test/pathauto_custom_punctuation_test.info.yml b/web/modules/pathauto/tests/modules/pathauto_custom_punctuation_test/pathauto_custom_punctuation_test.info.yml new file mode 100644 index 0000000000000000000000000000000000000000..039f05a5bff912b86c40010bec534a02280746c3 --- /dev/null +++ b/web/modules/pathauto/tests/modules/pathauto_custom_punctuation_test/pathauto_custom_punctuation_test.info.yml @@ -0,0 +1,10 @@ +name: 'Pathauto custom punctuation testing module' +type: module +core_version_requirement: ^8.8 || ^9 +description: 'Add some uncommon punctuation to the replacement list.' +package: Testing + +# Information added by Drupal.org packaging script on 2020-04-28 +version: '8.x-1.8' +project: 'pathauto' +datestamp: 1588103048 diff --git a/web/modules/pathauto/tests/modules/pathauto_custom_punctuation_test/pathauto_custom_punctuation_test.module b/web/modules/pathauto/tests/modules/pathauto_custom_punctuation_test/pathauto_custom_punctuation_test.module new file mode 100644 index 0000000000000000000000000000000000000000..ae95a13fdc79cf7c43c04323f440f24f0f6dba3f --- /dev/null +++ b/web/modules/pathauto/tests/modules/pathauto_custom_punctuation_test/pathauto_custom_punctuation_test.module @@ -0,0 +1,8 @@ +<?php + +/** + * Implements hook_pathauto_punctuation_chars_alter(). + */ +function pathauto_custom_punctuation_test_pathauto_punctuation_chars_alter(array &$punctuation) { + $punctuation['copyright'] = ['value' => '©', 'name' => t('Copyright symbol')]; +} diff --git a/web/modules/pathauto/tests/modules/pathauto_string_id_test/pathauto_string_id_test.info.yml b/web/modules/pathauto/tests/modules/pathauto_string_id_test/pathauto_string_id_test.info.yml index 5c1a63e9240ba83fec13039587ff67de9669abfb..7e8fa2163d63d58c3702624abe570f9e092a25a7 100644 --- a/web/modules/pathauto/tests/modules/pathauto_string_id_test/pathauto_string_id_test.info.yml +++ b/web/modules/pathauto/tests/modules/pathauto_string_id_test/pathauto_string_id_test.info.yml @@ -1,12 +1,12 @@ name: 'Pathauto testing module' type: module -core: '8.x' +core_version_requirement: ^8.8 || ^9 description: 'Pathauto for Entity with string ID.' package: Testing dependencies: - token:token -# Information added by Drupal.org packaging script on 2019-12-04 -version: '8.x-1.6' +# Information added by Drupal.org packaging script on 2020-04-28 +version: '8.x-1.8' project: 'pathauto' -datestamp: 1575467315 +datestamp: 1588103048 diff --git a/web/modules/pathauto/tests/modules/pathauto_views_test/pathauto_views_test.info.yml b/web/modules/pathauto/tests/modules/pathauto_views_test/pathauto_views_test.info.yml index a800d94375ffbe454119e86dcfde41ec724870f3..eaa18cfcc9d742c67e69e8f2707b12a8d87fffb9 100644 --- a/web/modules/pathauto/tests/modules/pathauto_views_test/pathauto_views_test.info.yml +++ b/web/modules/pathauto/tests/modules/pathauto_views_test/pathauto_views_test.info.yml @@ -2,11 +2,11 @@ name: 'Views Test Config' type: module description: 'Provides default views for tests.' package: Testing -core: 8.x +core_version_requirement: ^8.8 || ^9 dependencies: - drupal:views -# Information added by Drupal.org packaging script on 2019-12-04 -version: '8.x-1.6' +# Information added by Drupal.org packaging script on 2020-04-28 +version: '8.x-1.8' project: 'pathauto' -datestamp: 1575467315 +datestamp: 1588103048 diff --git a/web/modules/pathauto/tests/src/Functional/PathautoBulkUpdateTest.php b/web/modules/pathauto/tests/src/Functional/PathautoBulkUpdateTest.php index d9002267c4733ea577b25a122cb95650493722ba..1cad4f487d43d1dafa39cc4fd9c3a5be0aac1559 100644 --- a/web/modules/pathauto/tests/src/Functional/PathautoBulkUpdateTest.php +++ b/web/modules/pathauto/tests/src/Functional/PathautoBulkUpdateTest.php @@ -15,6 +15,11 @@ class PathautoBulkUpdateTest extends BrowserTestBase { use PathautoTestHelperTrait; + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'stable'; + /** * Modules to enable. * @@ -46,7 +51,7 @@ class PathautoBulkUpdateTest extends BrowserTestBase { /** * {@inheritdoc} */ - function setUp() { + protected function setUp() { parent::setUp(); // Allow other modules to add additional permissions for the admin user. @@ -65,7 +70,7 @@ function setUp() { $this->patterns['forum'] = $this->createPattern('forum', '/forums/[term:name]'); } - function testBulkUpdate() { + public function testBulkUpdate() { // Create some nodes. $this->nodes = []; for ($i = 1; $i <= 5; $i++) { @@ -93,7 +98,7 @@ function testBulkUpdate() { } $this->assertEntityAliasExists($this->adminUser); // This is the default "General discussion" forum. - $this->assertAliasExists(['source' => '/taxonomy/term/1']); + $this->assertAliasExists(['path' => '/taxonomy/term/1']); // Add a new node. $new_node = $this->drupalCreateNode(['path' => ['alias' => '', 'pathauto' => PathautoState::SKIP]]); @@ -134,7 +139,7 @@ function testBulkUpdate() { /** * Tests alias generation for nodes that existed before installing Pathauto. */ - function testBulkUpdateExistingContent() { + public function testBulkUpdateExistingContent() { // Create a node. $node = $this->drupalCreateNode(); diff --git a/web/modules/pathauto/tests/src/Functional/PathautoEnablingEntityTypesTest.php b/web/modules/pathauto/tests/src/Functional/PathautoEnablingEntityTypesTest.php index 2fe2d393460203969a8d7f4667656cacbb02cd17..0818049c5c6105454c7190a8701706e01ecc7076 100644 --- a/web/modules/pathauto/tests/src/Functional/PathautoEnablingEntityTypesTest.php +++ b/web/modules/pathauto/tests/src/Functional/PathautoEnablingEntityTypesTest.php @@ -16,6 +16,11 @@ class PathautoEnablingEntityTypesTest extends BrowserTestBase { use CommentTestTrait; + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'stable'; + /** * Modules to enable. * @@ -33,7 +38,7 @@ class PathautoEnablingEntityTypesTest extends BrowserTestBase { /** * {@inheritdoc} */ - function setUp() { + protected function setUp() { parent::setUp(); $this->drupalCreateContentType(['type' => 'article']); @@ -55,7 +60,7 @@ function setUp() { * ability to define alias patterns for a given entity type works. Test with * the comment module, as it is not enabled by default. */ - function testEnablingEntityTypes() { + public function testEnablingEntityTypes() { // Verify that the comment entity type is not available when trying to add // a new pattern, nor "broken". $this->drupalGet('/admin/config/search/path/patterns/add'); diff --git a/web/modules/pathauto/tests/src/Functional/PathautoMassDeleteTest.php b/web/modules/pathauto/tests/src/Functional/PathautoMassDeleteTest.php index 890e488fa3d0885983fecbb90d703322405af0bc..ad8b4d83997f2b0936dc13fb98bdd750585d086d 100644 --- a/web/modules/pathauto/tests/src/Functional/PathautoMassDeleteTest.php +++ b/web/modules/pathauto/tests/src/Functional/PathautoMassDeleteTest.php @@ -14,6 +14,11 @@ class PathautoMassDeleteTest extends BrowserTestBase { use PathautoTestHelperTrait; + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'stable'; + /** * Modules to enable. * @@ -52,7 +57,7 @@ class PathautoMassDeleteTest extends BrowserTestBase { /** * {@inheritdoc} */ - function setUp() { + protected function setUp() { parent::setUp(); $permissions = [ @@ -71,7 +76,7 @@ function setUp() { /** * Tests the deletion of all the aliases. */ - function testDeleteAll() { + public function testDeleteAll() { /** @var \Drupal\pathauto\AliasStorageHelperInterface $alias_storage_helper */ $alias_storage_helper = \Drupal::service('pathauto.alias_storage_helper'); @@ -138,7 +143,7 @@ function testDeleteAll() { /** * Helper function to generate aliases. */ - function generateAliases() { + public function generateAliases() { // Delete all aliases to avoid duplicated aliases. They will be recreated // below. $this->deleteAllAliases(); @@ -176,7 +181,7 @@ function generateAliases() { } } else { - foreach ($this->accounts as $id => $account) { + foreach ($this->accounts as $account) { $account->save(); } } diff --git a/web/modules/pathauto/tests/src/Functional/PathautoNodeWebTest.php b/web/modules/pathauto/tests/src/Functional/PathautoNodeWebTest.php index 2d5e67da06d3432da986710a87215e7da0af462f..f9a5bcafad0d080385b596d6c20c05d8d2370d7e 100644 --- a/web/modules/pathauto/tests/src/Functional/PathautoNodeWebTest.php +++ b/web/modules/pathauto/tests/src/Functional/PathautoNodeWebTest.php @@ -16,6 +16,11 @@ class PathautoNodeWebTest extends BrowserTestBase { use PathautoTestHelperTrait; + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'stable'; + /** * Modules to enable. * @@ -33,7 +38,7 @@ class PathautoNodeWebTest extends BrowserTestBase { /** * {@inheritdoc} */ - function setUp() { + protected function setUp() { parent::setUp(); $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']); @@ -56,7 +61,7 @@ function setUp() { /** * Tests editing nodes with different settings. */ - function testNodeEditing() { + public function testNodeEditing() { // Ensure that the Pathauto checkbox is checked by default on the node add // form. $this->drupalGet('node/add/page'); @@ -144,7 +149,7 @@ function testNodeEditing() { /** * Test node operations. */ - function testNodeOperations() { + public function testNodeOperations() { $node1 = $this->drupalCreateNode(['title' => 'node1']); $node2 = $this->drupalCreateNode(['title' => 'node2']); @@ -196,7 +201,7 @@ public function testNodeState() { // Ensure that the pathauto field was saved to the database. \Drupal::entityTypeManager()->getStorage('node')->resetCache(); $node = Node::load($node->id()); - $this->assertIdentical($node->path->pathauto, PathautoState::SKIP); + $this->assertSame(PathautoState::SKIP, $node->path->pathauto); // Ensure that the manual path alias was saved and an automatic alias was not generated. $this->assertEntityAlias($node, '/test-alias'); @@ -243,7 +248,7 @@ public function testNodeState() { // Ensure that the pathauto field was saved to the database. \Drupal::entityTypeManager()->getStorage('node')->resetCache(); $node = Node::load($node->id()); - $this->assertIdentical($node->path->pathauto, PathautoState::CREATE); + $this->assertSame(PathautoState::CREATE, $node->path->pathauto); $this->assertEntityAlias($node, '/content/node-version-three'); $this->assertNoEntityAliasExists($node, '/manually-edited-alias'); diff --git a/web/modules/pathauto/tests/src/Functional/PathautoSettingsFormWebTest.php b/web/modules/pathauto/tests/src/Functional/PathautoSettingsFormWebTest.php index 9d91b8837bbbdd3c3425a2e7cde8084baad998e5..bbbb3c0ccc69f09c758ec769631150944df643bb 100644 --- a/web/modules/pathauto/tests/src/Functional/PathautoSettingsFormWebTest.php +++ b/web/modules/pathauto/tests/src/Functional/PathautoSettingsFormWebTest.php @@ -14,6 +14,11 @@ class PathautoSettingsFormWebTest extends BrowserTestBase { use PathautoTestHelperTrait; + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'stable'; + /** * Modules to enable. * @@ -87,7 +92,7 @@ class PathautoSettingsFormWebTest extends BrowserTestBase { /** * {@inheritdoc} */ - function setUp() { + protected function setUp() { parent::setUp(); $this->drupalCreateContentType(['type' => 'article']); @@ -107,7 +112,7 @@ function setUp() { /** * Test if the default values are shown correctly in the form. */ - function testDefaultFormValues() { + public function testDefaultFormValues() { $this->drupalGet('/admin/config/search/path/settings'); $this->assertNoFieldChecked('edit-verbose'); $this->assertField('edit-separator', $this->defaultFormValues['separator']); @@ -123,7 +128,7 @@ function testDefaultFormValues() { /** * Test the verbose option. */ - function testVerboseOption() { + public function testVerboseOption() { $edit = ['verbose' => '1']; $this->drupalPostForm('/admin/config/search/path/settings', $edit, t('Save configuration')); $this->assertText(t('The configuration options have been saved.')); @@ -144,7 +149,7 @@ function testVerboseOption() { /** * Tests generating aliases with different settings. */ - function testSettingsForm() { + public function testSettingsForm() { // Ensure the separator settings apply correctly. $this->checkAlias('My awesome content', '/content/my.awesome.content', ['separator' => '.']); @@ -170,7 +175,7 @@ function testSettingsForm() { /** * Test the punctuation setting form items. */ - function testPunctuationSettings() { + public function testPunctuationSettings() { // Test the replacement of punctuations. $settings = []; foreach ($this->defaultPunctuations as $key => $punctuation) { diff --git a/web/modules/pathauto/tests/src/Functional/PathautoTaxonomyWebTest.php b/web/modules/pathauto/tests/src/Functional/PathautoTaxonomyWebTest.php index a0b5ddbcd706083ebaaab848f7492f88e46c9e71..9b643a1d169ce561171bf90f7c4e8588294f5d5f 100644 --- a/web/modules/pathauto/tests/src/Functional/PathautoTaxonomyWebTest.php +++ b/web/modules/pathauto/tests/src/Functional/PathautoTaxonomyWebTest.php @@ -13,6 +13,11 @@ class PathautoTaxonomyWebTest extends BrowserTestBase { use PathautoTestHelperTrait; + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'stable'; + /** * Modules to enable. * @@ -30,7 +35,7 @@ class PathautoTaxonomyWebTest extends BrowserTestBase { /** * {@inheritdoc} */ - function setUp() { + protected function setUp() { parent::setUp(); // Allow other modules to add additional permissions for the admin user. @@ -49,12 +54,12 @@ function setUp() { /** * Basic functional testing of Pathauto with taxonomy terms. */ - function testTermEditing() { + public function testTermEditing() { $this->drupalGet('admin/structure'); $this->drupalGet('admin/structure/taxonomy'); // Add vocabulary "tags". - $vocabulary = $this->addVocabulary(['name' => 'tags', 'vid' => 'tags']); + $this->addVocabulary(['name' => 'tags', 'vid' => 'tags']); // Create term for testing. $name = 'Testing: term name ['; diff --git a/web/modules/pathauto/tests/src/Functional/PathautoTestHelperTrait.php b/web/modules/pathauto/tests/src/Functional/PathautoTestHelperTrait.php index 95711cecd034a0ed72d5a3d582bf1d632ddb707d..0e6e9be8b0f07c23c0f44420bc8014ff6d7b9fd0 100644 --- a/web/modules/pathauto/tests/src/Functional/PathautoTestHelperTrait.php +++ b/web/modules/pathauto/tests/src/Functional/PathautoTestHelperTrait.php @@ -10,12 +10,15 @@ use Drupal\taxonomy\VocabularyInterface; use Drupal\taxonomy\Entity\Vocabulary; use Drupal\taxonomy\Entity\Term; +use Drupal\Tests\Traits\Core\PathAliasTestTrait; /** * Helper test class with some added functions for testing. */ trait PathautoTestHelperTrait { + use PathAliasTestTrait; + /** * Creates a pathauto pattern. * @@ -76,17 +79,12 @@ public function assertToken($type, $object, $token, $expected) { $this->assertSame($tokens[$token], $expected, t("Token value for [@type:@token] was '@actual', expected value '@expected'.", ['@type' => $type, '@token' => $token, '@actual' => $tokens[$token], '@expected' => $expected])); } - public function saveAlias($source, $alias, $langcode = Language::LANGCODE_NOT_SPECIFIED) { - \Drupal::service('path.alias_storage')->delete(['source' => $source, 'langcode' => $langcode]); - return \Drupal::service('path.alias_storage')->save($source, $alias, $langcode); - } - public function saveEntityAlias(EntityInterface $entity, $alias, $langcode = NULL) { // By default, use the entity language. if (!$langcode) { $langcode = $entity->language()->getId(); } - return $this->saveAlias('/' . $entity->toUrl()->getInternalPath(), $alias, $langcode); + return $this->createPathAlias('/' . $entity->toUrl()->getInternalPath(), $alias, $langcode); } public function assertEntityAlias(EntityInterface $entity, $expected_alias, $langcode = NULL) { @@ -98,7 +96,7 @@ public function assertEntityAlias(EntityInterface $entity, $expected_alias, $lan } public function assertEntityAliasExists(EntityInterface $entity) { - return $this->assertAliasExists(['source' => '/' . $entity->toUrl()->getInternalPath()]); + return $this->assertAliasExists(['path' => '/' . $entity->toUrl()->getInternalPath()]); } public function assertNoEntityAlias(EntityInterface $entity, $langcode = NULL) { @@ -110,7 +108,7 @@ public function assertNoEntityAlias(EntityInterface $entity, $langcode = NULL) { } public function assertNoEntityAliasExists(EntityInterface $entity, $alias = NULL) { - $path = ['source' => '/' . $entity->toUrl()->getInternalPath()]; + $path = ['path' => '/' . $entity->toUrl()->getInternalPath()]; if (!empty($alias)) { $path['alias'] = $alias; } @@ -118,29 +116,29 @@ public function assertNoEntityAliasExists(EntityInterface $entity, $alias = NULL } public function assertAlias($source, $expected_alias, $langcode = Language::LANGCODE_NOT_SPECIFIED) { - \Drupal::service('path.alias_manager')->cacheClear($source); + \Drupal::service('path_alias.manager')->cacheClear($source); $entity_type_manager = \Drupal::entityTypeManager(); if ($entity_type_manager->hasDefinition('path_alias')) { $entity_type_manager->getStorage('path_alias')->resetCache(); } - $this->assertEquals($expected_alias, \Drupal::service('path.alias_manager')->getAliasByPath($source, $langcode), t("Alias for %source with language '@language' is correct.", + $this->assertEquals($expected_alias, \Drupal::service('path_alias.manager')->getAliasByPath($source, $langcode), t("Alias for %source with language '@language' is correct.", ['%source' => $source, '@language' => $langcode])); } public function assertAliasExists($conditions) { - $path = \Drupal::service('path.alias_storage')->load($conditions); - $this->assertTrue($path, t('Alias with conditions @conditions found.', ['@conditions' => var_export($conditions, TRUE)])); + $path = $this->loadPathAliasByConditions($conditions); + $this->assertNotEmpty($path, t('Alias with conditions @conditions found.', ['@conditions' => var_export($conditions, TRUE)])); return $path; } public function assertNoAliasExists($conditions) { - $alias = \Drupal::service('path.alias_storage')->load($conditions); - $this->assertFalse($alias, t('Alias with conditions @conditions not found.', ['@conditions' => var_export($conditions, TRUE)])); + $alias = $this->loadPathAliasByConditions($conditions); + $this->assertEmpty($alias, t('Alias with conditions @conditions not found.', ['@conditions' => var_export($conditions, TRUE)])); } public function deleteAllAliases() { \Drupal::service('pathauto.alias_storage_helper')->deleteAll(); - \Drupal::service('path.alias_manager')->cacheClear(); + \Drupal::service('path_alias.manager')->cacheClear(); } /** diff --git a/web/modules/pathauto/tests/src/Functional/PathautoUserWebTest.php b/web/modules/pathauto/tests/src/Functional/PathautoUserWebTest.php index 076fdd27bb75f6e67f5187bcc794cf29b5f6005f..8d5cfd8447eb5658f64e03edb9060a372ce75dd1 100644 --- a/web/modules/pathauto/tests/src/Functional/PathautoUserWebTest.php +++ b/web/modules/pathauto/tests/src/Functional/PathautoUserWebTest.php @@ -15,6 +15,11 @@ class PathautoUserWebTest extends BrowserTestBase { use PathautoTestHelperTrait; /** + * {@inheritdoc} + */ + protected $defaultTheme = 'stable'; + + /** * Modules to enable. * * @var array @@ -31,7 +36,7 @@ class PathautoUserWebTest extends BrowserTestBase { /** * {@inheritdoc} */ - function setUp() { + protected function setUp() { parent::setUp(); // Allow other modules to add additional permissions for the admin user. @@ -50,7 +55,7 @@ function setUp() { /** * Basic functional testing of Pathauto with users. */ - function testUserEditing() { + public function testUserEditing() { // There should be no Pathauto checkbox on user forms. $this->drupalGet('user/' . $this->adminUser->id() . '/edit'); $this->assertNoFieldById('path[0][pathauto]'); @@ -59,7 +64,7 @@ function testUserEditing() { /** * Test user operations. */ - function testUserOperations() { + public function testUserOperations() { $account = $this->drupalCreateUser(); // Delete all current URL aliases. diff --git a/web/modules/pathauto/tests/src/FunctionalJavascript/PathautoLocaleTest.php b/web/modules/pathauto/tests/src/FunctionalJavascript/PathautoLocaleTest.php index fedf22a11062880757b9a58ac3eccabd1a78d0af..596fc775d307a196ec5cd3e9691e4e15a0739b4a 100644 --- a/web/modules/pathauto/tests/src/FunctionalJavascript/PathautoLocaleTest.php +++ b/web/modules/pathauto/tests/src/FunctionalJavascript/PathautoLocaleTest.php @@ -18,6 +18,11 @@ class PathautoLocaleTest extends WebDriverTestBase { use PathautoTestHelperTrait; + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'stable'; + /** * Modules to enable. * @@ -39,7 +44,7 @@ protected function setUp() { * Test that when an English node is updated, its old English alias is * updated and its newer French alias is left intact. */ - function testLanguageAliases() { + public function testLanguageAliases() { $this->createPattern('node', '/content/[node:title]'); @@ -55,8 +60,8 @@ function testLanguageAliases() { ]], ]; $node = $this->drupalCreateNode($node); - $english_alias = \Drupal::service('path.alias_storage')->load(['alias' => '/english-node', 'langcode' => 'en']); - $this->assertTrue($english_alias, 'Alias created with proper language.'); + $english_alias = $this->loadPathAliasByConditions(['alias' => '/english-node', 'langcode' => 'en']); + $this->assertNotEmpty($english_alias, 'Alias created with proper language.'); // Also save a French alias that should not be left alone, even though // it is the newer alias. @@ -64,7 +69,7 @@ function testLanguageAliases() { // Add an alias with the soon-to-be generated alias, causing the upcoming // alias update to generate a unique alias with the '-0' suffix. - $this->saveAlias('/node/invalid', '/content/english-node', Language::LANGCODE_NOT_SPECIFIED); + $this->createPathAlias('/node/invalid', '/content/english-node', Language::LANGCODE_NOT_SPECIFIED); // Update the node, triggering a change in the English alias. $node->path->pathauto = PathautoState::CREATE; @@ -73,7 +78,7 @@ function testLanguageAliases() { // Check that the new English alias replaced the old one. $this->assertEntityAlias($node, '/content/english-node-0', 'en'); $this->assertEntityAlias($node, '/french-node', 'fr'); - $this->assertAliasExists(['pid' => $english_alias['pid'], 'alias' => '/content/english-node-0']); + $this->assertAliasExists(['id' => $english_alias->id(), 'alias' => '/content/english-node-0']); // Create a new node with the same title as before but without // specifying a language. @@ -87,7 +92,7 @@ function testLanguageAliases() { /** * Test that patterns work on multilingual content. */ - function testLanguagePatterns() { + public function testLanguagePatterns() { // Allow other modules to add additional permissions for the admin user. $permissions = [ diff --git a/web/modules/pathauto/tests/src/FunctionalJavascript/PathautoUiTest.php b/web/modules/pathauto/tests/src/FunctionalJavascript/PathautoUiTest.php index 2d5c3168efc77e8cf2386df769e668ee399a88bd..ada2731f75c2b0d7db27b906850c4aa402368000 100644 --- a/web/modules/pathauto/tests/src/FunctionalJavascript/PathautoUiTest.php +++ b/web/modules/pathauto/tests/src/FunctionalJavascript/PathautoUiTest.php @@ -16,6 +16,11 @@ class PathautoUiTest extends WebDriverTestBase { use PathautoTestHelperTrait; + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'stable'; + /** * Modules to enable. * @@ -33,7 +38,7 @@ class PathautoUiTest extends WebDriverTestBase { /** * {@inheritdoc} */ - function setUp() { + protected function setUp() { parent::setUp(); $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']); @@ -52,7 +57,7 @@ function setUp() { $this->drupalLogin($this->adminUser); } - function testSettingsValidation() { + public function testSettingsValidation() { $this->drupalGet('/admin/config/search/path/settings'); $this->assertSession()->fieldExists('max_length'); @@ -62,16 +67,16 @@ function testSettingsValidation() { $this->assertSession()->elementAttributeContains('css', '#edit-max-component-length', 'min', '1'); } - function testPatternsWorkflow() { - $this->drupalPlaceBlock('local_tasks_block'); + public function testPatternsWorkflow() { + $this->drupalPlaceBlock('local_tasks_block', ['id' => 'local-tasks-block']); $this->drupalPlaceBlock('local_actions_block'); $this->drupalPlaceBlock('page_title_block'); $this->drupalGet('admin/config/search/path'); - $this->assertSession()->elementContains('css', '.block-local-tasks-block', 'Patterns'); - $this->assertSession()->elementContains('css', '.block-local-tasks-block', 'Settings'); - $this->assertSession()->elementContains('css', '.block-local-tasks-block', 'Bulk generate'); - $this->assertSession()->elementContains('css', '.block-local-tasks-block', 'Delete aliases'); + $this->assertSession()->elementContains('css', '#block-local-tasks-block', 'Patterns'); + $this->assertSession()->elementContains('css', '#block-local-tasks-block', 'Settings'); + $this->assertSession()->elementContains('css', '#block-local-tasks-block', 'Bulk generate'); + $this->assertSession()->elementContains('css', '#block-local-tasks-block', 'Delete aliases'); $this->drupalGet('admin/config/search/path/patterns'); $this->clickLink('Add Pathauto pattern'); @@ -194,7 +199,7 @@ function testPatternsWorkflow() { $this->drupalPostForm(NULL, [], t('Delete')); $this->assertSession()->pageTextContains('The pathauto pattern Test has been deleted.'); - $this->assertFalse(PathautoPattern::load('page_pattern')); + $this->assertEmpty(PathautoPattern::load('page_pattern')); } } diff --git a/web/modules/pathauto/tests/src/Kernel/PathautoEntityWithStringIdTest.php b/web/modules/pathauto/tests/src/Kernel/PathautoEntityWithStringIdTest.php index a08006550c8067eec3c98ff45c6340633c8afbe7..0bced80d8bf9391d70d341aa2f2a94a602237d05 100644 --- a/web/modules/pathauto/tests/src/Kernel/PathautoEntityWithStringIdTest.php +++ b/web/modules/pathauto/tests/src/Kernel/PathautoEntityWithStringIdTest.php @@ -36,6 +36,7 @@ class PathautoEntityWithStringIdTest extends KernelTestBase { 'field', 'token', 'path', + 'path_alias', 'pathauto', 'pathauto_string_id_test', ]; diff --git a/web/modules/pathauto/tests/src/Kernel/PathautoKernelTest.php b/web/modules/pathauto/tests/src/Kernel/PathautoKernelTest.php index 29ca4f236627aa92767b8cf9b0794d559e5c387c..49d4182f5545d07fcba4799aeb2cbaf5933807fe 100644 --- a/web/modules/pathauto/tests/src/Kernel/PathautoKernelTest.php +++ b/web/modules/pathauto/tests/src/Kernel/PathautoKernelTest.php @@ -27,7 +27,7 @@ class PathautoKernelTest extends KernelTestBase { use PathautoTestHelperTrait; - public static $modules = ['system', 'field', 'text', 'user', 'node', 'path', 'pathauto', 'taxonomy', 'token', 'filter', 'ctools', 'language']; + public static $modules = ['system', 'field', 'text', 'user', 'node', 'path', 'path_alias', 'pathauto', 'pathauto_custom_punctuation_test', 'taxonomy', 'token', 'filter', 'ctools', 'language']; protected $currentUser; @@ -44,7 +44,6 @@ class PathautoKernelTest extends KernelTestBase { public function setUp() { parent::setup(); - $this->installEntitySchema('user'); $this->installEntitySchema('node'); $this->installEntitySchema('taxonomy_term'); @@ -193,6 +192,11 @@ public function testCleanString() { // Test with default settings defined in pathauto.settings.yml. $this->installConfig(['pathauto']); + + // Add a custom setting for the copyright symbol defined in + // pathauto_custom_punctuation_test_pathauto_punctuation_chars_alter(). + $this->config('pathauto.settings')->set('punctuation.copyright', PathautoGeneratorInterface::PUNCTUATION_REMOVE); + \Drupal::service('pathauto.generator')->resetCaches(); $tests = []; @@ -216,6 +220,9 @@ public function testCleanString() { // Transliteration. $tests['ľščťžýáíéňô'] = 'lsctzyaieno'; + // Transliteration of special chars that are converted to punctuation. + $tests['© “Drupal”'] = 'drupal'; + foreach ($tests as $input => $expected) { $output = \Drupal::service('pathauto.alias_cleaner')->cleanString($input); $this->assertEquals($expected, $output, t("Drupal::service('pathauto.alias_cleaner')->cleanString('@input') expected '@expected', actual '@output'", [ @@ -251,18 +258,18 @@ public function testCleanAlias() { * Test pathauto_path_delete_multiple(). */ public function testPathDeleteMultiple() { - $this->saveAlias('/node/1', '/node-1-alias'); - $this->saveAlias('/node/1/view', '/node-1-alias/view'); - $this->saveAlias('/node/1', '/node-1-alias-en', 'en'); - $this->saveAlias('/node/1', '/node-1-alias-fr', 'fr'); - $this->saveAlias('/node/2', '/node-2-alias'); - $this->saveAlias('/node/10', '/node-10-alias'); + $this->createPathAlias('/node/1', '/node-1-alias'); + $this->createPathAlias('/node/1/view', '/node-1-alias/view'); + $this->createPathAlias('/node/1', '/node-1-alias-en', 'en'); + $this->createPathAlias('/node/1', '/node-1-alias-fr', 'fr'); + $this->createPathAlias('/node/2', '/node-2-alias'); + $this->createPathAlias('/node/10', '/node-10-alias'); \Drupal::service('pathauto.alias_storage_helper')->deleteBySourcePrefix('/node/1'); - $this->assertNoAliasExists(['source' => "/node/1"]); - $this->assertNoAliasExists(['source' => "/node/1/view"]); - $this->assertAliasExists(['source' => "/node/2"]); - $this->assertAliasExists(['source' => "/node/10"]); + $this->assertNoAliasExists(['path' => "/node/1"]); + $this->assertNoAliasExists(['path' => "/node/1/view"]); + $this->assertAliasExists(['path' => "/node/2"]); + $this->assertAliasExists(['path' => "/node/10"]); } /** @@ -293,7 +300,7 @@ public function testUpdateActions() { $node->setTitle('Third title'); $node->save(); $this->assertEntityAlias($node, '/content/third-title'); - $this->assertAliasExists(['source' => '/' . $node->toUrl()->getInternalPath(), 'alias' => '/content/second-title']); + $this->assertAliasExists(['path' => '/' . $node->toUrl()->getInternalPath(), 'alias' => '/content/second-title']); $config->set('update_action', PathautoGeneratorInterface::UPDATE_ACTION_DELETE); $config->save(); @@ -302,8 +309,8 @@ public function testUpdateActions() { $this->assertEntityAlias($node, '/content/fourth-title'); $this->assertNoAliasExists(['alias' => '/content/third-title']); // The older second alias is not deleted yet. - $older_path = $this->assertAliasExists(['source' => '/' . $node->toUrl()->getInternalPath(), 'alias' => '/content/second-title']); - \Drupal::service('path.alias_storage')->delete($older_path); + $older_path = $this->assertAliasExists(['path' => '/' . $node->toUrl()->getInternalPath(), 'alias' => '/content/second-title']); + \Drupal::service('entity_type.manager')->getStorage('path_alias')->delete([$older_path]); $config->set('update_action', PathautoGeneratorInterface::UPDATE_ACTION_NO_NEW); $config->save(); @@ -364,7 +371,7 @@ public function testPathTokens() { /** * Test using fields for path structures. */ - function testParentChildPathTokens() { + public function testParentChildPathTokens() { // First create a field which will be used to create the path. It must // begin with a letter. $this->installEntitySchema('taxonomy_term'); @@ -377,7 +384,7 @@ function testParentChildPathTokens() { $field = FieldConfig::create(['field_storage' => $field_storage, 'bundle' => 'tags']); $field->save(); - $display = entity_get_display('taxonomy_term', 'tags', 'default'); + $display = \Drupal::service('entity_display.repository')->getViewDisplay('taxonomy_term', 'tags'); $display->setComponent($fieldname, ['type' => 'string']); $display->save(); @@ -404,7 +411,7 @@ function testParentChildPathTokens() { */ public function testTaxonomyPattern() { // Create a vocabulary and test that it's pattern variable works. - $vocab = $this->addVocabulary(['vid' => 'name']); + $this->addVocabulary(['vid' => 'name']); $this->createPattern('taxonomy_term', 'base'); $pattern = $this->createPattern('taxonomy_term', 'bundle', -1); $this->addBundleCondition($pattern, 'taxonomy_term', 'name'); @@ -412,7 +419,7 @@ public function testTaxonomyPattern() { $this->assertEntityPattern('taxonomy_term', 'name', Language::LANGCODE_NOT_SPECIFIED, 'bundle'); } - function testNoExistingPathAliases() { + public function testNoExistingPathAliases() { $this->config('pathauto.settings') ->set('punctuation.period', PathautoGeneratorInterface::PUNCTUATION_DO_NOTHING) ->save(); @@ -445,7 +452,7 @@ function testNoExistingPathAliases() { /** * Test programmatic entity creation for aliases. */ - function testProgrammaticEntityCreation() { + public function testProgrammaticEntityCreation() { $node = $this->drupalCreateNode(['title' => 'Test node', 'path' => ['pathauto' => TRUE]]); $this->assertEntityAlias($node, '/content/test-node'); @@ -475,7 +482,7 @@ function testProgrammaticEntityCreation() { /** * Tests word safe alias truncating. */ - function testPathAliasUniquifyWordsafe() { + public function testPathAliasUniquifyWordsafe() { $this->config('pathauto.settings') ->set('max_length', 26) ->save(); @@ -493,7 +500,7 @@ function testPathAliasUniquifyWordsafe() { /** * Test if aliases are (not) generated with enabled/disabled patterns. */ - function testPatternStatus() { + public function testPatternStatus() { // Create a node to get an alias for. $title = 'Pattern enabled'; $alias = '/content/pattern-enabled'; diff --git a/web/modules/pathauto/tests/src/Kernel/PathautoTokenTest.php b/web/modules/pathauto/tests/src/Kernel/PathautoTokenTest.php index 93a5456155631c5a4dfc62e9f0f0f51b74137bbc..95b564a3cfd7119cd0380135019dd16e36d2d58d 100644 --- a/web/modules/pathauto/tests/src/Kernel/PathautoTokenTest.php +++ b/web/modules/pathauto/tests/src/Kernel/PathautoTokenTest.php @@ -17,7 +17,7 @@ class PathautoTokenTest extends KernelTestBase { * * @var array */ - public static $modules = ['system', 'token', 'pathauto']; + public static $modules = ['system', 'token', 'path_alias', 'pathauto']; public function testPathautoTokens() { @@ -97,7 +97,7 @@ public function assertTokens($type, array $data, array $tokens, array $options = $this->assertTrue(preg_match('/^' . $expected . '$/', $replacements[$token]), t("Token value for @token was '@actual', matching regular expression pattern '@expected'.", ['@type' => $type, '@token' => $token, '@actual' => $replacements[$token], '@expected' => $expected])); } else { - $this->assertIdentical($replacements[$token], $expected, t("Token value for @token was '@actual', expected value '@expected'.", ['@type' => $type, '@token' => $token, '@actual' => $replacements[$token], '@expected' => $expected])); + $this->assertSame($expected, $replacements[$token], t("Token value for @token was '@actual', expected value '@expected'.", ['@type' => $type, '@token' => $token, '@actual' => $replacements[$token], '@expected' => $expected])); } }