Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save krystianbuczak/c3914611a4fa1afdd5c9a7cd41c98380 to your computer and use it in GitHub Desktop.
Save krystianbuczak/c3914611a4fa1afdd5c9a7cd41c98380 to your computer and use it in GitHub Desktop.
Simple Drupal 7 script that removes aliases with empty source.
// Use this simple script in empty aliases sitaution, when you have many rows
// in "url_alias" table with "source" column being empty.
$query = db_select('url_alias', 'ua')->fields('ua');
$query->condition('ua.source', '', '=');
//$query->range(0, 500); // uncomment if plan to do this job in smaller chunks
$paths = $query->execute()->fetchAll();
foreach($paths as $object) {
if (is_numeric($object->pid)) {
path_delete($object->pid);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment