Last active
November 15, 2016 21:39
-
-
Save fiver-watson/929e6c3380bedd32f3a77d21403c80de to your computer and use it in GitHub Desktop.
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…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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