r22815 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r22814‎ | r22815 | r22816 >
Date:15:07, 7 June 2007
Author:robchurch
Status:old
Tags:
Comment:
* Don't require a list of extensions; move it into an option, and default to $wgFileExtensions
* Let the user know if no suitable files are found
* Missing release note from r22772
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/maintenance/importImages.php (modified) (history)

Diff [purge]

Index: trunk/phase3/RELEASE-NOTES
@@ -136,8 +136,10 @@
137137 * (bug 9383) Don't set a default value for BLOB column in rc-deleted
138138 database patch
139139 * (bug 10149) Don't show full template list on section-0 edit
 140+* Fix maintenance/importImages.php so it doesn't barf PHP errors when no suitable
 141+ files are found, and make the list of extensions an option (defaults to
 142+ $wgFileExtensions)
140143
141 -
142144 == MediaWiki API changes since 1.10 ==
143145
144146 (For ongoing development discussion, see http://www.mediawiki.org/wiki/API)
Index: trunk/phase3/maintenance/importImages.php
@@ -8,22 +8,24 @@
99 * @author Rob Church <robchur@gmail.com>
1010 */
1111
 12+$optionsWithArguments = array( 'extensions' );
1213 require_once( 'commandLine.inc' );
1314 require_once( 'importImages.inc.php' );
1415 echo( "Import Images\n\n" );
1516
16 -# Need a directory and at least one extension
17 -if( count( $args ) > 1 ) {
 17+# Need a path
 18+if( count( $args ) > 0 ) {
1819
19 - $dir = array_shift( $args );
 20+ $dir = $args[0];
2021
21 - # Check the allowed extensions
22 - while( $ext = array_shift( $args ) ) {
23 - $exts[] = ltrim( $ext, '.' );
24 - }
 22+ # Prepare the list of allowed extensions
 23+ global $wgFileExtensions;
 24+ $extensions = isset( $options['extensions'] )
 25+ ? explode( ',', strtolower( $options['extensions'] ) )
 26+ : $wgFileExtensions;
2527
26 - # Search the directory given and pull out suitable candidates
27 - $files = findFiles( $dir, $exts );
 28+ # Search the path provided for candidates for import
 29+ $files = findFiles( $dir, $extensions );
2830
2931 # Initialise the user for this operation
3032 $user = isset( $options['user'] )
@@ -44,6 +46,7 @@
4547 # Batch "upload" operation
4648 global $wgUploadDirectory;
4749 if( count( $files ) > 0 ) {
 50+
4851 foreach( $files as $file ) {
4952 $base = wfBaseName( $file );
5053
@@ -78,6 +81,9 @@
7982 echo( "failed.\n" );
8083 }
8184 }
 85+
 86+ } else {
 87+ echo( "No suitable files could be found for import.\n" );
8288 }
8389
8490 } else {
@@ -92,15 +98,15 @@
9399 }
94100
95101 echo <<<END
96 -USAGE: php importImages.php [options] <dir> <ext1> ...
 102+USAGE: php importImages.php [options] <dir>
97103
98104 <dir> : Path to the directory containing images to be imported
99 -<ext1+> File extensions to import
100105
101106 Options:
 107+--extensions=<exts> Comma-separated list of allowable extensions, defaults to $wgFileExtensions
 108+--user=<username> Set username of uploader, default 'Maintenance script'
 109+--comment=<text> Set upload summary comment, default 'Importing image file'
 110+--license=<code> Use an optional license template
102111
103112 END;
104113 exit();

Follow-up revisions

RevisionCommit summaryAuthorDate
r22857Merged revisions 22811-22855 via svnmerge from...david00:48, 9 June 2007

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r22772Don't bug out if no files were foundrobchurch18:39, 5 June 2007

Status & tagging log