Last active
November 9, 2018 23:51
-
-
Save sbreker/8f8a5c75b65e69b18eb0d44794585308 to your computer and use it in GitHub Desktop.
Delete Authority records not linked to an Information Object via the events table. This will preserve actors if they are a creator or other actor linked via the events table. This script will ALSO permanently delete authority records that may be linked to descriptions via the relations table as "Name access points".
This file contains 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 | |
// VERSION: 0.10 | |
// Delete actors that are not users or repos and: | |
// - are not linked via the events table - e.g. not a creator | |
// | |
// This script can be used to DELETE authority records. | |
// | |
// It will output a list of slugs that the script | |
// will delete. This is great for testing! The slug can be | |
// appended to your base URL to look at the Actor in question. e.g. | |
// http://10.10.10.10/rjpx-mzwk-pwls where the slug is rjpx-mzwk-pwls | |
// | |
// *WARNING - SCRIPT WILL DELETE DATA FROM ATOM* *MAKE BACKUPS FIRST!* | |
// | |
// Command: php symfony tools:run <full_path_to_this_file> | |
$verbose = True; | |
$actors = QubitActor::getOnlyActors(); | |
foreach ($actors as $actor) | |
{ | |
if ($actor->id == QubitActor::ROOT_ID) | |
{ | |
continue; | |
} | |
$eventRelations = $actor->getResourceRelations(); | |
if (count($eventRelations) == 0) | |
{ | |
print("--------------\n"); | |
print("CAN DELETE: " . $actor->slug."\n"); | |
print("Events linked: " . count($eventRelations)."\n"); | |
foreach (QubitRelation::getBySubjectOrObjectId($actor->id) as $relation) | |
{ | |
//$relation->delete(); | |
} | |
//$actor->delete(); | |
} | |
if ((count($eventRelations) > 0) && $verbose) | |
{ | |
print("--------------\n"); | |
print("KEEP: " . $actor->slug."\n"); | |
print("Events linked: " . count($eventRelations)."\n"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment