Page MenuHomePhorge

No OneTemporary

Size
3 KB
Referenced Files
None
Subscribers
None
diff --git a/maintenance/importImages.php b/maintenance/importImages.php
index 59cca0f14bc..b7a9914fb62 100644
--- a/maintenance/importImages.php
+++ b/maintenance/importImages.php
@@ -358,54 +358,63 @@ class ImportImages extends Maintenance {
if ( $this->hasOption( 'dry' ) ) {
$this->output( "done.\n" );
- } elseif ( $image->recordUpload3(
+ } else {
+ $uploadStatus = $image->recordUpload3(
// @phan-suppress-next-line PhanPossiblyUndeclaredVariable
- $archive->value,
- $summary,
- $commentText,
- $user,
- // @phan-suppress-next-line PhanTypeMismatchArgumentNullable,PhanPossiblyUndeclaredVariable
- $props,
- $timestamp,
- $tags
- )->isOK() ) {
- $this->output( "done.\n" );
+ $archive->value,
+ $summary,
+ $commentText,
+ $user,
+ // @phan-suppress-next-line PhanTypeMismatchArgumentNullable,PhanPossiblyUndeclaredVariable
+ $props,
+ $timestamp,
+ $tags
+ );
- $doProtect = false;
+ if ( $uploadStatus->isOK() ) {
+ $this->output( "done.\n" );
- $protectLevel = $this->getOption( 'protect' );
- $restrictionLevels = $this->getConfig()->get( MainConfigNames::RestrictionLevels );
+ $doProtect = false;
- if ( $protectLevel && in_array( $protectLevel, $restrictionLevels ) ) {
- $doProtect = true;
- }
- if ( $this->hasOption( 'unprotect' ) ) {
- $protectLevel = '';
- $doProtect = true;
- }
+ $protectLevel = $this->getOption( 'protect' );
+ $restrictionLevels = $this->getConfig()->get( MainConfigNames::RestrictionLevels );
- if ( $doProtect ) {
- # Protect the file
- $this->output( "\nWaiting for replica DBs...\n" );
- // Wait for replica DBs.
- sleep( 2 ); # Why this sleep?
- $this->waitForReplication();
+ if ( $protectLevel && in_array( $protectLevel, $restrictionLevels ) ) {
+ $doProtect = true;
+ }
+ if ( $this->hasOption( 'unprotect' ) ) {
+ $protectLevel = '';
+ $doProtect = true;
+ }
- $this->output( "\nSetting image restrictions ..." );
+ if ( $doProtect ) {
+ # Protect the file
+ $this->output( "\nWaiting for replica DBs...\n" );
+ // Wait for replica DBs.
+ sleep( 2 ); # Why this sleep?
+ $this->waitForReplication();
- $cascade = false;
- $restrictions = [];
- foreach ( $restrictionStore->listApplicableRestrictionTypes( $title ) as $type ) {
- $restrictions[$type] = $protectLevel;
- }
+ $this->output( "\nSetting image restrictions ..." );
+
+ $cascade = false;
+ $restrictions = [];
+ foreach ( $restrictionStore->listApplicableRestrictionTypes( $title ) as $type ) {
+ $restrictions[$type] = $protectLevel;
+ }
- $page = $services->getWikiPageFactory()->newFromTitle( $title );
- $status = $page->doUpdateRestrictions( $restrictions, [], $cascade, '', $user );
- $this->output( ( $status->isOK() ? 'done' : 'failed' ) . "\n" );
+ $page = $services->getWikiPageFactory()->newFromTitle( $title );
+ $status = $page->doUpdateRestrictions( $restrictions, [], $cascade, '', $user );
+ $this->output( ( $status->isOK() ? 'done' : 'failed' ) . "\n" );
+ }
+ } elseif ( $uploadStatus->hasMessage( 'fileexists-no-change' ) ) {
+ $this->output( "skipped. (fileexists-no-change)\n" );
+ $svar = 'skipped';
+ } else {
+ $errors = $uploadStatus->getMessages( 'error' );
+ $firstErrorKey = ( $errors !== [] ) ? $errors[0]->getKey() : 'unknown error at recordUpload';
+ $this->output( "failed. ($firstErrorKey)\n" );
+ $svar = 'failed';
}
- } else {
- $this->output( "failed. (at recordUpload stage)\n" );
- $svar = 'failed';
}
$statistics[$svar]++;

File Metadata

Mime Type
text/x-diff
Expires
Sat, Jul 5, 5:31 AM (8 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
227432
Default Alt Text
(3 KB)

Event Timeline