jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/364116 )
Change subject: Break long lines
......................................................................
Break long lines
Change-Id: I569a62cbb1b3655f1ff87b5da5c1287e9bc8b4eb
---
M backend/MWOAuthConsumer.php
M backend/MWOAuthDataStore.php
M backend/MWOAuthException.php
M backend/MWOAuthServer.php
M control/MWOAuthConsumerSubmitControl.php
M examples/testClient.php
M frontend/MWOAuthUI.hooks.php
M frontend/specialpages/SpecialMWOAuth.php
M frontend/specialpages/SpecialMWOAuthConsumerRegistration.php
M frontend/specialpages/SpecialMWOAuthManageMyGrants.php
M maintenance/importCentralWikiLogs.php
M maintenance/migrateCentralWiki.php
M phpcs.xml
13 files changed, 92 insertions(+), 38 deletions(-)
Approvals:
Legoktm: Looks good to me, approved
jenkins-bot: Verified
diff --git a/backend/MWOAuthConsumer.php b/backend/MWOAuthConsumer.php
index 982b6e6..976bdce 100644
--- a/backend/MWOAuthConsumer.php
+++ b/backend/MWOAuthConsumer.php
@@ -45,7 +45,10 @@
protected $version;
/** @var string OAuth callback URL for authorization step*/
protected $callbackUrl;
- /** @var int OAuth callback URL is a prefix and we allow all URLs which
have callbackUrl as the prefix */
+ /**
+ * @var int OAuth callback URL is a prefix and we allow all URLs which
+ * have callbackUrl as the prefix
+ */
protected $callbackIsPrefix;
/** @var string Application description */
protected $description;
diff --git a/backend/MWOAuthDataStore.php b/backend/MWOAuthDataStore.php
index b0ac61b..68fef92 100644
--- a/backend/MWOAuthDataStore.php
+++ b/backend/MWOAuthDataStore.php
@@ -24,7 +24,9 @@
*/
public function __construct( \DBConnRef $centralSlave, $centralMaster,
\BagOStuff $cache ) {
if ( $centralMaster !== null && !( $centralMaster instanceof
\DBConnRef ) ) {
- throw new \InvalidArgumentException( __METHOD__ . ':
$centralMaster must be a DB or null' );
+ throw new \InvalidArgumentException(
+ __METHOD__ . ': $centralMaster must be a DB or
null'
+ );
}
$this->centralSlave = $centralSlave;
$this->centralMaster = $centralMaster;
@@ -138,8 +140,12 @@
public function new_request_token( $consumer, $callback = 'oob' ) {
$token = MWOAuthDataStore::newToken();
$cacheConsumerKey = MWOAuthUtils::getCacheKey( 'consumer',
'request', $token->key );
- $cacheTokenKey = MWOAuthUtils::getCacheKey( 'token',
$consumer->key, 'request', $token->key );
- $cacheCallbackKey = MWOAuthUtils::getCacheKey( 'callback',
$consumer->key, 'request', $token->key );
+ $cacheTokenKey = MWOAuthUtils::getCacheKey(
+ 'token', $consumer->key, 'request', $token->key
+ );
+ $cacheCallbackKey = MWOAuthUtils::getCacheKey(
+ 'callback', $consumer->key, 'request', $token->key
+ );
$this->cache->add( $cacheConsumerKey, $consumer->key, 600 ); //
10 minutes. Kindof arbitray.
$this->cache->add( $cacheTokenKey, $token, 600 ); // 10
minutes. Kindof arbitray.
$this->cache->add( $cacheCallbackKey, $callback, 600 ); // 10
minutes. Kindof arbitray.
diff --git a/backend/MWOAuthException.php b/backend/MWOAuthException.php
index da050f4..7d1b0ae 100644
--- a/backend/MWOAuthException.php
+++ b/backend/MWOAuthException.php
@@ -13,7 +13,9 @@
function __construct( $msg, $params = null ) {
$this->msg = $msg;
$this->params = $params;
- parent::__construct( wfMessage( $msg, $params )->inLanguage(
'en' )->useDatabase( false )->plain() );
+ parent::__construct(
+ wfMessage( $msg, $params )->inLanguage( 'en'
)->useDatabase( false )->plain()
+ );
}
}
diff --git a/backend/MWOAuthServer.php b/backend/MWOAuthServer.php
index ede505f..f98e6c4 100644
--- a/backend/MWOAuthServer.php
+++ b/backend/MWOAuthServer.php
@@ -111,7 +111,8 @@
// Host must match exactly
$knownCallback['host'] === $reqCallback['host'] &&
// Port must be either missing from both or an exact
match
- static::getOrNull( 'port', $knownCallback ) ===
static::getorNull( 'port', $reqCallback ) &&
+ static::getOrNull( 'port', $knownCallback ) ===
+ static::getOrNull( 'port', $reqCallback ) &&
// Path must be an exact match if query is provided in
the
// registered callback. Otherwise it must be a prefix
match if
// provided in the registered callback or anything if
no path was
@@ -357,8 +358,11 @@
$requestToken->addAccessKey( $accessToken->key );
$this->data_store->updateRequestToken( $requestToken, $consumer
);
- $this->logger->debug( "Verification code
{$requestToken->getVerifyCode()} for $requestTokenKey (client: $consumerKey)" );
- return $consumer->generateCallbackUrl( $this->data_store,
$requestToken->getVerifyCode(), $requestTokenKey );
+ $this->logger->debug( "Verification code
{$requestToken->getVerifyCode()} for " .
+ "$requestTokenKey (client: $consumerKey)" );
+ return $consumer->generateCallbackUrl(
+ $this->data_store, $requestToken->getVerifyCode(),
$requestTokenKey
+ );
}
/**
diff --git a/control/MWOAuthConsumerSubmitControl.php
b/control/MWOAuthConsumerSubmitControl.php
index b3e351a..bd3cf39 100644
--- a/control/MWOAuthConsumerSubmitControl.php
+++ b/control/MWOAuthConsumerSubmitControl.php
@@ -237,7 +237,9 @@
$cmr->save( $dbw );
if ( $cmr->get( 'ownerOnly' ) ) {
- $this->makeLogEntry( $dbw, $cmr,
'create-owner-only', $user, $this->vals['description'] );
+ $this->makeLogEntry(
+ $dbw, $cmr, 'create-owner-only', $user,
$this->vals['description']
+ );
} else {
$this->makeLogEntry( $dbw, $cmr, $action,
$user, $this->vals['description'] );
$this->notify( $cmr, $user, $action, null );
@@ -460,7 +462,9 @@
* @param \User $performer
* @param string $comment
*/
- protected function makeLogEntry( $dbw, MWOAuthConsumer $cmr, $action,
\User $performer, $comment ) {
+ protected function makeLogEntry(
+ $dbw, MWOAuthConsumer $cmr, $action, \User $performer, $comment
+ ) {
$logEntry = new \ManualLogEntry( 'mwoauthconsumer', $action );
$logEntry->setPerformer( $performer );
$logEntry->setTarget( $this->getLogTitle( $dbw, $cmr->get(
'userId' ) ) );
diff --git a/examples/testClient.php b/examples/testClient.php
index f80a0d0..dc39d7e 100644
--- a/examples/testClient.php
+++ b/examples/testClient.php
@@ -147,6 +147,7 @@
$token = json_decode( $data );
+// @codingStandardsIgnoreStart
print <<<HELPTEXT
Response body should be a JSON object with three keys:
@@ -173,6 +174,7 @@
HELPTEXT;
+// @codingStandardsIgnoreEnd
// ACCESS TOKEN
print 'What was the "verification value" the MediaWiki installation
gave?'.PHP_EOL;
diff --git a/frontend/MWOAuthUI.hooks.php b/frontend/MWOAuthUI.hooks.php
index c7c0f48..52276a6 100644
--- a/frontend/MWOAuthUI.hooks.php
+++ b/frontend/MWOAuthUI.hooks.php
@@ -180,7 +180,9 @@
* @param array &$notificationCategories
* @param array &$icons
*/
- public static function onBeforeCreateEchoEvent( &$notifications,
&$notificationCategories, &$icons ) {
+ public static function onBeforeCreateEchoEvent(
+ &$notifications, &$notificationCategories, &$icons
+ ) {
global $wgOAuthGroupsToNotify;
if ( !MWOAuthUtils::isCentralWiki() ) {
diff --git a/frontend/specialpages/SpecialMWOAuth.php
b/frontend/specialpages/SpecialMWOAuth.php
index 5367fc1..0960474 100644
--- a/frontend/specialpages/SpecialMWOAuth.php
+++ b/frontend/specialpages/SpecialMWOAuth.php
@@ -51,7 +51,9 @@
$format = $request->getVal( 'format', 'raw' );
try {
- if ( $wgMWOAuthReadOnly && !in_array( $subpage, [
'verified', 'grants', 'identify' ] ) ) {
+ if ( $wgMWOAuthReadOnly &&
+ !in_array( $subpage, [ 'verified', 'grants',
'identify' ] )
+ ) {
throw new MWOAuthException(
'mwoauth-db-readonly' );
}
@@ -109,7 +111,9 @@
&& $request->detectProtocol()
== 'http'
&& substr( wfExpandUrl( '/',
PROTO_HTTPS ), 0, 8 ) === 'https://'
) {
- $redirUrl = str_replace(
'http://', 'https://', $request->getFullRequestURL() );
+ $redirUrl = str_replace(
+ 'http://', 'https://',
$request->getFullRequestURL()
+ );
$this->getOutput()->redirect(
$redirUrl );
$this->getOutput()->addVaryHeader( 'X-Forwarded-Proto' );
break;
@@ -160,7 +164,9 @@
$localUser =
MWOAuthUtils::getLocalUserFromCentralId( $access->get( 'userId' ) );
if ( !$localUser ||
!$localUser->isLoggedIn() ) {
throw new MWOAuthException(
'mwoauth-invalid-authorization-invalid-user' );
- } elseif ( $localUser->isLocked() ||
$wgBlockDisablesLogin && $localUser->isBlocked() ) {
+ } elseif ( $localUser->isLocked() ||
+ $wgBlockDisablesLogin &&
$localUser->isBlocked()
+ ) {
throw new MWOAuthException(
'mwoauth-invalid-authorization-blocked-user' );
}
// Access token is for this wiki
@@ -194,7 +200,8 @@
$format
);
} else {
- $owner =
MWOAuthUtils::getCentralUserNameFromId( $cmr->get( 'userId' ), $this->getUser()
);
+ $owner =
MWOAuthUtils::getCentralUserNameFromId(
+ $cmr->get( 'userId' ),
$this->getUser() );
$this->showError(
wfMessage(
'mwoauth-bad-request-invalid-action-contact',
MWOAuthUtils::getCentralUserTalk( $owner )
@@ -204,10 +211,12 @@
}
}
} catch ( MWOAuthException $exception ) {
- $this->logger->warning( __METHOD__ . ": Exception " .
$exception->getMessage(), [ 'exception' => $exception ] );
+ $this->logger->warning( __METHOD__ . ": Exception " .
$exception->getMessage(),
+ [ 'exception' => $exception ] );
$this->showError( wfMessage( $exception->msg,
$exception->params ), $format );
} catch ( OAuthException $exception ) {
- $this->logger->warning( __METHOD__ . ": Exception " .
$exception->getMessage(), [ 'exception' => $exception ] );
+ $this->logger->warning( __METHOD__ . ": Exception " .
$exception->getMessage(),
+ [ 'exception' => $exception ] );
$this->showError(
wfMessage( 'mwoauth-oauth-exception',
$exception->getMessage() ),
$format
@@ -332,7 +341,9 @@
if ( $existing && $authenticate &&
$existing->get( 'wiki' ) === $cmr->get( 'wiki' ) &&
$existing->get( 'grants' ) === $cmr->get( 'grants' ) &&
- !array_diff( $existing->get( 'grants' ), [
'mwoauth-authonly', 'mwoauth-authonlyprivate' ] )
+ !array_diff(
+ $existing->get( 'grants' ), [
'mwoauth-authonly', 'mwoauth-authonlyprivate' ]
+ )
) {
$callback = $oauthServer->authorize(
$consumerKey,
@@ -344,7 +355,9 @@
return;
}
- $this->getOutput()->addModuleStyles( [ 'mediawiki.ui',
'mediawiki.ui.button', 'ext.MWOAuth.AuthorizeForm' ] );
+ $this->getOutput()->addModuleStyles(
+ [ 'mediawiki.ui', 'mediawiki.ui.button',
'ext.MWOAuth.AuthorizeForm' ]
+ );
$this->getOutput()->addModules( 'ext.MWOAuth.AuthorizeDialog' );
$control = new MWOAuthConsumerAcceptanceSubmitControl(
$this->getContext(), [], $dbr );
@@ -393,13 +406,15 @@
$params = [
$this->getUser()->getName(),
$cmr->get( 'name' ),
- $cmr->get( 'userId',
'MediaWiki\Extensions\OAuth\MWOAuthUtils::getCentralUserNameFromId' ),
+ $cmr->get( 'userId',
+
'MediaWiki\Extensions\OAuth\MWOAuthUtils::getCentralUserNameFromId' ),
];
if ( $cmr->get( 'wiki' ) === '*' ) {
$msgKey .= '-allwikis';
} else {
$msgKey .= '-onewiki';
- $params[] = $cmr->get( 'wiki',
'MediaWiki\Extensions\OAuth\MWOAuthUtils::getWikiIdName' );
+ $params[] = $cmr->get( 'wiki',
+
'MediaWiki\Extensions\OAuth\MWOAuthUtils::getWikiIdName' );
}
$grantsText = \MWGrants::getGrantsWikiText( $cmr->get( 'grants'
), $this->getLanguage() );
if ( $grantsText === "\n" ) {
diff --git a/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php
b/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php
index d918871..99ce3f3 100644
--- a/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php
+++ b/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php
@@ -147,7 +147,8 @@
'type' => $allWikis ?
'combobox' : 'select',
'options' => [
wfMessage(
'mwoauth-consumer-allwikis' )->escaped() => '*',
- wfMessage(
'mwoauth-consumer-wiki-thiswiki', wfWikiID() )->escaped() => wfWikiID()
+ wfMessage(
'mwoauth-consumer-wiki-thiswiki', wfWikiID() )
+ ->escaped() =>
wfWikiID()
] + array_flip( $allWikis ),
'label-message' =>
'mwoauth-consumer-wiki',
'required' => true,
@@ -182,7 +183,8 @@
return
$lang->semicolonList( array_map(
'\User::getRightDescription', $rights ) );
},
-
array_intersect_key( \MWGrants::getRightsByGrant(), array_flip( $showGrants ) )
+
array_intersect_key(
+
\MWGrants::getRightsByGrant(), array_flip( $showGrants ) )
)
),
'force-options-on' => array_map(
@@ -222,7 +224,8 @@
function ( array $data, \IContextSource
$context ) use ( $control ) {
$data['grants'] = \FormatJson::encode(
// adapt form to controller
preg_replace( '/^grant-/', '',
$data['grants'] ) );
- // 'callbackUrl' must be present,
otherwise MWOAuthSubmitControl::validateFields() fails.
+ // 'callbackUrl' must be present,
+ // otherwise
MWOAuthSubmitControl::validateFields() fails.
if ( $data['ownerOnly'] && !isset(
$data['callbackUrl'] ) ) {
$data['callbackUrl'] = '';
}
@@ -241,7 +244,8 @@
$cmr = $status->value['result']['consumer'];
if ( $cmr->get( 'ownerOnly' ) ) {
$cmra =
$status->value['result']['acceptance'];
- $this->getOutput()->addWikiMsg(
'mwoauthconsumerregistration-created-owner-only',
+ $this->getOutput()->addWikiMsg(
+
'mwoauthconsumerregistration-created-owner-only',
$cmr->get( 'consumerKey' ),
MWOAuthUtils::hmacDBSecret(
$cmr->get( 'secretKey' ) ),
$cmra->get( 'accessToken' ),
@@ -344,7 +348,8 @@
if ( $oldSecretKey !== $curSecretKey ) { //
token reset?
if ( $cmr->get( 'ownerOnly' ) ) {
$cmra =
$status->value['result']['acceptance'];
- $this->getOutput()->addWikiMsg(
'mwoauthconsumerregistration-secretreset-owner-only',
+ $this->getOutput()->addWikiMsg(
+
'mwoauthconsumerregistration-secretreset-owner-only',
$cmr->get(
'consumerKey' ),
MWOAuthUtils::hmacDBSecret( $curSecretKey ),
$cmra->get(
'accessToken' ),
@@ -466,7 +471,8 @@
} )
),
// Messages: mwoauth-consumer-stage-proposed,
mwoauth-consumer-stage-rejected,
- // mwoauth-consumer-stage-expired,
mwoauth-consumer-stage-approved, mwoauth-consumer-stage-disabled
+ // mwoauth-consumer-stage-expired,
mwoauth-consumer-stage-approved,
+ // mwoauth-consumer-stage-disabled
'mwoauthconsumerregistration-stage' =>
$this->msg( "mwoauth-consumer-stage-$stageKey"
)->escaped(),
'mwoauthconsumerregistration-description' =>
htmlspecialchars(
diff --git a/frontend/specialpages/SpecialMWOAuthManageMyGrants.php
b/frontend/specialpages/SpecialMWOAuthManageMyGrants.php
index 15b6e68..d582a17 100644
--- a/frontend/specialpages/SpecialMWOAuthManageMyGrants.php
+++ b/frontend/specialpages/SpecialMWOAuthManageMyGrants.php
@@ -175,9 +175,12 @@
$cmra->get( 'grants' )
),
'tooltips' => [
- \MWGrants::getGrantsLink(
'basic' ) => $this->msg( 'mwoauthmanagemygrants-basic-tooltip' )->text(),
- \MWGrants::getGrantsLink(
'mwoauth-authonly' ) => $this->msg( 'mwoauthmanagemygrants-authonly-tooltip'
)->text(),
- \MWGrants::getGrantsLink(
'mwoauth-authonlyprivate' ) => $this->msg(
'mwoauthmanagemygrants-authonly-tooltip' )->text(),
+ \MWGrants::getGrantsLink(
'basic' ) =>
+ $this->msg(
'mwoauthmanagemygrants-basic-tooltip' )->text(),
+ \MWGrants::getGrantsLink(
'mwoauth-authonly' ) =>
+ $this->msg(
'mwoauthmanagemygrants-authonly-tooltip' )->text(),
+ \MWGrants::getGrantsLink(
'mwoauth-authonlyprivate' ) =>
+ $this->msg(
'mwoauthmanagemygrants-authonly-tooltip' )->text(),
],
'force-options-on' => array_map(
function ( $g ) {
@@ -231,7 +234,8 @@
$status = $form->show();
if ( $status instanceof \Status && $status->isOk() ) {
- // Messages: mwoauthmanagemygrants-success-update,
mwoauthmanagemygrants-success-renounce
+ // Messages: mwoauthmanagemygrants-success-update,
+ // mwoauthmanagemygrants-success-renounce
$this->getOutput()->addWikiMsg(
"mwoauthmanagemygrants-success-$action" );
}
}
diff --git a/maintenance/importCentralWikiLogs.php
b/maintenance/importCentralWikiLogs.php
index 8f38893..da0bd98 100644
--- a/maintenance/importCentralWikiLogs.php
+++ b/maintenance/importCentralWikiLogs.php
@@ -55,7 +55,8 @@
// This assumes that we don't have more than mBatchSize
oauth log entries
// with the same timestamp. Otherwise this will go into
an infinite loop.
if ( $lastMinTimestamp !== null ) {
- $conds[] = 'log_timestamp < ' .
$oldDb->addQuotes( $oldDb->timestamp( $lastMinTimestamp ) );
+ $conds[] = 'log_timestamp < ' .
+ $oldDb->addQuotes( $oldDb->timestamp(
$lastMinTimestamp ) );
}
$oldLoggs = $oldDb->select(
@@ -82,7 +83,8 @@
}
$extra = $oldLoggs->fetchObject();
if ( $last->log_timestamp ===
$extra->log_timestamp ) {
- $this->error( "We hit an edge case.
Please increase the batch size and restart the transfer.\n", 1 );
+ $this->error( "We hit an edge case.
Please increase the batch " .
+ " size and restart the
transfer.\n", 1 );
}
$oldLoggs->rewind();
}
@@ -99,7 +101,9 @@
$this->output( "Migrating log
{$row->log_id}...\n" );
$logUser = User::newFromName(
$row->log_user_text );
if ( !$logUser->getId() ) {
- $this->output( "Cannot transfer log_id:
{$row->log_id}, the log user doesn't exist" );
+ $this->output(
+ "Cannot transfer log_id:
{$row->log_id}, the log user doesn't exist"
+ );
continue;
}
$params = unserialize( $row->log_params );
diff --git a/maintenance/migrateCentralWiki.php
b/maintenance/migrateCentralWiki.php
index 2b9ddfa..dc846a1 100644
--- a/maintenance/migrateCentralWiki.php
+++ b/maintenance/migrateCentralWiki.php
@@ -28,10 +28,12 @@
class MigrateCentralWiki extends \Maintenance {
public function __construct() {
parent::__construct();
- $this->mDescription = "Migrate central wiki from one wiki to
another. OAuth should be in Read Only mode while this is running.";
+ $this->mDescription = "Migrate central wiki from one wiki to
another. " .
+ "OAuth should be in Read Only mode while this is
running.";
$this->addOption( 'old', 'Previous central wiki', true, true );
$this->addOption( 'target', 'New central wiki', true, true );
- $this->addOption( 'table', 'Table name
(oauth_registered_consumer or oauth_accepted_consumer)', true, true );
+ $this->addOption( 'table',
+ 'Table name (oauth_registered_consumer or
oauth_accepted_consumer)', true, true );
$this->setBatchSize( 200 );
$this->requireExtension( "OAuth" );
}
@@ -50,7 +52,8 @@
$cmrClass =
'MediaWiki\Extensions\OAuth\MWOAuthConsumerAcceptance';
$type = 'grant';
} else {
- $this->error( "Invalid table name. Must be one of
'oauth_registered_consumer' or 'oauth_accepted_consumer'.\n", 1 );
+ $this->error( "Invalid table name. Must be one of
'oauth_registered_consumer' " .
+ "or 'oauth_accepted_consumer'.\n", 1 );
}
$oldDb = wfGetLB( $oldWiki )->getConnectionRef( DB_MASTER, [],
$oldWiki );
diff --git a/phpcs.xml b/phpcs.xml
index 5404ce4..993adc5 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.TooLong" />
<exclude
name="MediaWiki.Commenting.FunctionComment.MissingDocumentationPublic"/>
<exclude
name="MediaWiki.Commenting.FunctionComment.MissingDocumentationProtected"/>
<exclude
name="MediaWiki.Commenting.FunctionComment.MissingParamComment"/>
--
To view, visit https://gerrit.wikimedia.org/r/364116
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I569a62cbb1b3655f1ff87b5da5c1287e9bc8b4eb
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/OAuth
Gerrit-Branch: master
Gerrit-Owner: Umherirrender <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits