Umherirrender has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/364114 )
Change subject: Break long lines ...................................................................... Break long lines Change-Id: I39de83f50f34d5ea0aa7c635e1d52ea978a69694 --- M GWToolset.php M includes/Config.php M includes/Forms/MetadataDetectForm.php M includes/Forms/MetadataMappingForm.php M includes/Handlers/Forms/MetadataDetectHandler.php M includes/Helpers/FileChecks.php M includes/Helpers/WikiChecks.php M maintenance/cleanupGWTFileBackend.php M phpcs.xml 9 files changed, 86 insertions(+), 44 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GWToolset refs/changes/14/364114/1 diff --git a/GWToolset.php b/GWToolset.php index f72384b..90a8021 100644 --- a/GWToolset.php +++ b/GWToolset.php @@ -10,7 +10,8 @@ namespace GWToolset; if ( !defined( 'MEDIAWIKI' ) ) { - echo 'This file is part of a MediaWiki extension; it is not a valid entry point. To install this extension, follow the instructions in the INSTALL file.'; + echo 'This file is part of a MediaWiki extension; it is not a valid entry point. To install ' . + 'this extension, follow the instructions in the INSTALL file.'; exit(); } @@ -50,25 +51,34 @@ 'GWToolset\Config' => __DIR__ . '/includes/Config.php', 'GWToolset\GWTException' => __DIR__ . '/includes/GWTException.php', 'GWToolset\Utils' => __DIR__ . '/includes/Utils.php', - 'GWToolset\Adapters\DataAdapterInterface' => __DIR__ . '/includes/Adapters/DataAdapterInterface.php', - 'GWToolset\Adapters\Php\MappingPhpAdapter' => __DIR__ . '/includes/Adapters/Php/MappingPhpAdapter.php', - 'GWToolset\Adapters\Php\MediawikiTemplatePhpAdapter' => __DIR__ . '/includes/Adapters/Php/MediawikiTemplatePhpAdapter.php', - 'GWToolset\Adapters\Php\MetadataPhpAdapter' => __DIR__ . '/includes/Adapters/Php/MetadataPhpAdapter.php', + 'GWToolset\Adapters\DataAdapterInterface' => + __DIR__ . '/includes/Adapters/DataAdapterInterface.php', + 'GWToolset\Adapters\Php\MappingPhpAdapter' => + __DIR__ . '/includes/Adapters/Php/MappingPhpAdapter.php', + 'GWToolset\Adapters\Php\MediawikiTemplatePhpAdapter' => + __DIR__ . '/includes/Adapters/Php/MediawikiTemplatePhpAdapter.php', + 'GWToolset\Adapters\Php\MetadataPhpAdapter' => + __DIR__ . '/includes/Adapters/Php/MetadataPhpAdapter.php', 'GWToolset\Forms\MetadataDetectForm' => __DIR__ . '/includes/Forms/MetadataDetectForm.php', 'GWToolset\Forms\MetadataMappingForm' => __DIR__ . '/includes/Forms/MetadataMappingForm.php', 'GWToolset\Forms\PreviewForm' => __DIR__ . '/includes/Forms/PreviewForm.php', 'GWToolset\Handlers\Forms\FormHandler' => __DIR__ . '/includes/Handlers/Forms/FormHandler.php', - 'GWToolset\Handlers\Forms\MetadataDetectHandler' => __DIR__ . '/includes/Handlers/Forms/MetadataDetectHandler.php', - 'GWToolset\Handlers\Forms\MetadataMappingHandler' => __DIR__ . '/includes/Handlers/Forms/MetadataMappingHandler.php', + 'GWToolset\Handlers\Forms\MetadataDetectHandler' => + __DIR__ . '/includes/Handlers/Forms/MetadataDetectHandler.php', + 'GWToolset\Handlers\Forms\MetadataMappingHandler' => + __DIR__ . '/includes/Handlers/Forms/MetadataMappingHandler.php', 'GWToolset\Handlers\UploadHandler' => __DIR__ . '/includes/Handlers/UploadHandler.php', - 'GWToolset\Handlers\Xml\XmlDetectHandler' => __DIR__ . '/includes/Handlers/Xml/XmlDetectHandler.php', + 'GWToolset\Handlers\Xml\XmlDetectHandler' => + __DIR__ . '/includes/Handlers/Xml/XmlDetectHandler.php', 'GWToolset\Handlers\Xml\XmlHandler' => __DIR__ . '/includes/Handlers/Xml/XmlHandler.php', - 'GWToolset\Handlers\Xml\XmlMappingHandler' => __DIR__ . '/includes/Handlers/Xml/XmlMappingHandler.php', + 'GWToolset\Handlers\Xml\XmlMappingHandler' => + __DIR__ . '/includes/Handlers/Xml/XmlMappingHandler.php', 'GWToolset\Helpers\FileChecks' => __DIR__ . '/includes/Helpers/FileChecks.php', 'GWToolset\Helpers\GWTFileBackend' => __DIR__ . '/includes/Helpers/GWTFileBackend.php', 'GWToolset\Helpers\WikiChecks' => __DIR__ . '/includes/Helpers/WikiChecks.php', 'GWToolset\Hooks' => __DIR__ . '/includes/Hooks/Hooks.php', - 'GWToolset\Jobs\GWTFileBackendCleanupJob' => __DIR__ . '/includes/Jobs/GWTFileBackendCleanupJob.php', + 'GWToolset\Jobs\GWTFileBackendCleanupJob' => + __DIR__ . '/includes/Jobs/GWTFileBackendCleanupJob.php', 'GWToolset\Jobs\UploadMediafileJob' => __DIR__ . '/includes/Jobs/UploadMediafileJob.php', 'GWToolset\Jobs\UploadMetadataJob' => __DIR__ . '/includes/Jobs/UploadMetadataJob.php', 'GWToolset\Models\Mapping' => __DIR__ . '/includes/Models/Mapping.php', diff --git a/includes/Config.php b/includes/Config.php index 4f8cbf7..12449e1 100644 --- a/includes/Config.php +++ b/includes/Config.php @@ -103,6 +103,7 @@ * - fallbacks in case there’s no template data for these MediaWiki templates */ public static $mediawiki_templates = [ + // @codingStandardsIgnoreStart 'Art_Photo' => '{"artist":"","title":"","description":"","date":"","medium":"","dimensions":"","institution":"","location":"","references":"","object history":"","exhibition history":"","credit line":"","inscriptions":"","notes":"","accession number":"","object type":"","artwork license":"","artwork":"","photo description":"","photo date":"","photographer":"","source":"","photo license":"","other_versions":""}', 'Artwork' => '{"artist":"","title":"","description":"","date":"","medium":"","dimensions":"","institution":"","location":"","references":"","object history":"","exhibition history":"","credit line":"","inscriptions":"","notes":"","accession number":"","source":"","permission":"","other_versions":""}', 'Book' => '{"Author":"","Translator":"","Editor":"","Illustrator":"","Title":"","Subtitle":"","Series title":"","Volume":"","Edition":"","Publisher":"","Printer":"","Date":"","City":"","Language":"","Description":"","Source":"","Permission":"","Image":"","Image page":"","Pageoverview":"","Wikisource":"","Homecat":"","Other_versions":"","ISBN":"","LCCN":"","OCLC":""}', @@ -111,6 +112,7 @@ 'Musical_work' => '{"composer":"","lyrics_writer":"","performer":"","title":"","description":"","composition_date":"","performance_date":"","notes":"","record_ID":"","image":"","references":"","source":"","permission":"","other_versions":""}', 'Photograph' => '{"photographer":"","title":"","description":"","depicted people":"","depicted place":"","date":"","medium":"","dimensions":"","institution":"","department":"","references":"","object history":"","exhibition history":"","credit line":"","inscriptions":"","notes":"","accession number":"","source":"","permission":"","other_versions":""}', 'Specimen' => '{"taxon":"","authority":"","institution":"","accession number":"","sex":"","discovery place":"","cultivar":"","author":"","source":"","date":"","description":"","period":"","depicted place":"","camera coord":"","dimensions":"","institution":"","location":"","object history":"","exhibition history":"","credit line":"","notes":"","references":"","permission":"","other versions":"","photographer":"","source":""}' + // @codingStandardsIgnoreEnd ]; /** diff --git a/includes/Forms/MetadataDetectForm.php b/includes/Forms/MetadataDetectForm.php index c4b0130..0b82432 100644 --- a/includes/Forms/MetadataDetectForm.php +++ b/includes/Forms/MetadataDetectForm.php @@ -40,7 +40,9 @@ [], wfMessage( 'gwtoolset-step-1-instructions-3', + // @codingStandardsIgnoreStart 'https://phabricator.wikimedia.org/maniphest/task/create/?projects=Wikimedia-Site-requests&priority=50&title=Add+domain+to+$wgCopyUploadsDomains&description=Please+add+the+following+domain+to+the+wgCopyUploadsDomains+whitelist,+so+that+I+can+use+GWToolset+to+upload+media+files+from+that+domain.+I+have+provided+at+least+3+example+URLs+to+media+files+that+will+be+uploaded+with+GWToolset.%0A%0A%3Cdomain+name%3E%0A%0A%3Cexample+URL%3E%0A%3Cexample+URL%3E%0A%3Cexample+URL%3E' + // @codingStandardsIgnoreEnd )->parse() ); @@ -322,7 +324,8 @@ [ 'type' => 'file', 'name' => 'gwtoolset-metadata-file-upload', - 'accept' => FileChecks::getFileAcceptAttribute( Config::$accepted_metadata_types ) + 'accept' => FileChecks::getFileAcceptAttribute( + Config::$accepted_metadata_types ) ] ) . Html::rawElement( 'br' ) . diff --git a/includes/Forms/MetadataMappingForm.php b/includes/Forms/MetadataMappingForm.php index bb2a4c4..8505343 100644 --- a/includes/Forms/MetadataMappingForm.php +++ b/includes/Forms/MetadataMappingForm.php @@ -34,8 +34,8 @@ Utils::sanitizeString( $user_options['gwtoolset-mediawiki-template-name'] ) . ']]'; $metadata_file_url = !empty( $user_options['Metadata-Title'] ) - ? $linkRenderer->makeLink( $user_options['Metadata-Title'], null, [ 'target' => '_blank' ] ) . - Html::rawElement( 'br' ) + ? $linkRenderer->makeLink( $user_options['Metadata-Title'], null, + [ 'target' => '_blank' ] ) . Html::rawElement( 'br' ) : null; return @@ -76,7 +76,8 @@ Html::rawElement( 'li', [], - wfMessage( 'gwtoolset-step-2-instructions-1-li-1' )->params( $template_link )->parse() + wfMessage( 'gwtoolset-step-2-instructions-1-li-1' ) + ->params( $template_link )->parse() ) . Html::rawElement( @@ -165,7 +166,8 @@ 'type' => 'hidden', 'id' => 'gwtoolset-mediawiki-template-name', 'name' => 'gwtoolset-mediawiki-template-name', - 'value' => Utils::sanitizeString( $user_options['gwtoolset-mediawiki-template-name'] ) + 'value' => Utils::sanitizeString( + $user_options['gwtoolset-mediawiki-template-name'] ) ] ) . @@ -184,7 +186,8 @@ 'type' => 'hidden', 'id' => 'gwtoolset-metadata-mapping-name', 'name' => 'gwtoolset-metadata-mapping-name', - 'value' => Utils::sanitizeString( $user_options['gwtoolset-metadata-mapping-name'] ) + 'value' => Utils::sanitizeString( + $user_options['gwtoolset-metadata-mapping-name'] ) ] ) . @@ -193,7 +196,8 @@ [ 'type' => 'hidden', 'name' => 'gwtoolset-metadata-mapping-url', - 'value' => Utils::sanitizeString( $user_options['gwtoolset-metadata-mapping-url'] ) + 'value' => Utils::sanitizeString( + $user_options['gwtoolset-metadata-mapping-url'] ) ] ) . @@ -202,7 +206,8 @@ [ 'type' => 'hidden', 'name' => 'gwtoolset-metadata-file-relative-path', - 'value' => Utils::sanitizeUrl( $user_options['gwtoolset-metadata-file-relative-path'] ) + 'value' => Utils::sanitizeUrl( + $user_options['gwtoolset-metadata-file-relative-path'] ) ] ) . @@ -211,7 +216,8 @@ [ 'type' => 'hidden', 'name' => 'gwtoolset-metadata-file-sha1', - 'value' => Utils::sanitizeString( $user_options['gwtoolset-metadata-file-sha1'] ) + 'value' => Utils::sanitizeString( + $user_options['gwtoolset-metadata-file-sha1'] ) ] ) . @@ -229,7 +235,8 @@ [ 'type' => 'hidden', 'name' => 'gwtoolset-record-element-name', - 'value' => Utils::sanitizeString( $user_options['gwtoolset-record-element-name'] ) + 'value' => Utils::sanitizeString( + $user_options['gwtoolset-record-element-name'] ) ] ) . @@ -239,7 +246,8 @@ 'type' => 'hidden', 'id' => 'gwtoolset-metadata-namespace', 'name' => 'gwtoolset-metadata-namespace', - 'value' => Utils::sanitizeString( Utils::getNamespaceName( Config::$metadata_namespace ) ) + 'value' => Utils::sanitizeString( + Utils::getNamespaceName( Config::$metadata_namespace ) ) ] ) . @@ -267,7 +275,8 @@ 'h3', [], wfMessage( 'gwtoolset-mediawiki-template' ) - ->params( Utils::sanitizeString( $user_options['gwtoolset-mediawiki-template-name'] ) ) + ->params( Utils::sanitizeString( + $user_options['gwtoolset-mediawiki-template-name'] ) ) ->escaped() ) . diff --git a/includes/Handlers/Forms/MetadataDetectHandler.php b/includes/Handlers/Forms/MetadataDetectHandler.php index c8a984e..0a268d1 100644 --- a/includes/Handlers/Forms/MetadataDetectHandler.php +++ b/includes/Handlers/Forms/MetadataDetectHandler.php @@ -123,21 +123,24 @@ 'gwtoolset-mediawiki-template-name' => $this->setTemplateName(), - 'gwtoolset-metadata-file-url' => !empty( $this->_whitelisted_post['gwtoolset-metadata-file-url'] ) - ? $this->_whitelisted_post['gwtoolset-metadata-file-url'] - : null, + 'gwtoolset-metadata-file-url' => + !empty( $this->_whitelisted_post['gwtoolset-metadata-file-url'] ) + ? $this->_whitelisted_post['gwtoolset-metadata-file-url'] + : null, - 'gwtoolset-metadata-mapping-url' => !empty( $this->_whitelisted_post['gwtoolset-metadata-mapping-url'] ) - ? $this->_whitelisted_post['gwtoolset-metadata-mapping-url'] - : null, + 'gwtoolset-metadata-mapping-url' => + !empty( $this->_whitelisted_post['gwtoolset-metadata-mapping-url'] ) + ? $this->_whitelisted_post['gwtoolset-metadata-mapping-url'] + : null, 'Metadata-Title' => null, 'gwtoolset-record-count' => 0, - 'gwtoolset-record-element-name' => !empty( $this->_whitelisted_post['gwtoolset-record-element-name'] ) - ? $this->_whitelisted_post['gwtoolset-record-element-name'] - : 'record', + 'gwtoolset-record-element-name' => + !empty( $this->_whitelisted_post['gwtoolset-record-element-name'] ) + ? $this->_whitelisted_post['gwtoolset-record-element-name'] + : 'record', ]; } diff --git a/includes/Helpers/FileChecks.php b/includes/Helpers/FileChecks.php index fc1a78e..22b028f 100644 --- a/includes/Helpers/FileChecks.php +++ b/includes/Helpers/FileChecks.php @@ -189,9 +189,16 @@ public static function isAcceptedMimeType( File $File, array $accepted_mime_types = [] ) { if ( !in_array( $File->mime_type, $accepted_mime_types ) ) { if ( self::$current_extension === 'xml' ) { - return Status::newFatal( 'gwtoolset-unaccepted-mime-type-for-xml', Utils::sanitizeString( $File->mime_type ), '<?xml version="1.0" encoding="UTF-8"?>' ); + return Status::newFatal( + 'gwtoolset-unaccepted-mime-type-for-xml', + Utils::sanitizeString( $File->mime_type ), + '<?xml version="1.0" encoding="UTF-8"?>' + ); } else { - return Status::newFatal( 'gwtoolset-unaccepted-mime-type', Utils::sanitizeString( $File->mime_type ) ); + return Status::newFatal( + 'gwtoolset-unaccepted-mime-type', + Utils::sanitizeString( $File->mime_type ) + ); } } @@ -229,8 +236,10 @@ if ( empty( $accepted_types ) ) { throw new MWException( wfMessage( 'gwtoolset-developer-issue' ) - ->params( wfMessage( 'gwtoolset-no-accepted-types' )->escaped( 'gwtoolset-no-accepted-types-provided' ) ) - ->parse() + ->params( + wfMessage( 'gwtoolset-no-accepted-types' ) + ->escaped( 'gwtoolset-no-accepted-types-provided' ) + )->parse() ); } @@ -249,7 +258,9 @@ return $Status; } - $Status = self::isAcceptedFileExtension( $File, self::getAcceptedExtensions( $accepted_types ) ); + $Status = self::isAcceptedFileExtension( + $File, self::getAcceptedExtensions( $accepted_types ) + ); if ( !$Status->ok ) { return $Status; } @@ -278,8 +289,9 @@ return Status::newFatal( 'gwtoolset-unaccepted-extension' ); } - $mime_type_extension_match = - MimeMagic::singleton()->isMatchingExtension( $File->pathinfo['extension'], $File->mime_type ); + $mime_type_extension_match = MimeMagic::singleton()->isMatchingExtension( + $File->pathinfo['extension'], $File->mime_type + ); if ( !$mime_type_extension_match ) { return Status::newFatal( diff --git a/includes/Helpers/WikiChecks.php b/includes/Helpers/WikiChecks.php index 50fc29f..29be0a5 100644 --- a/includes/Helpers/WikiChecks.php +++ b/includes/Helpers/WikiChecks.php @@ -144,7 +144,9 @@ * @return {Status} */ public static function doesEditTokenMatch( SpecialPage $SpecialPage ) { - if ( !$SpecialPage->getUser()->matchEditToken( $SpecialPage->getRequest()->getVal( 'wpEditToken' ) ) ) { + if ( !$SpecialPage->getUser()->matchEditToken( + $SpecialPage->getRequest()->getVal( 'wpEditToken' ) ) + ) { return Status::newFatal( 'gwtoolset-permission-not-given', wfMessage( 'gwtoolset-invalid-token' )->escaped() @@ -243,7 +245,9 @@ global $wgEnableUploads; if ( !$wgEnableUploads || ( !wfIsHHVM() && !wfIniGetBool( 'file_uploads' ) ) ) { - return Status::newFatal( 'gwtoolset-verify-uploads-enabled', Constants::EXTENSION_NAME ); + return Status::newFatal( + 'gwtoolset-verify-uploads-enabled', Constants::EXTENSION_NAME + ); } return Status::newGood(); diff --git a/maintenance/cleanupGWTFileBackend.php b/maintenance/cleanupGWTFileBackend.php index cb524cf..8d15909 100644 --- a/maintenance/cleanupGWTFileBackend.php +++ b/maintenance/cleanupGWTFileBackend.php @@ -21,9 +21,9 @@ /** * Maintenance script to remove abandoned or outdated metadata files from the temporary - * gwtoolset file storage. These files are normally removed by GWToolset\Jobs\GWTFileBackendCleanupJob, - * however if a user stops the GWToolset upload process or the clean-up job fails to run, - * some files may become orphaned. + * gwtoolset file storage. These files are normally removed by + * GWToolset\Jobs\GWTFileBackendCleanupJob, however if a user stops the GWToolset upload process + * or the clean-up job fails to run, some files may become orphaned. * * @ingroup Maintenance */ diff --git a/phpcs.xml b/phpcs.xml index de673c8..a41ee98 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,7 +1,6 @@ <?xml version="1.0"?> <ruleset> <rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki"> - <exclude name="Generic.Files.LineLength"/> <exclude name="PSR2.Classes.PropertyDeclaration.Underscore"/> <exclude name="MediaWiki.Commenting.FunctionComment.ExtraParamComment" /> <exclude name="MediaWiki.Commenting.FunctionComment.MissingParamComment" /> -- To view, visit https://gerrit.wikimedia.org/r/364114 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I39de83f50f34d5ea0aa7c635e1d52ea978a69694 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/GWToolset Gerrit-Branch: master Gerrit-Owner: Umherirrender <umherirrender_de...@web.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits