// Get the result based on the current upload context:
try {
$result = $this->getContextResult();
- if ( $result['result'] === 'Success' ) {
- $result['imageinfo'] = $this->mUpload->getImageInfo( $this->getResult() );
- }
} catch ( UploadStashException $e ) { // XXX: don't spam exception log
list( $msg, $code ) = $this->handleStashException( get_class( $e ), $e->getMessage() );
$this->dieUsage( $msg, $code );
}
-
$this->getResult()->addValue( null, $this->getModuleName(), $result );
+ // Add 'imageinfo' in a separate addValue() call. File metadata can be unreasonably large,
+ // so otherwise when it exceeded $wgAPIMaxResultSize, no result would be returned (T143993).
+ if ( $result['result'] === 'Success' ) {
+ $imageinfo = $this->mUpload->getImageInfo( $this->getResult() );
+ $this->getResult()->addValue( $this->getModuleName(), 'imageinfo', $imageinfo );
+ }
+
// Cleanup any temporary mess
$this->mUpload->cleanupTempFile();
}
$this->dieStatusWithCode( $status, 'stashfailed' );
}
+ // We can only get warnings like 'duplicate' after concatenating the chunks
+ $warnings = $this->getApiWarnings();
+ if ( $warnings ) {
+ $result['warnings'] = $warnings;
+ }
+
// The fully concatenated file has a new filekey. So remove
// the old filekey and fetch the new one.
UploadBase::setSessionStatus( $this->getUser(), $filekey, false );
$code = $overrideCode;
}
if ( $moreExtraData ) {
+ $extraData = $extraData ?: [];
$extraData += $moreExtraData;
}
$this->dieUsage( $msg, $code, 0, $extraData );
if ( isset( $progress['status']->value['verification'] ) ) {
$this->checkVerification( $progress['status']->value['verification'] );
}
+ if ( isset( $progress['status']->value['warnings'] ) ) {
+ $warnings = $this->transformWarnings( $progress['status']->value['warnings'] );
+ if ( $warnings ) {
+ $progress['warnings'] = $warnings;
+ }
+ }
unset( $progress['status'] ); // remove Status object
+ $imageinfo = null;
+ if ( isset( $progress['imageinfo'] ) ) {
+ $imageinfo = $progress['imageinfo'];
+ unset( $progress['imageinfo'] );
+ }
+
$this->getResult()->addValue( null, $this->getModuleName(), $progress );
+ // Add 'imageinfo' in a separate addValue() call. File metadata can be unreasonably large,
+ // so otherwise when it exceeded $wgAPIMaxResultSize, no result would be returned (T143993).
+ if ( $imageinfo ) {
+ $this->getResult()->addValue( $this->getModuleName(), 'imageinfo', $imageinfo );
+ }
return false;
}
: $warning['file'];
$warnings[$warning['warning']] = $localFile->getName();
}
+
+ if ( isset( $warnings['no-change'] ) ) {
+ /** @var File $file */
+ $file = $warnings['no-change'];
+ unset( $warnings['no-change'] );
+
+ $warnings['nochange'] = [
+ 'timestamp' => wfTimestamp( TS_ISO_8601, $file->getTimestamp() )
+ ];
+ }
+
+ if ( isset( $warnings['duplicate-version'] ) ) {
+ $dupes = [];
+ /** @var File $dupe */
+ foreach ( $warnings['duplicate-version'] as $dupe ) {
+ $dupes[] = [
+ 'timestamp' => wfTimestamp( TS_ISO_8601, $dupe->getTimestamp() )
+ ];
+ }
+ unset( $warnings['duplicate-version'] );
+
+ ApiResult::setIndexedTagName( $dupes, 'ver' );
+ $warnings['duplicateversions'] = $dupes;
+ }
}
return $warnings;