MaxSem has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/359367 )

Change subject: Cleanup: namespace this extension, move stuff into includes
......................................................................

Cleanup: namespace this extension, move stuff into includes

Change-Id: I7cf55685de955912c8637681c397179553d17152
---
M extension.json
R includes/Hooks.php
R includes/LoginNotify.php
R includes/PresentationModel.php
4 files changed, 43 insertions(+), 17 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LoginNotify 
refs/changes/67/359367/1

diff --git a/extension.json b/extension.json
index db0e0d1..99e4a6c 100644
--- a/extension.json
+++ b/extension.json
@@ -25,34 +25,34 @@
                ]
        },
        "AutoloadClasses": {
-               "LoginNotify": "LoginNotify_body.php",
-               "LoginNotifyHooks": "LoginNotify.hooks.php",
-               "LoginNotifyPresentationModel": 
"LoginNotifyPresentationModel.php"
+               "LoginNotify\\LoginNotify": "includes/LoginNotify.php",
+               "LoginNotify\\Hooks": "includes/Hooks.php",
+               "LoginNotify\\PresentationModel": 
"LoginNotifyPresentationModel.php"
        },
        "Hooks": {
                "BeforeCreateEchoEvent": [
-                       "LoginNotifyHooks::onBeforeCreateEchoEvent"
+                       "LoginNotify\\Hooks::onBeforeCreateEchoEvent"
                ],
                "EchoGetBundleRules": [
-                       "LoginNotifyHooks::onEchoGetBundleRules"
+                       "LoginNotify\\Hooks::onEchoGetBundleRules"
                ],
                "LoginAuthenticateAudit": [
                        "LoginNotifyHooks::onLoginAuthenticateAudit"
                ],
                "AuthManagerLoginAuthenticateAudit": [
-                       "LoginNotifyHooks::onAuthManagerLoginAuthenticateAudit"
+                       
"LoginNotify\\Hooks::onAuthManagerLoginAuthenticateAudit"
                ],
                "AddNewAccount": [
-                       "LoginNotifyHooks::onAddNewAccount"
+                       "LoginNotify\\Hooks::onAddNewAccount"
                ],
                "UserLoadOptions": [
-                       "LoginNotifyHooks::onUserLoadOptions"
+                       "LoginNotify\\Hooks::onUserLoadOptions"
                ],
                "UserSaveOptions": [
-                       "LoginNotifyHooks::onUserSaveOptions"
+                       "LoginNotify\\Hooks::onUserSaveOptions"
                ],
                "LocalUserCreated": [
-                       "LoginNotifyHooks::onLocalUserCreated"
+                       "LoginNotify\\Hooks::onLocalUserCreated"
                ]
        },
        "config": {
diff --git a/LoginNotify.hooks.php b/includes/Hooks.php
similarity index 98%
rename from LoginNotify.hooks.php
rename to includes/Hooks.php
index 54c2669..cbf404f 100644
--- a/LoginNotify.hooks.php
+++ b/includes/Hooks.php
@@ -6,9 +6,14 @@
  * @ingroup Extensions
  */
 
-use MediaWiki\Auth\AuthenticationResponse;
+namespace LoginNotify;
 
-class LoginNotifyHooks {
+use EchoAttributeManager;
+use LoginForm;
+use MediaWiki\Auth\AuthenticationResponse;
+use User;
+
+class Hooks {
 
        const OPTIONS_FAKE_TRUTH = 2;
        const OPTIONS_FAKE_FALSE = 'fake-false';
diff --git a/LoginNotify_body.php b/includes/LoginNotify.php
similarity index 96%
rename from LoginNotify_body.php
rename to includes/LoginNotify.php
index b817541..04a8698 100644
--- a/LoginNotify_body.php
+++ b/includes/LoginNotify.php
@@ -6,10 +6,24 @@
  * @ingroup Extensions
  */
 
+namespace LoginNotify;
+
+use BagOStuff;
+use CentralAuthUser;
+use Config;
+use EchoEvent;
+use WebRequest;
+use Wikimedia\Rdbms\Database;
+use Exception;
+use IP;
 use MediaWiki\Logger\LoggerFactory;
+use MWCryptRand;
+use ObjectCache;
 use Psr\Log\LoggerInterface;
 use Psr\Log\LoggerAwareInterface;
-use Wikimedia\Rdbms\DBConnectionError;
+use RequestContext;
+use UnexpectedValueException;
+use User;
 
 /**
  * Handle sending notifications on login from unknown source.
@@ -46,7 +60,7 @@
                $this->cache = $cache;
                $this->config = $cfg;
                // Generate salt just once to avoid duplicate cookies
-               $this->gSalt = Wikimedia\base_convert( 
MWCryptRand::generateHex( 8 ), 16, 36 );
+               $this->gSalt = \Wikimedia\base_convert( 
MWCryptRand::generateHex( 8 ), 16, 36 );
 
                if ( $this->config->get( 'LoginNotifySecretKey' ) !== null ) {
                        $this->secret = $this->config->get( 
'LoginNotifySecretKey' );
@@ -517,7 +531,7 @@
                if ( !is_string( $res ) ) {
                        throw new UnexpectedValueException( "Hash failed" );
                }
-               $encoded = $year . '-' . $salt . '-' . Wikimedia\base_convert( 
$res, 16, 36 );
+               $encoded = $year . '-' . $salt . '-' . \Wikimedia\base_convert( 
$res, 16, 36 );
                return $encoded;
        }
 
@@ -529,7 +543,7 @@
         * @return string The cache key
         */
        private function getKey( User $user, $type ) {
-               $userHash = Wikimedia\base_convert( sha1( $user->getName() ), 
16, 36, 31 );
+               $userHash = \Wikimedia\base_convert( sha1( $user->getName() ), 
16, 36, 31 );
                return $this->cache->makeGlobalKey(
                        'loginnotify', $type, $userHash
                );
diff --git a/LoginNotifyPresentationModel.php b/includes/PresentationModel.php
similarity index 93%
rename from LoginNotifyPresentationModel.php
rename to includes/PresentationModel.php
index e061d50..6bf0470 100644
--- a/LoginNotifyPresentationModel.php
+++ b/includes/PresentationModel.php
@@ -1,5 +1,12 @@
 <?php
-class LoginNotifyPresentationModel extends EchoEventPresentationModel {
+
+namespace LoginNotify;
+
+use EchoEventPresentationModel;
+use Message;
+use SpecialPage;
+
+class PresentationModel extends EchoEventPresentationModel {
 
        /**
         * Show an user avatar.

-- 
To view, visit https://gerrit.wikimedia.org/r/359367
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7cf55685de955912c8637681c397179553d17152
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/LoginNotify
Gerrit-Branch: master
Gerrit-Owner: MaxSem <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to