jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/352165 )
Change subject: Implement FileImporter behaviour when suppressed revision data needs to be imported ...................................................................... Implement FileImporter behaviour when suppressed revision data needs to be imported Bug: T162255 Change-Id: I0d83fc188860a2a02f8325c3c1564685bc16dffd --- M i18n/en.json M i18n/qqq.json M src/MediaWiki/ApiDetailRetriever.php 3 files changed, 35 insertions(+), 7 deletions(-) Approvals: WMDE-Fisch: Looks good to me, approved jenkins-bot: Verified diff --git a/i18n/en.json b/i18n/en.json index 04a7ab0..1c2afb9 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -17,7 +17,6 @@ "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-cantimportsuppressedcontent": "Can't import revisions with suppressed content.", "fileimporter-badtoken": "CSRF token does not match", "fileimporter-badimporthash": "Import hash does not match. Please restart the import.", "fileimporter-localtitleexists" : "The title you are currently trying to import to already exists on this wiki.", @@ -38,5 +37,7 @@ "fileimporter-editsummary-placeholder": "Only used if you make changes to the import.", "fileimporter-previewnote": "This is a preview of the file to be imported. Please check the page in detail before importing.", "fileimporter-heading-fileinfo": "File info", - "fileimporter-heading-filehistory": "File history" + "fileimporter-heading-filehistory": "File history", + "fileimporter-revision-removed-text": "Suppressed text removed by FileImporter.", + "fileimporter-revision-removed-comment": "Suppressed comment removed by FileImporter." } \ No newline at end of file diff --git a/i18n/qqq.json b/i18n/qqq.json index d5d0f2d..ec5c210 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -19,7 +19,6 @@ "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-cantimportsuppressedcontent": "Error message when the file import target includes suppressed content.", "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-localtitleexists": "Error message shown on the special page when the title to be imported to already exists on the local wiki.", @@ -40,5 +39,7 @@ "fileimporter-editsummary-placeholder": "Placeholder for the edit summary input box.", "fileimporter-previewnote": "Note shown at the top of the import page.", "fileimporter-heading-fileinfo": "Heading of the file info on the import page.", - "fileimporter-heading-filehistory": "Heading of the file history on the import page." + "fileimporter-heading-filehistory": "Heading of the file history on the import page.", + "fileimporter-revision-removed-text": "Text inserted if the original text is suppressed.", + "fileimporter-revision-removed-comment": "Text inserted as a revision comment if the original comment is suppressed." } diff --git a/src/MediaWiki/ApiDetailRetriever.php b/src/MediaWiki/ApiDetailRetriever.php index dca1484..6dfe004 100644 --- a/src/MediaWiki/ApiDetailRetriever.php +++ b/src/MediaWiki/ApiDetailRetriever.php @@ -197,9 +197,35 @@ private function getTextRevisionsFromRevisionsInfo( array $revisionsInfo, $pageTitle ) { $revisions = []; foreach ( $revisionsInfo as $revisionInfo ) { - if ( array_key_exists( 'suppressed', $revisionInfo ) ) { - // TODO allow importing revisions with suppressed content T162255 - throw new LocalizedImportException( 'fileimporter-cantimportsuppressedcontent' ); + + if ( array_key_exists( 'userhidden', $revisionInfo ) ) { + $revisionInfo['user'] = '0.0.0.0'; + } + + if ( array_key_exists( 'texthidden', $revisionInfo ) ) { + $revisionInfo['*'] = ( + new Message( 'fileimporter-revision-removed-text' ) + )->plain(); + } + + if ( array_key_exists( 'sha1hidden', $revisionInfo ) ) { + $revisionInfo['sha1'] = \Wikimedia\base_convert( + sha1( $revisionInfo['*'] ), 16, 36, 31 + ); + } + + if ( array_key_exists( 'commenthidden', $revisionInfo ) ) { + $revisionInfo['comment'] = ( + new Message( 'fileimporter-revision-removed-comment' ) + )->plain(); + } + + if ( !array_key_exists( 'contentmodel', $revisionInfo ) ) { + $revisionInfo['contentmodel'] = CONTENT_MODEL_WIKITEXT; + } + + if ( !array_key_exists( 'contentformat', $revisionInfo ) ) { + $revisionInfo['contentformat'] = CONTENT_FORMAT_WIKITEXT; } $revisionInfo['minor'] = array_key_exists( 'minor', $revisionInfo ); -- To view, visit https://gerrit.wikimedia.org/r/352165 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I0d83fc188860a2a02f8325c3c1564685bc16dffd Gerrit-PatchSet: 4 Gerrit-Project: mediawiki/extensions/FileImporter Gerrit-Branch: master Gerrit-Owner: Andrew-WMDE <andrew.kos...@wikimedia.de> Gerrit-Reviewer: Addshore <addshorew...@gmail.com> Gerrit-Reviewer: Tobias Gritschacher <tobias.gritschac...@wikimedia.de> Gerrit-Reviewer: WMDE-Fisch <christoph.jau...@wikimedia.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits