jenkins-bot has submitted this change and it was merged.
Change subject: Add php code sniffer, Remove i18n shim
......................................................................
Add php code sniffer, Remove i18n shim
Change-Id: Id1d9b40ebd536108f11be2eff8f1387180ad40e4
---
M .gitignore
M MwEmbedModules/MediaWikiSupport/MediaWikiSupport.config.php
D MwEmbedModules/MwEmbedSupport/MwEmbedSupport.i18n.php
M MwEmbedResourceManager.php
M MwEmbedSupport.php
M composer.json
A phpcs.xml
7 files changed, 55 insertions(+), 51 deletions(-)
Approvals:
TheDJ: Looks good to me, approved
jenkins-bot: Verified
diff --git a/.gitignore b/.gitignore
index a48934e..9d06b20 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,3 @@
-.svn
*~
*.kate-swp
.*.swp
@@ -9,4 +8,4 @@
/vendor
/composer.lock
/composer.json
-/composer.local.json
\ No newline at end of file
+/composer.local.json
diff --git a/MwEmbedModules/MediaWikiSupport/MediaWikiSupport.config.php
b/MwEmbedModules/MediaWikiSupport/MediaWikiSupport.config.php
index a6e1664..9ea469e 100644
--- a/MwEmbedModules/MediaWikiSupport/MediaWikiSupport.config.php
+++ b/MwEmbedModules/MediaWikiSupport/MediaWikiSupport.config.php
@@ -14,8 +14,21 @@
)
),
- "MediaWiki.ApiPostActions" => array( 'login', 'purge', 'rollback',
'delete', 'undelete',
- 'protect', 'block', 'unblock', 'move', 'edit', 'upload',
'emailuser',
- 'import', 'userrights' ),
+ "MediaWiki.ApiPostActions" => array(
+ 'login',
+ 'purge',
+ 'rollback',
+ 'delete',
+ 'undelete',
+ 'protect',
+ 'block',
+ 'unblock',
+ 'move',
+ 'edit',
+ 'upload',
+ 'emailuser',
+ 'import',
+ 'userrights'
+ ),
);
diff --git a/MwEmbedModules/MwEmbedSupport/MwEmbedSupport.i18n.php
b/MwEmbedModules/MwEmbedSupport/MwEmbedSupport.i18n.php
deleted file mode 100644
index 8ab1be1..0000000
--- a/MwEmbedModules/MwEmbedSupport/MwEmbedSupport.i18n.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-/**
- * This is a backwards-compatibility shim, generated by:
- *
https://git.wikimedia.org/blob/mediawiki%2Fcore.git/HEAD/maintenance%2FgenerateJsonI18n.php
- *
- * Beginning with MediaWiki 1.23, translation strings are stored in json files,
- * and the EXTENSION.i18n.php file only exists to provide compatibility with
- * older releases of MediaWiki. For more information about this migration, see:
- * https://www.mediawiki.org/wiki/Requests_for_comment/Localisation_format
- *
- * This shim maintains compatibility back to MediaWiki 1.17.
- */
-$messages = array();
-if ( !function_exists( 'wfJsonI18nShim8b01f527e599cd45' ) ) {
- function wfJsonI18nShim8b01f527e599cd45( $cache, $code, &$cachedData ) {
- $codeSequence = array_merge( array( $code ),
$cachedData['fallbackSequence'] );
- foreach ( $codeSequence as $csCode ) {
- $fileName = dirname( __FILE__ ) . "/i18n/$csCode.json";
- if ( is_readable( $fileName ) ) {
- $data = FormatJson::decode( file_get_contents(
$fileName ), true );
- foreach ( array_keys( $data ) as $key ) {
- if ( $key === '' || $key[0] === '@' ) {
- unset( $data[$key] );
- }
- }
- $cachedData['messages'] = array_merge( $data,
$cachedData['messages'] );
- }
-
- $cachedData['deps'][] = new FileDependency( $fileName );
- }
- return true;
- }
-
- $GLOBALS['wgHooks']['LocalisationCacheRecache'][] =
'wfJsonI18nShim8b01f527e599cd45';
-}
diff --git a/MwEmbedResourceManager.php b/MwEmbedResourceManager.php
index c9b5a1b..36947eb 100644
--- a/MwEmbedResourceManager.php
+++ b/MwEmbedResourceManager.php
@@ -19,30 +19,43 @@
* @throws Exception
*/
public static function register( $mwEmbedResourcePath ) {
- global $IP, $wgExtensionMessagesFiles;
+ // @codingStandardsIgnoreStart
+ global $IP;
+ // @codingStandardsIgnoreEnd
$localResourcePath = $IP . '/' . $mwEmbedResourcePath;
// Get the module name from the end of the path:
$modulePathParts = explode( '/', $mwEmbedResourcePath );
$moduleName = array_pop( $modulePathParts );
if ( !is_dir( $localResourcePath ) ) {
- throw new Exception( __METHOD__ . " not given readable
path: " . htmlspecialchars( $localResourcePath ) );
+ throw new Exception(
+ __METHOD__ . " not given readable path: " .
htmlspecialchars( $localResourcePath )
+ );
}
if ( substr( $mwEmbedResourcePath, -1 ) == '/' ) {
- throw new Exception( __METHOD__ . " path has trailing
slash: " . htmlspecialchars( $localResourcePath ) );
+ throw new Exception(
+ __METHOD__ . " path has trailing slash: " .
htmlspecialchars( $localResourcePath )
+ );
}
// Check that resource file is present:
$resourceListFilePath = $localResourcePath . '/' . $moduleName
. '.php';
if ( !is_file( $resourceListFilePath ) ) {
- throw new Exception( __METHOD__ . " mwEmbed Module is
missing resource list: " . htmlspecialchars( $resourceListFilePath ) );
+ throw new Exception(
+ __METHOD__ . " mwEmbed Module is missing
resource list: " . htmlspecialchars(
+ $resourceListFilePath
+ )
+ );
}
// Get the mwEmbed module resource registration:
$resourceList = include $resourceListFilePath;
// Look for special 'messages' => 'moduleFile' key and load all
modules file messages:
foreach ( $resourceList as $name => $resources ) {
- if ( isset( $resources['messageFile'] ) && is_file(
$localResourcePath . '/' . $resources['messageFile'] ) ) {
+ if (
+ isset( $resources['messageFile'] ) &&
+ is_file( $localResourcePath . '/' .
$resources['messageFile'] )
+ ) {
$resourceList[$name]['messages'] = array();
include $localResourcePath . '/' .
$resources['messageFile'];
foreach ( $messages['en'] as $msgKey => $na ) {
@@ -99,10 +112,13 @@
* @return bool
*/
public static function registerModules( &$resourceLoader ) {
- global $IP, $wgMwEmbedResourceLoaderFileModule, $wgScriptPath;
+ // @codingStandardsIgnoreStart
+ global $IP;
+ // @codingStandardsIgnoreEnd
+ global $wgMwEmbedResourceLoaderFileModule, $wgScriptPath;
// Register all the resources with the resource loader
foreach ( self::$moduleSet as $path => $modules ) {
- //remove 'extension' prefix from path
+ // remove 'extension' prefix from path
$remoteExtPath = explode( '/', $path );
array_shift( $remoteExtPath );
$remoteExtPath = implode( '/', $remoteExtPath );
diff --git a/MwEmbedSupport.php b/MwEmbedSupport.php
index e81e76c..99a5164 100644
--- a/MwEmbedSupport.php
+++ b/MwEmbedSupport.php
@@ -12,7 +12,8 @@
*/
if ( !defined( 'MEDIAWIKI' ) ) {
- echo "This is the TimedMediaHandler extension. Please see the README
file for installation instructions.\n";
+ echo "This is the TimedMediaHandler extension.
+ Please see the README file for installation instructions.\n";
exit( 1 );
}
@@ -39,7 +40,6 @@
// Include module messages:
$wgMessagesDirs['MwEmbedSupport'] = __DIR__ . '/i18n';
$wgMessagesDirs['MwEmbed.MwEmbedSupport'] = __DIR__ .
'/MwEmbedModules/MwEmbedSupport/i18n';
-$wgExtensionMessagesFiles['MwEmbed.MwEmbedSupport'] = __DIR__
."/MwEmbedModules/MwEmbedSupport/MwEmbedSupport.i18n.php";
// Add Global MwEmbed Registration hook
$wgHooks['ResourceLoaderRegisterModules'][] =
'MwEmbedResourceManager::registerModules';
diff --git a/composer.json b/composer.json
index f2883f7..2c5c7d2 100644
--- a/composer.json
+++ b/composer.json
@@ -1,10 +1,12 @@
{
"require-dev": {
- "jakub-onderka/php-parallel-lint": "0.9"
+ "jakub-onderka/php-parallel-lint": "0.9",
+ "mediawiki/mediawiki-codesniffer": "0.4.0"
},
"scripts": {
"test": [
- "parallel-lint . --exclude vendor"
+ "parallel-lint . --exclude vendor",
+ "phpcs -v -s"
]
}
}
diff --git a/phpcs.xml b/phpcs.xml
new file mode 100644
index 0000000..32fdead
--- /dev/null
+++ b/phpcs.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<ruleset>
+ <rule ref="vendor/mediawiki/mediawiki-codesniffer/MediaWiki"/>
+ <file>.</file>
+ <arg name="extensions" value="php,php5,inc"/>
+ <arg name="encoding" value="utf8"/>
+ <exclude-pattern>MwEmbedModules/MwEmbedSupport</exclude-pattern>
+ <exclude-pattern>vendor</exclude-pattern>
+</ruleset>
--
To view, visit https://gerrit.wikimedia.org/r/247052
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Id1d9b40ebd536108f11be2eff8f1387180ad40e4
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/MwEmbedSupport
Gerrit-Branch: master
Gerrit-Owner: Paladox <[email protected]>
Gerrit-Reviewer: Brion VIBBER <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: TheDJ <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits