From: Max Semenik Date: Wed, 26 Sep 2012 16:02:47 +0000 (+0400) Subject: Add 2 new options to importImages.php X-Git-Tag: 1.31.0-rc.0~22265^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/journal.php?a=commitdiff_plain;h=f000f1455519938ddaa1c2849759510d2bafa99e;p=lhc%2Fweb%2Fwiklou.git Add 2 new options to importImages.php --timestamp overrides upload timestamp --summary sets upload summary Change-Id: I930c8b1ce55af0543a41f412ecf702715c82c6df --- diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php index 695c4e9eab..bbabe8415d 100644 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@ -1006,7 +1006,7 @@ class LocalFile extends File { { $pageText = SpecialUpload::getInitialPageText( $desc, $license, $copyStatus, $source ); - if ( !$this->recordUpload2( $oldver, $desc, $pageText ) ) { + if ( !$this->recordUpload2( $oldver, $desc, $pageText, false, $timestamp ) ) { return false; } diff --git a/maintenance/importImages.php b/maintenance/importImages.php index 8d92383d0a..a8cd2ff959 100644 --- a/maintenance/importImages.php +++ b/maintenance/importImages.php @@ -31,7 +31,10 @@ * @author Mij */ -$optionsWithArgs = array( 'extensions', 'comment', 'comment-file', 'comment-ext', 'user', 'license', 'sleep', 'limit', 'from', 'source-wiki-url' ); +$optionsWithArgs = array( + 'extensions', 'comment', 'comment-file', 'comment-ext', 'summary', 'user', + 'license', 'sleep', 'limit', 'from', 'source-wiki-url', 'timestamp', +); require_once( __DIR__ . '/commandLine.inc' ); require_once( __DIR__ . '/importImages.inc' ); $processed = $added = $ignored = $skipped = $overwritten = $failed = 0; @@ -98,6 +101,8 @@ if ( $limit ) { $limit = (int)$limit; } +$timestamp = isset( $options['timestamp'] ) ? $options['timestamp'] : false; + # Get the upload comment. Provide a default one in case there's no comment given. $comment = 'Importing image file'; @@ -112,6 +117,8 @@ if ( isset( $options['comment-file'] ) ) { $commentExt = isset( $options['comment-ext'] ) ? $options['comment-ext'] : false; +$summary = isset( $options['summary'] ) ? $options['summary'] : ''; + # Get the license specifier $license = isset( $options['license'] ) ? $options['license'] : ''; @@ -230,9 +237,14 @@ if ( $count > 0 ) { } } + $commentText = SpecialUpload::getInitialPageText( $commentText, $license ); + if ( !$summary ) { + $summary = $commentText; + } + if ( isset( $options['dry'] ) ) { echo( "done.\n" ); - } elseif ( $image->recordUpload( $archive->value, $commentText, $license ) ) { + } elseif ( $image->recordUpload2( $archive->value, $summary, $commentText, false, $timestamp ) ) { # We're done! echo( "done.\n" ); @@ -315,24 +327,26 @@ USAGE: php importImages.php [options] Options: --extensions= Comma-separated list of allowable extensions, defaults to \$wgFileExtensions ---overwrite Overwrite existing images with the same name (default is to skip them) ---limit= Limit the number of images to process. Ignored or skipped images are not counted. ---from= Ignore all files until the one with the given name. Useful for resuming - aborted imports. should be the file's canonical database form. ---skip-dupes Skip images that were already uploaded under a different name (check SHA1) ---sleep= Sleep between files. Useful mostly for debugging. ---user= Set username of uploader, default 'Maintenance script' ---check-userblock Check if the user got blocked during import. ---comment= Set upload summary comment, default 'Importing image file'. ---comment-file= Set upload summary comment the the content of . ---comment-ext= Causes the comment for each file to be loaded from a file with the same name - but the extension . If a global comment is also given, it is appended. ---license= Use an optional license template ---dry Dry run, don't import anything +--overwrite Overwrite existing images with the same name (default is to skip them) +--limit= Limit the number of images to process. Ignored or skipped images are not counted. +--from= Ignore all files until the one with the given name. Useful for resuming + aborted imports. should be the file's canonical database form. +--skip-dupes Skip images that were already uploaded under a different name (check SHA1) +--sleep= Sleep between files. Useful mostly for debugging. +--user= Set username of uploader, default 'Maintenance script' +--check-userblock Check if the user got blocked during import. +--comment= Set file description, default 'Importing image file'. +--comment-file= Set description to the content of . +--comment-ext= Causes the description for each file to be loaded from a file with the same name + but the extension . If a global description is also given, it is appended. +--license= Use an optional license template +--dry Dry run, don't import anything --protect= Specify the protect value (autoconfirmed,sysop) +--summary= Upload summary, description will be used if not provided +--timestamp= Override upload time/date, all MediaWiki timestamp formats are accepted --unprotect Unprotects all uploaded images ---source-wiki-url if specified, take User and Comment data for each imported file from this URL. - For example, --source-wiki-url="http://en.wikipedia.org/" +--source-wiki-url If specified, take User and Comment data for each imported file from this URL. + For example, --source-wiki-url="http://en.wikipedia.org/" TEXT; exit( 1 );