Page MenuHomePhabricator

Maintenance script checkImages.php called with a wrong parameter; does not work
Closed, ResolvedPublic

Description

The maintenance script checkImages.php currently only reports, that files would be missing:

test.pdf: missing

This output is repeated for every file; the statistic at the end finally says:

However, this is wrong: The problem is that in checkImages.php around line 57 stat is called with a wrong parameter.

This is the code, comments by me:
$path = $file->getPath();

$path is set to an internal path identifier, e.g. mwstore://local-backend/local-public/8/85/test.pdf

if ( !$path ) {

  1. does not happen as path is set

$this->output( "{$row->img_name}: not locally accessible\n" );
continue;
}
$stat = stat( $file->getPath() );

stat returns FALSE meaning: error. Reason is that it did not get an actual file path, but this internal identifier: stat(mwstore://local-backend/local-public/8/85/test.pdf);

if ( !$stat ) {
$this->output( "{$row->img_name}: missing\n" );

stat() however SHOULD be called with the real path to the file. That should fix the problem...


Version: 1.22.3
Severity: normal

Details

Reference
bz62148
Related Changes in Gerrit:

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 2:52 AM
bzimport set Reference to bz62148.
bzimport added a subscriber: Unknown Object (MLST).

I have checked the methods of includes/filerepo/file/File.php. Changing the line

$stat = stat( $file->getPath() );

to

$stat = stat( $file->getLocalRefPath() );

Makes the script provide the correct results again.

Thanks for taking the time to report this and your analysis!

In case you would like to turn the fix into a patch, you are welcome to use Developer access at https://www.mediawiki.org/wiki/Developer_access
to submit this as a Git branch directly into Gerrit:

https://www.mediawiki.org/wiki/Git/Tutorial

If you don't want to set up Git/Gerrit, you can also use https://tools.wmflabs.org/gerrit-patch-uploader/

Change 117027 had a related patch set uploaded by AalekhN:
Correct parameter passed checkImages.php

https://gerrit.wikimedia.org/r/117027

Thanks for putting the patch into Gerrit!

It looks good.

Change 204814 had a related patch set uploaded (by Aaron Schulz):
Fixed stat calls in checkImages

https://gerrit.wikimedia.org/r/204814

Change 117027 abandoned by Aaron Schulz:
Pass correct parameter to stat() in checkImages.php

Reason:
Obsolete - https://gerrit.wikimedia.org/r/#/c/204814/

https://gerrit.wikimedia.org/r/117027

Change 204814 merged by jenkins-bot:
Fixed stat calls in checkImages

https://gerrit.wikimedia.org/r/204814

Aklapper claimed this task.
Aklapper added a subscriber: aaron.

@aaron: All patches merged; assuming this is fixed. If not, please reopen.