Page MenuHomePhabricator

When using importImages.php to overwrite multiple existing files, only the first is overwritten
Closed, ResolvedPublic

Description

reedy@terbium:/media/external/keepers$ sudo -u apache mwscript importImages.php --wiki=commonswiki --comment-ext=txt --user=LSHuploadBot /media/external/keepers/reupload/ --overwrite
Import Images

Vas_med_frostblommor_-_Hallwylska_museet_-_87149.tif exists, overwriting...done.
Älghudskyller,_Sverige_1600-talets_början_-_Livrustkammaren_-_43603.tif exists, skipping

Found: 2
Skipped: 1
Overwritten: 1
reedy@terbium:/media/external/keepers$ rm reupload/Vas_med_frostblommor_-_Hallwylska_museet_-_87149.t*
reedy@terbium:/media/external/keepers$ sudo -u apache mwscript importImages.php --wiki=commonswiki --comment-ext=txt --user=LSHuploadBot /media/external/keepers/reupload/ --overwrite
Import Images

Älghudskyller,_Sverige_1600-talets_början_-_Livrustkammaren_-_43603.tif exists, overwriting...done.

Found: 1
Overwritten: 1


Version: 1.22.0
Severity: normal

Details

Reference
bz55883

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 2:16 AM
bzimport set Reference to bz55883.
Reedy created this task.Oct 18 2013, 5:07 PM
Reedy added a comment.Oct 18 2013, 5:17 PM

Looks like it's because $options is blindly overwritten

  1. Import the file
		if ( isset( $options['dry'] ) ) {
			echo " publishing {$file} by '" . $wgUser->getName() . "', comment '$commentText'... ";
		} else {
			$props = FSFile::getPropsFromPath( $file );
			$flags = 0;
			$options = array();
			$handler = MediaHandler::getHandler( $props['mime'] );
			if ( $handler ) {
				$options['headers'] = $handler->getStreamHeaders( $props['metadata'] );
			} else {
				$options['headers'] = array();
			}
			$archive = $image->publish( $file, $flags, $options );
			if ( !$archive->isGood() ) {
				echo "failed. (" .
					$archive->getWikiText() .
					")\n";
				$failed++;
				continue;
			}
		}

Some parameters are variablised, some aren't. Any that aren't won't be carried forward...

Change 90573 had a related patch set uploaded by Reedy:
Don't blindly overwrite $options in importImages.php

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

Change 90573 merged by jenkins-bot:
Don't blindly overwrite $options in importImages.php

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