diff -u b/src/AliasUniquifier.php b/src/AliasUniquifier.php --- b/src/AliasUniquifier.php +++ b/src/AliasUniquifier.php @@ -64,7 +64,7 @@ * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler. * @param \Drupal\Core\Routing\RouteProviderInterface $route_provider - * The url matcher service. + * The route provider service. */ public function __construct(ConfigFactoryInterface $config_factory, AliasStorageHelperInterface $alias_storage_helper, ModuleHandlerInterface $module_handler, RouteProviderInterface $route_provider, AliasManagerInterface $alias_manager) { $this->configFactory = $config_factory; @@ -107,7 +107,6 @@ if ($existing_source != $alias) { // If it is an alias for the provided source, it is allowed to keep using // it. If not, then it is reserved. - $this->lastRouteName = NULL; return $existing_source != $source; } only in patch2: unchanged: --- a/src/Tests/PathautoNodeWebTest.php +++ b/src/Tests/PathautoNodeWebTest.php @@ -6,6 +6,7 @@ */ namespace Drupal\pathauto\Tests; +use Drupal\language\Entity\ConfigurableLanguage; use Drupal\pathauto\Entity\PathautoPattern; use Drupal\node\Entity\Node; use Drupal\pathauto\PathautoState; @@ -25,7 +26,7 @@ class PathautoNodeWebTest extends WebTestBase { * * @var array */ - public static $modules = array('node', 'pathauto', 'views', 'taxonomy', 'pathauto_views_test'); + public static $modules = array('node', 'locale', 'pathauto', 'views', 'taxonomy', 'pathauto_views_test'); /** * Admin user. @@ -146,6 +147,38 @@ class PathautoNodeWebTest extends WebTestBase { } /** + * Tests that nodes with the same title but different languages are properly + * handled. + */ + public function testNodeDifferentLanguages() { + $this->drupalLogin($this->rootUser); + + // Create a title-based node pattern. + $this->createPattern('node', '/prefix/[node:title]', -1); + + // Add predefined French language. + ConfigurableLanguage::createFromLangcode('fr')->save(); + + // Create two English articles with the same title. + $edit = [ + 'title' => 'Sample article', + 'type' => 'article', + 'langcode' => 'en', + ]; + $node1 = $this->drupalCreateNode($edit); + $this->assertEntityAlias($node1, '/prefix/sample-article', 'en'); + + $node2 = $this->drupalCreateNode($edit); + $this->assertEntityAlias($node2, '/prefix/sample-article-0', 'en'); + + // Now, create a French article with the same title, and verify that it gets + // the basic alias with the correct langcode. + $edit['langcode'] = 'fr'; + $node3 = $this->drupalCreateNode($edit); + $this->assertEntityAlias($node3, '/prefix/sample-article', 'fr'); + } + + /** * Test node operations. */ function testNodeOperations() { @@ -285,28 +318,4 @@ class PathautoNodeWebTest extends WebTestBase { $this->assertResponse(200); } - /** - * Tests that patterns can coexist with routes with arguments. - * - * A common case is to have a view with a term name as a contextual filter, - * and a pattern that matches the view's path. - */ - public function testPatternMatchingDynamicRoute() { - $this->drupalLogin($this->rootUser); - - // Create a pattern for nodes that matches with a view path defined at - // pathauto_views_test module. - $this->createPattern('node', '/articles/[node:title]', -1); - - // Create an article. - $edit = array( - 'title[0][value]' => 'Sample article', - ); - $this->drupalPostForm('node/add/article', $edit, t('Save and publish')); - - // Check that the alias was not created and an alert was shown. - $this->assertText('collides with the route with identifier'); - $this->assertNoAliasExists(array('alias' => '/articles/sample-article')); - } - }