Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This script can be used by Access to Memory (AtoM) users who have encountered bug #10276 (https://projects.artefactual.com/issues/10276), and have accidentally created slugs (permalinks) for users or other entities with periods in them - these slugs will fail, rendering the record inaccessible. This script can be run from AtoM's root directory u…
<?php
print "Fixing invalid slugs...\n";
// add separator characters you want to convert FROM (DO NOT ADD A BACKSLASH HERE)
$separators = array('.', '/');
// change all instances of 'separator' to dash '-'.
foreach ($separators as $separator)
{
print 'Updating where slug contains: ' . $separator . "\n";
$r = QubitPdo::prepareAndExecute('UPDATE slug SET slug = REPLACE(slug, "' . $separator . '", "-") WHERE slug LIKE "%' . $separator . '%"');
$counter += $r->rowCount();
}
print 'Done. Fixed '.$counter." slugs.\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.