summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2014-10-04 16:40:06 (GMT)
committerAlex Pott2014-10-04 16:40:06 (GMT)
commit0e17d9783748012d8db7c1e78204fdceb9a7ecbb (patch)
treebf7c814b7157f4f97bc645f2702226449a1dc952
parent8dfea8efdef09032d59dc6368c1f69e7731ff691 (diff)
Issue #1160764 by Désiré, Dave Reid, SebCorbin, agentrickard: Fixed URL alias load is inconsistent if there are more then one aliases.
-rw-r--r--core/lib/Drupal/Core/Path/AliasStorage.php2
-rw-r--r--core/modules/system/src/Tests/Path/AliasTest.php4
2 files changed, 6 insertions, 0 deletions
diff --git a/core/lib/Drupal/Core/Path/AliasStorage.php b/core/lib/Drupal/Core/Path/AliasStorage.php
index 153866b..3922e23 100644
--- a/core/lib/Drupal/Core/Path/AliasStorage.php
+++ b/core/lib/Drupal/Core/Path/AliasStorage.php
@@ -92,6 +92,8 @@ class AliasStorage implements AliasStorageInterface {
}
return $select
->fields('url_alias')
+ ->orderBy('pid', 'DESC')
+ ->range(0, 1)
->execute()
->fetchAssoc();
}
diff --git a/core/modules/system/src/Tests/Path/AliasTest.php b/core/modules/system/src/Tests/Path/AliasTest.php
index d91c59f..f1f6bf2 100644
--- a/core/modules/system/src/Tests/Path/AliasTest.php
+++ b/core/modules/system/src/Tests/Path/AliasTest.php
@@ -50,6 +50,10 @@ class AliasTest extends PathUnitTestBase {
$this->assertEqual($loadedAlias, $alias, format_string('Loaded the expected path with pid %pid.', array('%pid' => $pid)));
}
+ // Load alias by source path.
+ $loadedAlias = $aliasStorage->load(array('source' => 'node/1'));
+ $this->assertEqual($loadedAlias['alias'], 'alias_for_node_1_und', format_string('The last created alias loaded by default.'));
+
//Update a few aliases
foreach ($aliases as $alias) {
$fields = $aliasStorage->save($alias['source'], $alias['alias'] . '_updated', $alias['langcode'], $alias['pid']);