Deleting a file from a wiki AFTER moving to commons: pages on the wiki linking to the file can have broken links until the page is purged
For example, after moving FiveThirtyEight_Logo.svg from enwiki to commons, a page with a link to the file had a broken image link
... until the page was purged and then the image showed fine
The above can be reproduced on a local vagrant instance of mediawiki as follows
- Enable and provision 'commons' role
- Download a file from commons, upload it to local
- Disable 'commons' role
- Link to the file via [[File:filename|thumb]] on Page_X
- Verify that the File page has links to commons and to Page_X
- Delete the File page
- Reload Page_X
- Observe that it has a broken link to the file, unless the page is purged (and then it'll link to the file on commons)
The reason for the broken link is that pages containing backlinks are not being purged automatically when a file is deleted, and the reason in turn for that is
- when the file is uploaded in the first place its set of backlinks (obvs an empty set) are cached in memcache
- when the file is deleted it reads the backlinks that need to be purged from memcache, and that set is empty, so Page_X does not get purged
So any backlink missing from the backlink cache at the time of deletion of the file will NOT be purged when the file is deleted, which may be the root cause of this bug on production
The obvious solution would be to clear the backlink cache on file deletion, but BacklinkCache has been implemented in such a way as to make this difficult - code that calls BacklinkCache methods passes string data that is used to construct cache keys, and so it's impossible to clear the cache effectively without knowledge of the code that made the calls to populate the cache.
The problem could be mitigated by lowering the ttl on the memcache storage, but a better solution would be to re-engineer BacklinkCache so that it's easy to cleanly clear the cache for a title