jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/402152 )
Change subject: Use namespaced version of DBError, DBConnRef and IDatabase ...................................................................... Use namespaced version of DBError, DBConnRef and IDatabase Change-Id: I5811ec246a14c482559e97cdd786fe99239ec890 --- M api/MWOAuthSessionProvider.php M backend/MWOAuthConsumer.php M backend/MWOAuthConsumerAcceptance.php M backend/MWOAuthDAO.php M backend/MWOAuthDataStore.php M backend/MWOAuthUtils.php M control/MWOAuthConsumerAcceptanceSubmitControl.php M control/MWOAuthConsumerSubmitControl.php M frontend/specialpages/SpecialMWOAuthConsumerRegistration.php M frontend/specialpages/SpecialMWOAuthListConsumers.php M frontend/specialpages/SpecialMWOAuthManageConsumers.php M frontend/specialpages/SpecialMWOAuthManageMyGrants.php 12 files changed, 83 insertions(+), 60 deletions(-) Approvals: Legoktm: Looks good to me, approved jenkins-bot: Verified diff --git a/api/MWOAuthSessionProvider.php b/api/MWOAuthSessionProvider.php index f821e65..c86d62c 100644 --- a/api/MWOAuthSessionProvider.php +++ b/api/MWOAuthSessionProvider.php @@ -7,6 +7,7 @@ use MediaWiki\Session\SessionInfo; use MediaWiki\Session\UserInfo; use WebRequest; +use Wikimedia\Rdbms\DBError; /** * Session provider for OAuth @@ -180,7 +181,7 @@ [ 'oaac_user_id' => $id ], __METHOD__ ); - } catch ( \DBError $e ) { + } catch ( DBError $e ) { $dbw->rollback( __METHOD__ ); throw $e; } diff --git a/backend/MWOAuthConsumer.php b/backend/MWOAuthConsumer.php index 98ae243..9ef778d 100644 --- a/backend/MWOAuthConsumer.php +++ b/backend/MWOAuthConsumer.php @@ -2,6 +2,8 @@ namespace MediaWiki\Extensions\OAuth; +use Wikimedia\Rdbms\DBConnRef; + /** * (c) Aaron Schulz 2013, GPL * @@ -158,12 +160,12 @@ } /** - * @param \DBConnRef $db + * @param DBConnRef $db * @param string $key * @param int $flags MWOAuthConsumer::READ_* bitfield * @return MWOAuthConsumer|bool */ - public static function newFromKey( \DBConnRef $db, $key, $flags = 0 ) { + public static function newFromKey( DBConnRef $db, $key, $flags = 0 ) { $row = $db->selectRow( static::getTable(), array_values( static::getFieldColumnMap() ), [ 'oarc_consumer_key' => (string)$key ], @@ -181,7 +183,7 @@ } /** - * @param \DBConnRef $db + * @param DBConnRef $db * @param string $name * @param string $version * @param int $userId Central user ID @@ -189,7 +191,7 @@ * @return MWOAuthConsumer|bool */ public static function newFromNameVersionUser( - \DBConnRef $db, $name, $version, $userId, $flags = 0 + DBConnRef $db, $name, $version, $userId, $flags = 0 ) { $row = $db->selectRow( static::getTable(), array_values( static::getFieldColumnMap() ), @@ -283,7 +285,7 @@ $this->grants = (array)$this->grants; // sanity } - protected function encodeRow( \DBConnRef $db, $row ) { + protected function encodeRow( DBConnRef $db, $row ) { // For compatibility with other wikis in the farm, un-remap some grants foreach ( self::$mapBackCompatGrants as $old => $new ) { while ( ( $i = array_search( $new, $row['oarc_grants'], true ) ) !== false ) { @@ -300,7 +302,7 @@ return $row; } - protected function decodeRow( \DBConnRef $db, $row ) { + protected function decodeRow( DBConnRef $db, $row ) { $row['oarc_registration'] = wfTimestamp( TS_MW, $row['oarc_registration'] ); $row['oarc_stage_timestamp'] = wfTimestamp( TS_MW, $row['oarc_stage_timestamp'] ); $row['oarc_restrictions'] = \MWRestrictions::newFromJson( $row['oarc_restrictions'] ); diff --git a/backend/MWOAuthConsumerAcceptance.php b/backend/MWOAuthConsumerAcceptance.php index 27969ec..d0ec980 100644 --- a/backend/MWOAuthConsumerAcceptance.php +++ b/backend/MWOAuthConsumerAcceptance.php @@ -2,6 +2,8 @@ namespace MediaWiki\Extensions\OAuth; +use Wikimedia\Rdbms\DBConnRef; + /** (c) Aaron Schulz 2013, GPL @@ -73,12 +75,12 @@ } /** - * @param \DBConnRef $db + * @param DBConnRef $db * @param string $token Access token * @param int $flags MWOAuthConsumerAcceptance::READ_* bitfield * @return MWOAuthConsumerAcceptance|bool */ - public static function newFromToken( \DBConnRef $db, $token, $flags = 0 ) { + public static function newFromToken( DBConnRef $db, $token, $flags = 0 ) { $row = $db->selectRow( static::getTable(), array_values( static::getFieldColumnMap() ), [ 'oaac_access_token' => (string)$token ], @@ -96,7 +98,7 @@ } /** - * @param \DBConnRef $db + * @param DBConnRef $db * @param String $userId of user who authorized (central wiki's id) * @param MWOAuthConsumer $consumer * @param String $wiki wiki associated with the acceptance @@ -104,7 +106,7 @@ * @return MWOAuthConsumerAcceptance|bool */ public static function newFromUserConsumerWiki( - \DBConnRef $db, $userId, $consumer, $wiki, $flags = 0 + DBConnRef $db, $userId, $consumer, $wiki, $flags = 0 ) { $row = $db->selectRow( static::getTable(), array_values( static::getFieldColumnMap() ), @@ -133,7 +135,7 @@ $this->grants = (array)$this->grants; // sanity } - protected function encodeRow( \DBConnRef $db, $row ) { + protected function encodeRow( DBConnRef $db, $row ) { // For compatibility with other wikis in the farm, un-remap some grants foreach ( MWOAuthConsumer::$mapBackCompatGrants as $old => $new ) { while ( ( $i = array_search( $new, $row['oaac_grants'], true ) ) !== false ) { @@ -146,7 +148,7 @@ return $row; } - protected function decodeRow( \DBConnRef $db, $row ) { + protected function decodeRow( DBConnRef $db, $row ) { $row['oaac_grants'] = \FormatJson::decode( $row['oaac_grants'], true ); $row['oaac_accepted'] = wfTimestamp( TS_MW, $row['oaac_accepted'] ); diff --git a/backend/MWOAuthDAO.php b/backend/MWOAuthDAO.php index 0bf8f14..d0f7a88 100644 --- a/backend/MWOAuthDAO.php +++ b/backend/MWOAuthDAO.php @@ -2,6 +2,9 @@ namespace MediaWiki\Extensions\OAuth; +use Wikimedia\Rdbms\DBConnRef; +use Wikimedia\Rdbms\DBError; + /** * (c) Aaron Schulz 2013, GPL * @@ -55,24 +58,24 @@ } /** - * @param \DBConnRef $db + * @param DBConnRef $db * @param array|\stdClass $row * @return MWOAuthDAO */ - final public static function newFromRow( \DBConnRef $db, $row ) { + final public static function newFromRow( DBConnRef $db, $row ) { $consumer = new static(); $consumer->loadFromRow( $db, $row ); return $consumer; } /** - * @param \DBConnRef $db + * @param DBConnRef $db * @param int $id * @param int $flags MWOAuthDAO::READ_* bitfield * @return MWOAuthDAO|bool Returns false if not found - * @throws \DBError + * @throws DBError */ - final public static function newFromId( \DBConnRef $db, $id, $flags = 0 ) { + final public static function newFromId( DBConnRef $db, $id, $flags = 0 ) { $row = $db->selectRow( static::getTable(), array_values( static::getFieldColumnMap() ), [ static::getIdColumn() => (int)$id ], @@ -147,12 +150,12 @@ } /** - * @param \DBConnRef $dbw + * @param DBConnRef $dbw * @return bool - * @throws \DBError + * @throws DBError * @throws \MWException */ - public function save( \DBConnRef $dbw ) { + public function save( DBConnRef $dbw ) { $uniqueId = $this->getIdValue(); $idColumn = static::getIdColumn(); if ( !empty( $dbw->daoReadOnly ) ) { @@ -197,11 +200,11 @@ } /** - * @param \DBConnRef $dbw + * @param DBConnRef $dbw * @return bool * @throws \MWException */ - public function delete( \DBConnRef $dbw ) { + public function delete( DBConnRef $dbw ) { $uniqueId = $this->getIdValue(); $idColumn = static::getIdColumn(); if ( !empty( $dbw->daoReadOnly ) ) { @@ -339,11 +342,11 @@ abstract protected function normalizeValues(); /** - * @param \DBConnRef $db + * @param DBConnRef $db * @param \stdClass|array $row * @return void */ - final protected function loadFromRow( \DBConnRef $db, $row ) { + final protected function loadFromRow( DBConnRef $db, $row ) { $row = $this->decodeRow( $db, (array)$row ); $values = []; foreach ( static::getFieldColumnMap() as $field => $column ) { @@ -358,28 +361,28 @@ * Subclasses should make this to encode DB fields (e.g. timestamps). * This must also flatten any PHP data structures into flat values. * - * @param \DBConnRef $db + * @param DBConnRef $db * @param array $row * @return array */ - abstract protected function encodeRow( \DBConnRef $db, $row ); + abstract protected function encodeRow( DBConnRef $db, $row ); /** * Subclasses should make this to decode DB fields (e.g. timestamps). * This can also expand some flat values (e.g. JSON) into PHP data structures. * Note: this does not need to handle what normalizeValues() already does. * - * @param \DBConnRef $db + * @param DBConnRef $db * @param array $row * @return array */ - abstract protected function decodeRow( \DBConnRef $db, $row ); + abstract protected function decodeRow( DBConnRef $db, $row ); /** - * @param \DBConnRef $db + * @param DBConnRef $db * @return array */ - final protected function getRowArray( \DBConnRef $db ) { + final protected function getRowArray( DBConnRef $db ) { $row = []; foreach ( static::getFieldColumnMap() as $field => $column ) { $row[$column] = $this->$field; diff --git a/backend/MWOAuthDataStore.php b/backend/MWOAuthDataStore.php index 6672769..3cd88ab 100644 --- a/backend/MWOAuthDataStore.php +++ b/backend/MWOAuthDataStore.php @@ -3,11 +3,12 @@ namespace MediaWiki\Extensions\OAuth; use MediaWiki\Logger\LoggerFactory; +use Wikimedia\Rdbms\DBConnRef; class MWOAuthDataStore extends OAuthDataStore { - /** @var \DBConnRef DB for the consumer/grant registry */ + /** @var DBConnRef DB for the consumer/grant registry */ protected $centralSlave; - /** @var \DBConnRef|null Master DB for repeated lookup in case of replication lag problems; + /** @var DBConnRef|null Master DB for repeated lookup in case of replication lag problems; * null if there is no separate master and slave DB */ protected $centralMaster; /** @var \BagOStuff Cache for Tokens and Nonces */ @@ -17,12 +18,12 @@ protected $logger; /** - * @param \DBConnRef $centralSlave Central DB slave - * @param \DBConnRef|null $centralMaster Central DB master (if different) + * @param DBConnRef $centralSlave Central DB slave + * @param DBConnRef|null $centralMaster Central DB master (if different) * @param \BagOStuff $cache */ - public function __construct( \DBConnRef $centralSlave, $centralMaster, \BagOStuff $cache ) { - if ( $centralMaster !== null && !( $centralMaster instanceof \DBConnRef ) ) { + 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' ); diff --git a/backend/MWOAuthUtils.php b/backend/MWOAuthUtils.php index 285fd9f..75f7612 100644 --- a/backend/MWOAuthUtils.php +++ b/backend/MWOAuthUtils.php @@ -5,6 +5,8 @@ use EchoEvent; use Hooks; use User; +use Wikimedia\Rdbms\DBConnRef; +use Wikimedia\Rdbms\IDatabase; /** * Static utility functions for OAuth @@ -24,7 +26,7 @@ /** * @param int $index DB_MASTER/DB_REPLICA - * @return \DBConnRef + * @return DBConnRef */ public static function getCentralDB( $index ) { global $wgMWOAuthCentralWiki, $wgMWOAuthReadOnly; @@ -44,10 +46,10 @@ } /** - * @param \DBConnRef $db + * @param DBConnRef $db * @return array */ - public static function getConsumerStateCounts( \DBConnRef $db ) { + public static function getConsumerStateCounts( DBConnRef $db ) { $res = $db->select( 'oauth_registered_consumer', [ 'oarc_stage', 'count' => 'COUNT(*)' ], [], @@ -116,10 +118,10 @@ } /** - * @param \DBConnRef $dbw + * @param DBConnRef $dbw * @return void */ - public static function runAutoMaintenance( \DBConnRef $dbw ) { + public static function runAutoMaintenance( DBConnRef $dbw ) { global $wgMWOAuthRequestExpirationAge; if ( $wgMWOAuthRequestExpirationAge <= 0 ) { @@ -131,7 +133,7 @@ new \AutoCommitUpdate( $dbw, __METHOD__, - function ( \IDatabase $dbw ) use ( $cutoff ) { + function ( IDatabase $dbw ) use ( $cutoff ) { $dbw->update( 'oauth_registered_consumer', [ diff --git a/control/MWOAuthConsumerAcceptanceSubmitControl.php b/control/MWOAuthConsumerAcceptanceSubmitControl.php index 7a90ad3..63b6e26 100644 --- a/control/MWOAuthConsumerAcceptanceSubmitControl.php +++ b/control/MWOAuthConsumerAcceptanceSubmitControl.php @@ -2,6 +2,8 @@ namespace MediaWiki\Extensions\OAuth; +use Wikimedia\Rdbms\DBConnRef; + /** * (c) Aaron Schulz 2013, GPL * @@ -30,15 +32,15 @@ * @TODO: improve error messages */ class MWOAuthConsumerAcceptanceSubmitControl extends MWOAuthSubmitControl { - /** @var \DBConnRef */ + /** @var DBConnRef */ protected $dbw; /** * @param \IContextSource $context * @param array $params - * @param \DBConnRef $dbw Result of MWOAuthUtils::getCentralDB( DB_MASTER ) + * @param DBConnRef $dbw Result of MWOAuthUtils::getCentralDB( DB_MASTER ) */ - public function __construct( \IContextSource $context, array $params, \DBConnRef $dbw ) { + public function __construct( \IContextSource $context, array $params, DBConnRef $dbw ) { parent::__construct( $context, $params ); $this->dbw = $dbw; } diff --git a/control/MWOAuthConsumerSubmitControl.php b/control/MWOAuthConsumerSubmitControl.php index bd3cf39..f3e547f 100644 --- a/control/MWOAuthConsumerSubmitControl.php +++ b/control/MWOAuthConsumerSubmitControl.php @@ -2,6 +2,8 @@ namespace MediaWiki\Extensions\OAuth; +use Wikimedia\Rdbms\DBConnRef; + /** * (c) Aaron Schulz 2013, GPL * @@ -37,15 +39,15 @@ */ public static $actions = [ 'propose', 'update', 'approve', 'reject', 'disable', 'reenable' ]; - /** @var \DBConnRef */ + /** @var DBConnRef */ protected $dbw; /** * @param \IContextSource $context * @param array $params - * @param \DBConnRef $dbw Result of MWOAuthUtils::getCentralDB( DB_MASTER ) + * @param DBConnRef $dbw Result of MWOAuthUtils::getCentralDB( DB_MASTER ) */ - public function __construct( \IContextSource $context, array $params, \DBConnRef $dbw ) { + public function __construct( \IContextSource $context, array $params, DBConnRef $dbw ) { parent::__construct( $context, $params ); $this->dbw = $dbw; } @@ -446,17 +448,17 @@ } /** - * @param \DBConnRef $db + * @param DBConnRef $db * @param int $userId * @return \Title */ - protected function getLogTitle( \DBConnRef $db, $userId ) { + protected function getLogTitle( DBConnRef $db, $userId ) { $name = MWOAuthUtils::getCentralUserNameFromId( $userId ); return \Title::makeTitleSafe( NS_USER, $name ); } /** - * @param \DBConnRef $dbw + * @param DBConnRef $dbw * @param MWOAuthConsumer $cmr * @param string $action * @param \User $performer diff --git a/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php b/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php index 05b8251..71f0024 100644 --- a/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php +++ b/frontend/specialpages/SpecialMWOAuthConsumerRegistration.php @@ -2,6 +2,8 @@ namespace MediaWiki\Extensions\OAuth; +use Wikimedia\Rdbms\DBConnRef; + /** * (c) Aaron Schulz 2013, GPL * @@ -433,11 +435,11 @@ } /** - * @param \DBConnRef $db + * @param DBConnRef $db * @param stdclass $row * @return string */ - public function formatRow( \DBConnRef $db, $row ) { + public function formatRow( DBConnRef $db, $row ) { $cmr = MWOAuthDAOAccessControl::wrap( MWOAuthConsumer::newFromRow( $db, $row ), $this->getContext() ); diff --git a/frontend/specialpages/SpecialMWOAuthListConsumers.php b/frontend/specialpages/SpecialMWOAuthListConsumers.php index 61c6832..f432c87 100644 --- a/frontend/specialpages/SpecialMWOAuthListConsumers.php +++ b/frontend/specialpages/SpecialMWOAuthListConsumers.php @@ -2,6 +2,8 @@ namespace MediaWiki\Extensions\OAuth; +use Wikimedia\Rdbms\DBConnRef; + /** * (c) Aaron Schulz 2013, GPL * @@ -204,11 +206,11 @@ } /** - * @param \DBConnRef $db + * @param DBConnRef $db * @param stdclass $row * @return string */ - public function formatRow( \DBConnRef $db, $row ) { + public function formatRow( DBConnRef $db, $row ) { $cmr = MWOAuthDAOAccessControl::wrap( MWOAuthConsumer::newFromRow( $db, $row ), $this->getContext() ); diff --git a/frontend/specialpages/SpecialMWOAuthManageConsumers.php b/frontend/specialpages/SpecialMWOAuthManageConsumers.php index 6d04ed7..73463e1 100644 --- a/frontend/specialpages/SpecialMWOAuthManageConsumers.php +++ b/frontend/specialpages/SpecialMWOAuthManageConsumers.php @@ -2,6 +2,8 @@ namespace MediaWiki\Extensions\OAuth; +use Wikimedia\Rdbms\DBConnRef; + /** * (c) Aaron Schulz 2013, GPL * @@ -385,11 +387,11 @@ } /** - * @param \DBConnRef $db + * @param DBConnRef $db * @param stdclass $row * @return string */ - public function formatRow( \DBConnRef $db, $row ) { + public function formatRow( DBConnRef $db, $row ) { $cmr = MWOAuthDAOAccessControl::wrap( MWOAuthConsumer::newFromRow( $db, $row ), $this->getContext() ); diff --git a/frontend/specialpages/SpecialMWOAuthManageMyGrants.php b/frontend/specialpages/SpecialMWOAuthManageMyGrants.php index db48ea0..43f5fc8 100644 --- a/frontend/specialpages/SpecialMWOAuthManageMyGrants.php +++ b/frontend/specialpages/SpecialMWOAuthManageMyGrants.php @@ -2,6 +2,8 @@ namespace MediaWiki\Extensions\OAuth; +use Wikimedia\Rdbms\DBConnRef; + /** * (c) Aaron Schulz 2013, GPL * @@ -260,11 +262,11 @@ } /** - * @param \DBConnRef $db + * @param DBConnRef $db * @param stdclass $row * @return string */ - public function formatRow( \DBConnRef $db, $row ) { + public function formatRow( DBConnRef $db, $row ) { $cmr = MWOAuthDAOAccessControl::wrap( MWOAuthConsumer::newFromRow( $db, $row ), $this->getContext() ); $cmra = MWOAuthDAOAccessControl::wrap( -- To view, visit https://gerrit.wikimedia.org/r/402152 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I5811ec246a14c482559e97cdd786fe99239ec890 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/OAuth Gerrit-Branch: master Gerrit-Owner: Umherirrender <umherirrender_de...@web.de> Gerrit-Reviewer: Chad <ch...@wikimedia.org> Gerrit-Reviewer: Gergő Tisza <gti...@wikimedia.org> Gerrit-Reviewer: Legoktm <lego...@member.fsf.org> Gerrit-Reviewer: Thiemo Kreuz (WMDE) <thiemo.kr...@wikimedia.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits