- Patch #10603 by TDobes: bugfix: URL aliases got lost when deleting revision.
parent
770f4f8a59
commit
c4403eed12
|
@ -196,27 +196,14 @@ function path_form($edit = '') {
|
||||||
*/
|
*/
|
||||||
function path_nodeapi(&$node, $op, $arg) {
|
function path_nodeapi(&$node, $op, $arg) {
|
||||||
if (user_access('create url aliases') || user_access('administer url aliases')) {
|
if (user_access('create url aliases') || user_access('administer url aliases')) {
|
||||||
|
|
||||||
switch ($op) {
|
switch ($op) {
|
||||||
case 'validate':
|
case 'validate':
|
||||||
// is_null provides a mechanism for us to determine if this is the first
|
$node->path = trim($node->path);
|
||||||
// viewing of the form. If it is the first time, load the alias, if it isn't
|
if ($node->path && !valid_url($node->path)) {
|
||||||
// (i.e., user has clicked preview) let them work with their current form alias.
|
form_set_error('path', t('The path is invalid.'));
|
||||||
if (is_null($node->path)) {
|
|
||||||
$path = "node/$node->nid";
|
|
||||||
$alias = drupal_get_path_alias($path);
|
|
||||||
if ($alias != $path) {
|
|
||||||
$node->path = $alias;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else if (db_result(db_query("SELECT COUNT(dst) FROM {url_alias} WHERE dst = '%s' AND src != '%s'", $node->path, "node/$node->nid"))) {
|
||||||
$node->path = trim($node->path);
|
form_set_error('path', t('The path is already in use.'));
|
||||||
if ($node->path && !valid_url($node->path)) {
|
|
||||||
form_set_error('path', t('The path is invalid.'));
|
|
||||||
}
|
|
||||||
else if (db_result(db_query("SELECT COUNT(dst) FROM {url_alias} WHERE dst = '%s' AND src != '%s'", $node->path, "node/$node->nid"))) {
|
|
||||||
form_set_error('path', t('The path is already in use.'));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -227,6 +214,14 @@ function path_nodeapi(&$node, $op, $arg) {
|
||||||
}
|
}
|
||||||
return $output;
|
return $output;
|
||||||
|
|
||||||
|
case 'load':
|
||||||
|
$path = "node/$node->nid";
|
||||||
|
$alias = drupal_get_path_alias($path);
|
||||||
|
if ($alias != $path) {
|
||||||
|
$node->path = $alias;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 'insert':
|
case 'insert':
|
||||||
// Don't try to insert if path is NULL. We may have already set
|
// Don't try to insert if path is NULL. We may have already set
|
||||||
// the alias ahead of time.
|
// the alias ahead of time.
|
||||||
|
@ -234,6 +229,7 @@ function path_nodeapi(&$node, $op, $arg) {
|
||||||
path_set_alias("node/$node->nid", $node->path);
|
path_set_alias("node/$node->nid", $node->path);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'update':
|
case 'update':
|
||||||
path_set_alias("node/$node->nid", $node->path, $node->pid);
|
path_set_alias("node/$node->nid", $node->path, $node->pid);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -196,27 +196,14 @@ function path_form($edit = '') {
|
||||||
*/
|
*/
|
||||||
function path_nodeapi(&$node, $op, $arg) {
|
function path_nodeapi(&$node, $op, $arg) {
|
||||||
if (user_access('create url aliases') || user_access('administer url aliases')) {
|
if (user_access('create url aliases') || user_access('administer url aliases')) {
|
||||||
|
|
||||||
switch ($op) {
|
switch ($op) {
|
||||||
case 'validate':
|
case 'validate':
|
||||||
// is_null provides a mechanism for us to determine if this is the first
|
$node->path = trim($node->path);
|
||||||
// viewing of the form. If it is the first time, load the alias, if it isn't
|
if ($node->path && !valid_url($node->path)) {
|
||||||
// (i.e., user has clicked preview) let them work with their current form alias.
|
form_set_error('path', t('The path is invalid.'));
|
||||||
if (is_null($node->path)) {
|
|
||||||
$path = "node/$node->nid";
|
|
||||||
$alias = drupal_get_path_alias($path);
|
|
||||||
if ($alias != $path) {
|
|
||||||
$node->path = $alias;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else if (db_result(db_query("SELECT COUNT(dst) FROM {url_alias} WHERE dst = '%s' AND src != '%s'", $node->path, "node/$node->nid"))) {
|
||||||
$node->path = trim($node->path);
|
form_set_error('path', t('The path is already in use.'));
|
||||||
if ($node->path && !valid_url($node->path)) {
|
|
||||||
form_set_error('path', t('The path is invalid.'));
|
|
||||||
}
|
|
||||||
else if (db_result(db_query("SELECT COUNT(dst) FROM {url_alias} WHERE dst = '%s' AND src != '%s'", $node->path, "node/$node->nid"))) {
|
|
||||||
form_set_error('path', t('The path is already in use.'));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -227,6 +214,14 @@ function path_nodeapi(&$node, $op, $arg) {
|
||||||
}
|
}
|
||||||
return $output;
|
return $output;
|
||||||
|
|
||||||
|
case 'load':
|
||||||
|
$path = "node/$node->nid";
|
||||||
|
$alias = drupal_get_path_alias($path);
|
||||||
|
if ($alias != $path) {
|
||||||
|
$node->path = $alias;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 'insert':
|
case 'insert':
|
||||||
// Don't try to insert if path is NULL. We may have already set
|
// Don't try to insert if path is NULL. We may have already set
|
||||||
// the alias ahead of time.
|
// the alias ahead of time.
|
||||||
|
@ -234,6 +229,7 @@ function path_nodeapi(&$node, $op, $arg) {
|
||||||
path_set_alias("node/$node->nid", $node->path);
|
path_set_alias("node/$node->nid", $node->path);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'update':
|
case 'update':
|
||||||
path_set_alias("node/$node->nid", $node->path, $node->pid);
|
path_set_alias("node/$node->nid", $node->path, $node->pid);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue