summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorwebchick <webchick@24967.no-reply.drupal.org>2012-02-28 23:53:31 -0800
committerwebchick <webchick@24967.no-reply.drupal.org>2012-02-28 23:53:31 -0800
commita11889c035b4e7b10af70caf2cba9fcc9201f9e1 (patch)
treef844fe9cada0d661cd9e7ac98b2cf26933502f10 /includes
parent300a007c71b79692f5a48caeeba690b1eb3cefab (diff)
downloadbrdo-a11889c035b4e7b10af70caf2cba9fcc9201f9e1.tar.gz
brdo-a11889c035b4e7b10af70caf2cba9fcc9201f9e1.tar.bz2
Issue #998256 by justafish, Albert Volkman, Dave Reid, no_commit_credit: Please let modules know about the original URL alias in hook_path_update().
Diffstat (limited to 'includes')
-rw-r--r--includes/path.inc30
1 files changed, 18 insertions, 12 deletions
diff --git a/includes/path.inc b/includes/path.inc
index ed5b639fb..411a7a71c 100644
--- a/includes/path.inc
+++ b/includes/path.inc
@@ -431,21 +431,27 @@ function path_load($conditions) {
* - language: (optional) The language of the alias.
*/
function path_save(&$path) {
- $path += array('pid' => NULL, 'language' => LANGUAGE_NONE);
+ $path += array('language' => LANGUAGE_NONE);
- // Insert or update the alias.
- $status = drupal_write_record('url_alias', $path, (!empty($path['pid']) ? 'pid' : array()));
+ // Load the stored alias, if any.
+ if (!empty($path['pid']) && !isset($path['original'])) {
+ $path['original'] = path_load($path['pid']);
+ }
- // Verify that a record was written.
- if ($status) {
- if ($status === SAVED_NEW) {
- module_invoke_all('path_insert', $path);
- }
- else {
- module_invoke_all('path_update', $path);
- }
- drupal_clear_path_cache($path['source']);
+ if (empty($path['pid'])) {
+ drupal_write_record('url_alias', $path);
+ module_invoke_all('path_insert', $path);
+ }
+ else {
+ drupal_write_record('url_alias', $path, array('pid'));
+ module_invoke_all('path_update', $path);
}
+
+ // Clear internal properties.
+ unset($path['original']);
+
+ // Clear the static alias cache.
+ drupal_clear_path_cache($path['source']);
}
/**