Skip to content

Instantly share code, notes, and snippets.

@alex-moreno
Last active December 20, 2015 22:39
Show Gist options
  • Save alex-moreno/6206684 to your computer and use it in GitHub Desktop.
Save alex-moreno/6206684 to your computer and use it in GitHub Desktop.
way of deleting thousands of spam messages with a single commando and without overloading the server, timeout problems, etc... Way of executing: drush -u admin php-script sites/all/scripts/delete-spammernodes.php > drush-deletespammer.log --uri=[YOUR-DOMAIN] Do not forget the backup: drush --uri=URI sql-dump > /DIRECTORY/yourbackup.sql change no…
<?php
drush_print( 'Deleting nodes created by user');
// Select nodes from offending user
$result = db_query("SELECT * FROM node WHERE node.uid=27216 AND node.type='group_node' LIMIT 0,50000");
$number_deleted = 0;
while( $row = db_fetch_array( $result ) ) {
echo "\n\n node :: " ;
echo "\n " . $row['title'];
echo "\n nid: " . $row['nid'];
echo "\n uid: " . $row['uid'];
echo "\n index so far: " . $number_deleted;
node_delete($row['nid']);
$number_deleted = $number_deleted + 1;
}
echo "\n\n Elements deleted: " . $number_deleted . "\n\n";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment