Page MenuHomePhabricator

File page not purged after deletion
Open, Needs TriagePublic


Filepage not purged after deletion (for a random example see file)

(File has been deleted at 00:17, 3 July 2015 but hours later not purged!)

Event Timeline

Steinsplitter raised the priority of this task from to Needs Triage.
Steinsplitter updated the task description. (Show Details)
Steinsplitter added a project: MediaWiki-Cache.
Steinsplitter added a subscriber: Steinsplitter.
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJul 3 2015, 4:40 PM
Steinsplitter set Security to None.
Steinsplitter moved this task from Incoming to Backlog on the Commons board.
Luke081515 added a subscriber: Luke081515.
Aklapper renamed this task from Purging file page after deletion to File page not purged after deletion.Jul 16 2015, 2:21 PM
Restricted Application added a subscriber: StudiesWorld. · View Herald TranscriptNov 15 2015, 2:25 PM

I have the same problem. We use redis as the main cache. MediaWiki 1.29

Several images were deleted normally by the web interface. However, one of them is stuck: The file is deleted (it's not on the public folder anymore) and it's not on the database neither (image table). However, viewing the file description page displays the image, the deletion log and the file revision log. Purging the page does not work.

(image is displayed because I have a CDN with long TTL)

I can even delete it again (although there's no delete button, I can access action=delete and perform the deletion again without errors):

Doing an imageinfo query api I get

    "batchcomplete": "",
    "query": {
        "pages": {
            "-1": {
                "ns": 6,
                "title": "Archivo:Al ataque fase 1 XY.png",
                "missing": "",
                "known": "",
                "imagerepository": "",
                "contentmodel": "wikitext",
                "pagelanguage": "es",
                "pagelanguagehtmlcode": "es",
                "pagelanguagedir": "ltr"

Nothing in DB

MariaDB [wikidexwiki]> select * from image where img_name = 'Al_ataque_fase_1_XY.png';
Empty set (0.00 sec)

I've found that the image info is on the cache, so for MediaWiki, when reading from the cache, the file is known:

$ sudo -u php-fpm-wikidex php /home/www/
> $t = Title::newFromText('Archivo:Al ataque fase 1 XY.png');

> $r = RepoGroup::singleton()->getLocalRepo();

> $f = LocalFile::newFromTitle($t, $r);

> $f->load( File::READ_LATEST );

> echo $f->exists();

> $f = LocalFile::newFromTitle($t, $r);

> $f->load( 0 );

> echo $f->exists();
> echo $f->getCacheKey();

Deleting the file again (as I said) doesn't remove it from the cache. action=purge doesn't neither. I think both actions should try to remove it from the cache, so it can be purged from the web interface.

I can't see anything related in the error and exception logs from the deletion time. Not sure why it wasn't purged the first time. Maybe a race condition somewhere.

I've tried also to $f->invalidateCache(); (from eval.php) but it didn't remove it from the cache neither. I had to execute $r->getMasterDB()->commit(); for it to be removed, because I found LocalFile::invalidateCache purges it only on transaction commit.

	 * Purge the file object/metadata cache
	public function invalidateCache() {
		$key = $this->getCacheKey();
		if ( !$key ) {

			function () use ( $key ) {
				ObjectCache::getMainWANInstance()->delete( $key );

Maybe the bug was related to this, transaction was never commited, or who knows...