Commit 3c3c556c authored by Dries's avatar Dries
Browse files

- Bugfix: pass the node by reference in path_nodeapi so that $node->path is set
  for the node.  Fixes bug #3680.  Patch by Matt.

- Bugfix: when creating a new node, don't try to insert a path if it wasn't set
  in the node form.  This destroys any paths which the user may have created
  ahead of time for that node.  Patch by Matt.
parent 88084288
......@@ -137,7 +137,7 @@ function path_link($type, $node = NULL) {
}
}
function path_nodeapi($node, $op, $arg) {
function path_nodeapi(&$node, $op, $arg) {
if (user_access("create url aliases") || user_access("administer url aliases")) {
switch ($op) {
......@@ -165,6 +165,14 @@ function path_nodeapi($node, $op, $arg) {
return form_textfield(t("Path alias"), "path", $node->path, 60, 250, t("Optionally specify an alternative URL by which this node can be accessed. For example, type 'about' when writing an about page. Use a relative path and don't add a trailing slash or the URL alias won't work.") . theme_error($arg["path"]));
case "insert":
/*
** Don't try to insert if path is NULL. We may have already set
** the alias ahead of time.
*/
if ($node->path) {
path_set_alias("node/view/$node->nid", $node->path);
}
break;
case "update":
path_set_alias("node/view/$node->nid", $node->path);
break;
......
......@@ -137,7 +137,7 @@ function path_link($type, $node = NULL) {
}
}
function path_nodeapi($node, $op, $arg) {
function path_nodeapi(&$node, $op, $arg) {
if (user_access("create url aliases") || user_access("administer url aliases")) {
switch ($op) {
......@@ -165,6 +165,14 @@ function path_nodeapi($node, $op, $arg) {
return form_textfield(t("Path alias"), "path", $node->path, 60, 250, t("Optionally specify an alternative URL by which this node can be accessed. For example, type 'about' when writing an about page. Use a relative path and don't add a trailing slash or the URL alias won't work.") . theme_error($arg["path"]));
case "insert":
/*
** Don't try to insert if path is NULL. We may have already set
** the alias ahead of time.
*/
if ($node->path) {
path_set_alias("node/view/$node->nid", $node->path);
}
break;
case "update":
path_set_alias("node/view/$node->nid", $node->path);
break;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment