MarkAHershberger has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/369584 )
Change subject: Conform to coding conventions
......................................................................
Conform to coding conventions
* Address CodeSniffer issues.
* Add .dir-locals.el for emacs users.
* Introduce personal pref for long lines in argument lists
* Hooks don't need to return true any more. Doing so makes
CodeSniffer go bonkers w/o a comment.
* When passing in objects pass by ref isn't needed.
Change-Id: Iad94d077418078bb9d714606ff328b338a30b5cf
---
A .dir-locals.el
M PluggableAuthHooks.php
2 files changed, 125 insertions(+), 36 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/PluggableAuth
refs/changes/84/369584/1
diff --git a/.dir-locals.el b/.dir-locals.el
new file mode 100644
index 0000000..2280495
--- /dev/null
+++ b/.dir-locals.el
@@ -0,0 +1,88 @@
+((nil . ((mode . flycheck)
+ (mode . company)
+ (mode . edep)
+ (mode . subword)
+ (tab-width . 4)
+ (c-basic-offset . 4)
+ (indent-tabs-mode . t)
+ (eval . (progn (when (fboundp 'delete-trailing-whitespace)
+ (delete-trailing-whitespace))
+ (tabify (point-min)
(point-max))))
+ (c-hanging-braces-alist
+ (defun-open after)
+ (block-open after)
+ (defun-close))
+ (c-offsets-alist . (
+ (access-label . -)
+ (annotation-top-cont .
0)
+ (annotation-var-cont .
+)
+ (arglist-close .
php-lineup-arglist-close)
+ (arglist-cont-nonempty
first
+
php-lineup-cascaded-calls
+
c-lineup-arglist)
+ (arglist-intro .
php-lineup-arglist-intro)
+ (block-close . 0)
+ (block-open . 0)
+ (brace-entry-open . 0)
+ (brace-list-close . 0)
+ (brace-list-entry . 0)
+ (brace-list-intro . +)
+ (brace-list-open . 0)
+ (c .
c-lineup-C-comments)
+ (case-label . 0)
+ (catch-clause . 0)
+ (class-close . 0)
+ (comment-intro . 0)
+ (composition-close . 0)
+ (composition-open . 0)
+ (cpp-define-intro
c-lineup-cpp-define +)
+ (cpp-macro . [0])
+ (cpp-macro-cont . +)
+ (defun-block-intro . +)
+ (defun-close . 0)
+ (defun-open . 0)
+ (do-while-closure . 0)
+ (else-clause . 0)
+ (extern-lang-close . 0)
+ (extern-lang-open . 0)
+ (friend . 0)
+ (func-decl-cont . +)
+ (inclass . +)
+ (incomposition . +)
+ (inexpr-class . +)
+ (inexpr-statement . +)
+ (inextern-lang . +)
+ (inher-cont .
c-lineup-multi-inher)
+ (inher-intro . +)
+ (inlambda . 0)
+ (inline-close . 0)
+ (inline-open . 0)
+ (inmodule . +)
+ (innamespace . +)
+ (knr-argdecl . 0)
+ (knr-argdecl-intro . +)
+ (label . +)
+ (lambda-intro-cont . +)
+ (member-init-cont .
c-lineup-multi-inher)
+ (member-init-intro . +)
+ (module-close . 0)
+ (module-open . 0)
+ (namespace-close . 0)
+ (namespace-open . 0)
+ (statement . 0)
+ (statement-block-intro
. +)
+ (statement-case-intro
. +)
+ (statement-case-open .
0)
+ (statement-cont first
+
php-lineup-cascaded-calls
+
php-lineup-string-cont +)
+ (stream-op .
c-lineup-streamop)
+ (string .
c-lineup-dont-change)
+ (substatement . +)
+ (substatement-label .
2)
+ (substatement-open . 0)
+ (template-args-cont
c-lineup-template-args +)
+ (topmost-intro . 0)
+ (topmost-intro-cont
first php-lineup-cascaded-calls +)
+ ))
+ )))
diff --git a/PluggableAuthHooks.php b/PluggableAuthHooks.php
index d550b8a..a82d024 100644
--- a/PluggableAuthHooks.php
+++ b/PluggableAuthHooks.php
@@ -52,41 +52,43 @@
}
/**
- *
* Implements TitleReadWhitelist hook.
* See https://www.mediawiki.org/wiki/Manual:Hooks/TitleReadWhitelist
* Adds PluggableAuth login special pages to whitelist.
*
* @since 2.0
- *
+ * @param Title $title being checked
+ * @param User $user Current user
+ * @param bool &$whitelisted whether this title is whitelisted
*/
- public static function onTitleReadWhitelist( $title, $user,
&$whitelisted ) {
+ public static function onTitleReadWhitelist(
+ Title $title, User $user, &$whitelisted
+ ) {
$loginSpecialPages =
ExtensionRegistry::getInstance()->getAttribute(
'PluggableAuthLoginSpecialPages' );
foreach ( $loginSpecialPages as $page ) {
if ( $title->isSpecial( $page ) ) {
$whitelisted = true;
- return true;
+ return;
}
}
- return true;
}
/**
- *
* Implements AuthChangeFormFields hook.
* See https://www.mediawiki.org/wiki/Manual:Hooks/AuthChangeFormFields
* Moves login button to bottom of form.
*
* @since 2.0
- *
- * @param array $requests
- * @param array $fieldInfo
- * @param array $formDescriptor
- * @param $action
+ * @param array $requests AuthenticationRequests the fields are created
from
+ * @param array $fieldInfo union of
AuthenticationRequest::getFieldInfo()
+ * @param HTMLForm &$formDescriptor The special key weight can be set to
+ * change the order of the fields.
+ * @param int $action one of the AuthManager::ACTION_* constants.
*/
- public static function onAuthChangeFormFields( array $requests,
- array $fieldInfo, array &$formDescriptor, $action) {
+ public static function onAuthChangeFormFields(
+ array $requests, array $fieldInfo, array &$formDescriptor,
$action
+ ) {
if ( isset( $formDescriptor['pluggableauthlogin'] ) ) {
$formDescriptor['pluggableauthlogin']['weight'] = 101;
}
@@ -98,16 +100,16 @@
* Calls deauthenticate hook in authentication plugin.
*
* @since 2.0
- *
- * @param User $user
- * @param $inject_html
- * @param $old_name
+ * @param User $user User after logout (won't have name, ID, etc.)
+ * @param string $inject_html Any HTML to inject after the logout
message.
+ * @param string $old_name The text of the username that just logged
out.
*/
- public static function deauthenticate( User &$user, $inject_html,
- $old_name ) {
+ public static function deauthenticate(
+ User $user, $inject_html, $old_name
+ ) {
$old_user = User::newFromName( $old_name );
if ( $old_user === false ) {
- return true;
+ return;
}
wfDebug( 'Deauthenticating ' . $old_name );
$pluggableauth = PluggableAuth::singleton();
@@ -115,11 +117,11 @@
$pluggableauth->deauthenticate( $old_user );
}
wfDebug( 'Deauthenticated ' . $old_name );
- return true;
}
/**
* Implements BeforePageDisplay hook.
+ * See https://www.mediawiki.org/wiki/Manual:Hooks/BeforePageDisplay
* Adds auto login JavaScript module if all of the following are true:
* - auto login is enabled
* - no user is already logged in
@@ -132,29 +134,28 @@
*
* @since 2.0
*
- * @param OutputPage $out
- * @param Skin $skin
+ * @param OutputPage &$out output page obj
+ * @param Skin &$skin will be used to generate the page
*/
public static function autoLoginInit( &$out, &$skin ) {
if ( !$GLOBALS['wgPluggableAuth_EnableAutoLogin'] ) {
- return true;
+ return;
}
if ( !$out->getUser()->isAnon() ) {
- return true;
+ return;
+ }
+ if ( !User::isEveryoneAllowed( 'read' ) && $title->userCan(
'read' ) ) {
+ return;
}
$loginSpecialPages =
ExtensionRegistry::getInstance()->getAttribute(
'PluggableAuthLoginSpecialPages' );
$title = $out->getTitle();
foreach ( $loginSpecialPages as $page ) {
if ( $title->isSpecial( $page ) ) {
- return true;
+ return;
}
}
- if ( !User::isEveryoneAllowed( 'read' ) && $title->userCan(
'read' ) ) {
- return true;
- }
$out->addModules( 'ext.PluggableAuthAutoLogin' );
- return true;
}
/**
@@ -164,15 +165,15 @@
*
* @since 1.0
*
- * @param array &$personal_urls
- * @param Title $title
- * @param SkinTemplate $skin
+ * @param array &$personal_urls urls sto modify
+ * @param Title $title current title
+ * @param SkinTemplate $skin template for vars
*/
- public static function modifyLoginURLs( array &$personal_urls,
- Title $title = null, SkinTemplate $skin = null ) {
+ public static function modifyLoginURLs(
+ array &$personal_urls, Title $title = null, SkinTemplate $skin
= null
+ ) {
if ( $GLOBALS['wgPluggableAuth_EnableAutoLogin'] ) {
unset( $personal_urls['logout'] );
}
- return true;
}
}
--
To view, visit https://gerrit.wikimedia.org/r/369584
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iad94d077418078bb9d714606ff328b338a30b5cf
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/PluggableAuth
Gerrit-Branch: master
Gerrit-Owner: MarkAHershberger <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits