Andrew-WMDE has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/378323 )
Change subject: [WIP] FileImporter behaviour when suppressed FILE revision data needs to be imported ...................................................................... [WIP] FileImporter behaviour when suppressed FILE revision data needs to be imported Bug: T173836 Change-Id: I6eb1c1bcef01b8549949ec38591ce23904955596 --- M i18n/en.json M i18n/qqq.json M src/Remote/MediaWiki/ApiDetailRetriever.php 3 files changed, 21 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/FileImporter refs/changes/23/378323/1 diff --git a/i18n/en.json b/i18n/en.json index e9857b2..86d932b 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -17,6 +17,7 @@ "fileimporter-cantimporturl": "Can't import the given URL", "fileimporter-cantimportfromsharedrepo": "Can't import a file from a shared repository.", "fileimporter-cantimportmissingfile": "Can't import a missing file.", + "fileimporter-cantimportfilehidden": "Can't import file because at least one of its revisions contains a suppressed file (filehidden flag set).", "fileimporter-badtoken": "CSRF token does not match", "fileimporter-badimporthash": "Import hash does not match. Please restart the import.", "fileimporter-filenameerror-default" : "There is an unknown issue with your filename.", diff --git a/i18n/qqq.json b/i18n/qqq.json index f6919e4..e00f48a 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -19,6 +19,7 @@ "fileimporter-cantimporturl": "Error message shown on the special page when the URL entered can not be imported from.", "fileimporter-cantimportfromsharedrepo": "Error message when the file import target comes from a shared or remote repository.", "fileimporter-cantimportmissingfile": "Error message when the file import target is missing.", + "fileimporter-cantimportfilehidden": "Error message when the file contains at least one revision with a suppressed file.", "fileimporter-badtoken": "Error message shown on the special page when the CSRF token for the request does not match the expected token.", "fileimporter-badimporthash": "Error message shown on the special page when the import hash for the request does not match the expected hash.", "fileimporter-filenameerror-default": "Error message shown on the special page when the file name to be imported to has an issue we have no special handling for.", diff --git a/src/Remote/MediaWiki/ApiDetailRetriever.php b/src/Remote/MediaWiki/ApiDetailRetriever.php index 9a3ca4b..963daf8 100644 --- a/src/Remote/MediaWiki/ApiDetailRetriever.php +++ b/src/Remote/MediaWiki/ApiDetailRetriever.php @@ -175,6 +175,18 @@ private function getFileRevisionsFromImageInfo( array $imageInfo, $pageTitle ) { $revisions = []; foreach ( $imageInfo as $revisionInfo ) { + if ( array_key_exists( 'filehidden', $revisionInfo ) ) { + throw new LocalizedImportException( 'fileimporter-cantimportfilehidden' ); + } + + if ( array_key_exists( 'userhidden', $revisionInfo ) ) { + $revisionInfo['user'] = '0.0.0.0'; + } + + if ( array_key_exists( 'sha1hidden', $revisionInfo ) ) { + $revisionInfo['sha1'] = sha1( $revisionInfo['*'] ); + } + /** * Convert from API sha1 format to DB sha1 format. * The conversion can be se inside ApiQueryImageInfo. @@ -182,6 +194,13 @@ * - DB sha1 format is base 36 padded to 31 chars */ $revisionInfo['sha1'] = \Wikimedia\base_convert( $revisionInfo['sha1'], 16, 36, 31 ); + + if ( array_key_exists( 'commenthidden', $revisionInfo ) ) { + $revisionInfo['comment'] = ( + new Message( 'fileimporter-revision-removed-comment' ) + )->plain(); + } + $revisionInfo['bits'] = $revisionInfo['size']; $revisionInfo['name'] = $pageTitle; $revisionInfo['description'] = $revisionInfo['comment']; -- To view, visit https://gerrit.wikimedia.org/r/378323 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6eb1c1bcef01b8549949ec38591ce23904955596 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/FileImporter Gerrit-Branch: master Gerrit-Owner: Andrew-WMDE <andrew.kos...@wikimedia.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits