Closed (fixed)
Project:
Pathauto
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
22 Jul 2010 at 02:33 UTC
Updated:
8 Aug 2010 at 03:20 UTC
Jump to comment: Most recent file
D7 doesn't provide an easy way to delete a path based on a wildcard, so we have to write our own small function do it for us.
D7:
/**
* Delete multiple URL aliases based on a wildcard source.
*
* Given a source like 'node/1' this function will delete any alias that have
* that specific source or any sources that match 'node/1/%'.
*
* @param $source
* An string with a source URL path.
*/
function pathauto_path_delete_multiple($source) {
$sql = "SELECT pid FROM {url_alias} WHERE source = :source OR source LIKE :source-wildcard";
$pids = db_query($sql, array(':source' => $source, ':source-wildcard' => $source . '/%'))->fetchCol();
foreach ($pids as $pid) {
path_delete(array('pid' => $pid));
}
}
D6:
function pathauto_path_delete_multiple($source) {
$source = urldecode($source);
// Delete the source path.
db_query("DELETE FROM {url_alias} WHERE src = '%s'", $source);
// Delete any sub-paths.
db_query("DELETE FROM {url_alias} WHERE src LIKE '%s'", $source . '/%%');
drupal_clear_path_cache();
}
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | 861106-pathauto-path-delete-multiple-D7.patch | 3.84 KB | dave reid |
Comments
Comment #1
dave reidComment #2
dave reidCommitted to 7.x and 6.x-2.x.
http://drupal.org/cvs?commit=397322
http://drupal.org/cvs?commit=397324