diff --git a/pathauto.module b/pathauto.module index dffc29282e..2f5550502e 100644 --- a/pathauto.module +++ b/pathauto.module @@ -511,26 +511,35 @@ function pathauto_node_operations() { * @param $node * A node object. * @param $op - * Operation being performed on the node ('insert', 'update' or 'bulkupdate'). + * Operation being performed on the node ('insert', 'update', 'return', or 'bulkupdate'). * @param $options * An optional array of additional options. + * + * @return mixed + * Depends on $op: + * - insert, update, or bulkupdate: + * The path alias array that was created, otherwise NULL, or sometimes an + * empty string. + * - return: + * The string path for the given node, otherwise NULL, or sometimes an empty + * string. */ function pathauto_node_update_alias(stdClass $node, $op, array $options = array()) { // Skip processing if the user has disabled pathauto for the node. if (isset($node->path['pathauto']) && empty($node->path['pathauto'])) { - return; + return ''; } $options += array('language' => pathauto_entity_language('node', $node)); // Skip processing if the node has no pattern. if (!pathauto_pattern_load_by_entity('node', $node->type, $options['language'])) { - return; + return ''; } module_load_include('inc', 'pathauto'); $uri = entity_uri('node', $node); - pathauto_create_alias('node', $op, $uri['path'], array('node' => $node), $node->type, $options['language']); + return pathauto_create_alias('node', $op, $uri['path'], array('node' => $node), $node->type, $options['language']); } /** @@ -539,22 +548,34 @@ function pathauto_node_update_alias(stdClass $node, $op, array $options = array( * @param $nids * An array of node IDs. * @param $op - * Operation being performed on the nodes ('insert', 'update' or + * Operation being performed on the nodes ('insert', 'update', 'return' or * 'bulkupdate'). * @param $options * An optional array of additional options. + * + * @return array() + * An associative array with keys for the given node IDs. The values vary + * depending on $op: + * - insert, update, or bulkupdate: + * The path alias array that was created, otherwise NULL, or sometimes an + * empty string. + * - return: + * The string path for the given node, otherwise NULL, or sometimes an empty + * string. */ function pathauto_node_update_alias_multiple(array $nids, $op, array $options = array()) { $options += array('message' => FALSE); + $results = []; $nodes = node_load_multiple($nids); foreach ($nodes as $node) { - pathauto_node_update_alias($node, $op, $options); + $results[$node->nid] = pathauto_node_update_alias($node, $op, $options); } if (!empty($options['message'])) { drupal_set_message(format_plural(count($nids), 'Updated URL alias for 1 node.', 'Updated URL aliases for @count nodes.')); } + return $results; } /**