From e0c26282a603881e8d2f839d94c28dbbfc57d71b Mon Sep 17 00:00:00 2001
From: Gerrit Uitslag <klapinklapin@gmail.com>
Date: Mon, 29 Sep 2014 03:34:17 +0200
Subject: scrutinizer documentations issues

---
 lib/plugins/authmysql/auth.php | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

(limited to 'lib/plugins/authmysql/auth.php')

diff --git a/lib/plugins/authmysql/auth.php b/lib/plugins/authmysql/auth.php
index 95c62f636..176eac679 100644
--- a/lib/plugins/authmysql/auth.php
+++ b/lib/plugins/authmysql/auth.php
@@ -284,7 +284,7 @@ class auth_plugin_authmysql extends DokuWiki_Auth_Plugin {
                 $grpdel = array_diff($groups, $changes['grps']);
 
                 foreach($grpadd as $group) {
-                    if(($this->_addUserToGroup($user, $group, 1)) == false) {
+                    if(($this->_addUserToGroup($user, $group, true)) == false) {
                         $rc = false;
                     }
                 }
@@ -612,7 +612,7 @@ class auth_plugin_authmysql extends DokuWiki_Auth_Plugin {
 
             if($uid) {
                 foreach($grps as $group) {
-                    $gid = $this->_addUserToGroup($user, $group, 1);
+                    $gid = $this->_addUserToGroup($user, $group, true);
                     if($gid === false) break;
                 }
 
@@ -777,7 +777,6 @@ class auth_plugin_authmysql extends DokuWiki_Auth_Plugin {
      *
      * @param  string $user    user's nick being updated
      * @param  array $changes  array of items to change as pairs of item and value
-     * @param  mixed $uid      user id of dataset to change, must be unique in DB
      * @return bool true on success or false on error
      *
      * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net>
-- 
cgit v1.2.3


From 59bc3b48fdffb76ee65a4b630be3ffa1f6c20c80 Mon Sep 17 00:00:00 2001
From: Gerrit Uitslag <klapinklapin@gmail.com>
Date: Mon, 29 Sep 2014 21:45:27 +0200
Subject: more scrutinizer issue improvements

---
 lib/plugins/authmysql/auth.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'lib/plugins/authmysql/auth.php')

diff --git a/lib/plugins/authmysql/auth.php b/lib/plugins/authmysql/auth.php
index 176eac679..0605a3bf1 100644
--- a/lib/plugins/authmysql/auth.php
+++ b/lib/plugins/authmysql/auth.php
@@ -366,7 +366,7 @@ class auth_plugin_authmysql extends DokuWiki_Auth_Plugin {
      *
      * @param  int          $first  index of first user to be returned
      * @param  int          $limit  max number of users to be returned
-     * @param  array|string $filter array of field/pattern pairs
+     * @param  array $filter array of field/pattern pairs
      * @return  array userinfo (refer getUserData for internal userinfo details)
      */
     public function retrieveUsers($first = 0, $limit = 0, $filter = array()) {
-- 
cgit v1.2.3


From 253d4b48ec708eb42033862dc15c8576f44a48ed Mon Sep 17 00:00:00 2001
From: Gerrit Uitslag <klapinklapin@gmail.com>
Date: Wed, 1 Oct 2014 15:32:05 +0200
Subject: more PHPDocs, unused var, small bit code reformatting

---
 lib/plugins/authmysql/auth.php | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

(limited to 'lib/plugins/authmysql/auth.php')

diff --git a/lib/plugins/authmysql/auth.php b/lib/plugins/authmysql/auth.php
index 0605a3bf1..0d423b6c9 100644
--- a/lib/plugins/authmysql/auth.php
+++ b/lib/plugins/authmysql/auth.php
@@ -115,7 +115,8 @@ class auth_plugin_authmysql extends DokuWiki_Auth_Plugin {
      * Check if the given config strings are set
      *
      * @author  Matthias Grimm <matthiasgrimm@users.sourceforge.net>
-     * @param   array $keys
+     *
+     * @param   string[] $keys
      * @param   bool  $wop is this a check for a write operation?
      * @return  bool
      */
@@ -668,7 +669,6 @@ class auth_plugin_authmysql extends DokuWiki_Auth_Plugin {
      *
      * @param  string  $user username of the user whose data is to be removed from the cache
      *                       if null, empty the whole cache
-     * @return none
      */
     protected function _flushUserInfoCache($user=null) {
         if (is_null($user)) {
@@ -750,7 +750,7 @@ class auth_plugin_authmysql extends DokuWiki_Auth_Plugin {
      * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net>
      *
      * @param  string $user  user's nick to get data for
-     * @return bool|array false on error, user info on success
+     * @return false|array false on error, user info on success
      */
     protected function _retrieveUserInfo($user) {
         $sql    = str_replace('%{user}', $this->_escape($user), $this->getConf('getUserInfo'));
@@ -837,7 +837,7 @@ class auth_plugin_authmysql extends DokuWiki_Auth_Plugin {
      * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net>
      *
      * @param  string $group   group name which id is desired
-     * @return mixed group id
+     * @return false|string group id
      */
     protected function _getGroupID($group) {
         if($this->dbcon) {
@@ -910,7 +910,7 @@ class auth_plugin_authmysql extends DokuWiki_Auth_Plugin {
      * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net>
      *
      * @param string $query  SQL string that contains the query
-     * @return array with the result table
+     * @return array|false with the result table
      */
     protected function _queryDB($query) {
         if($this->getConf('debug') >= 2) {
@@ -1001,6 +1001,8 @@ class auth_plugin_authmysql extends DokuWiki_Auth_Plugin {
      * abrogated.
      *
      * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net>
+     *
+     * @return bool
      */
     protected function _unlockTables() {
         if($this->dbcon) {
-- 
cgit v1.2.3


From 8f03c311f28eaffe92893ec1a4d0b78581926e13 Mon Sep 17 00:00:00 2001
From: Patrick Brown <ptbrown@whoopdedo.org>
Date: Wed, 6 May 2015 15:31:08 -0400
Subject: Error reporting for database auth plugins

---
 lib/plugins/authmysql/auth.php | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

(limited to 'lib/plugins/authmysql/auth.php')

diff --git a/lib/plugins/authmysql/auth.php b/lib/plugins/authmysql/auth.php
index 0d423b6c9..1b7d0bfa4 100644
--- a/lib/plugins/authmysql/auth.php
+++ b/lib/plugins/authmysql/auth.php
@@ -222,6 +222,7 @@ class auth_plugin_authmysql extends DokuWiki_Auth_Plugin {
 
         if($this->_openDB()) {
             if(($info = $this->_getUserInfo($user)) !== false) {
+                msg($this->getLang('userexists'), -1);
                 return false; // user already exists
             }
 
@@ -235,7 +236,13 @@ class auth_plugin_authmysql extends DokuWiki_Auth_Plugin {
             $rc  = $this->_addUser($user, $pwd, $name, $mail, $grps);
             $this->_unlockTables();
             $this->_closeDB();
-            if($rc) return true;
+            if(!$rc) {
+                msg($this->getLang('writefail'));
+                return null;
+            }
+            return true;
+        } else {
+            msg($this->getLang('connectfail'), -1);
         }
         return null; // return error
     }
@@ -279,7 +286,9 @@ class auth_plugin_authmysql extends DokuWiki_Auth_Plugin {
 
             $rc = $this->_updateUserInfo($user, $changes);
 
-            if($rc && isset($changes['grps']) && $this->cando['modGroups']) {
+            if(!$rc) {
+                msg($this->getLang('usernotexists'), -1);
+            } elseif(isset($changes['grps']) && $this->cando['modGroups']) {
                 $groups = $this->_getGroups($user);
                 $grpadd = array_diff($changes['grps'], $groups);
                 $grpdel = array_diff($groups, $changes['grps']);
@@ -295,10 +304,14 @@ class auth_plugin_authmysql extends DokuWiki_Auth_Plugin {
                         $rc = false;
                     }
                 }
+
+                if(!$rc) msg($this->getLang('writefail'));
             }
 
             $this->_unlockTables();
             $this->_closeDB();
+        } else {
+            msg($this->getLang('connectfail'), -1);
         }
         return $rc;
     }
@@ -328,6 +341,8 @@ class auth_plugin_authmysql extends DokuWiki_Auth_Plugin {
                 $this->_unlockTables();
             }
             $this->_closeDB();
+        } else {
+            msg($this->getLang('connectfail'), -1);
         }
         return $count;
     }
-- 
cgit v1.2.3