Healing / recreating relationships
-
Hi WordPressers,
Background:
A WordPress imported lots of posts using RSS agregator (this is not an issue of that plugin). After that, due to lack of maintenance, most of the posts had to be deleted in a bad way (because the server timed out when trying to), querying the database and getting rid of lots of drafts (over 60000).
As part of a scheduled migration, the hosting was changed and none of these files were copied.
Now:
My problem is that awful deletion left behind tons (over 250000) media records that were attached to these drafts. Technically they are still attached because the database migration took the orphaned relationships.
Those media records cannot be quickly deleted because they are not listed within the ‘Unattached’ link.
They are listed as ‘Uploaded to: (Unattached)’.
Problem:
Ideally I’d query an awesome order to mysql to let it do all the hardwork (as it should be!) but I cannot even guess a way to select all the attachments whose related post doesn’t exists. I don’t really understand how the tables relate to themselves.
Why:
I have to clean that because there still are around 900 posts with images. Checking for 404s and taking them one by one from the old hosting is not feasible.
The task is going to be massively easier once all the orphaned images are taken care of.
After that, a simple file_exists() could do the filtering and some cleverly placed str_replace() can retrieve the img’s src from the old hosting (so just drag’n’drop!…)
Sorry for the massive chunk of text! Thanks!
- The topic ‘Healing / recreating relationships’ is closed to new replies.