Last modified: 2014-03-05 21:01:34 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T64148, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 62148 - Maintenance script checkImages.php called with a wrong parameter; does not work
Maintenance script checkImages.php called with a wrong parameter; does not work
Status: PATCH_TO_REVIEW
Product: MediaWiki
Classification: Unclassified
Maintenance scripts (Other open bugs)
1.22.3
All All
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
: easy
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-03-03 15:52 UTC by Joerg
Modified: 2014-03-05 21:01 UTC (History)
1 user (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Joerg 2014-03-03 15:52:58 UTC
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 ) {
	# 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...
Comment 1 Joerg 2014-03-03 16:27:39 UTC
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.
Comment 2 Andre Klapper 2014-03-05 12:15:38 UTC
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/
Comment 3 Gerrit Notification Bot 2014-03-05 19:52:28 UTC
Change 117027 had a related patch set uploaded by AalekhN:
Correct parameter passed checkImages.php

https://gerrit.wikimedia.org/r/117027
Comment 4 Joerg 2014-03-05 21:01:34 UTC
Thanks for putting the patch into Gerrit!

It looks good.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links