From b0a0ac793b5f8794c458eb10e10efca5cede3d75 Mon Sep 17 00:00:00 2001
From: matthiasgrimm <matthiasgrimm@users.sourceforge.net>
Date: Wed, 1 Feb 2006 19:14:22 +0100
Subject: [PATCH] optional READ Lock

The option TablesToLock is no longer required for read operations.
The small risk to feed invalid data into dokuwiki was accepted by
the project leader.

Nevertheless locks will be used for read operations too, if the
option 'TablesToLock' is given.

darcs-hash:20060201181422-7ef76-e89c5d9c305ca8c076281a58b6208e60dfce4c9f.gz
---
 inc/auth/mysql.class.php | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/inc/auth/mysql.class.php b/inc/auth/mysql.class.php
index cb789fc12..fb7f43d80 100644
--- a/inc/auth/mysql.class.php
+++ b/inc/auth/mysql.class.php
@@ -53,14 +53,12 @@ class auth_mysql extends auth_basic {
   	 * @return  bool
   	 */
     function canDo($fn) {
+      $wop = false;  /* function is write operation */
+      
       /* general database configuration set? */
       if (empty($this->cnf['server']) || empty($this->cnf['user']) ||
           empty($this->cnf['password']) || empty($this->cnf['database']))
         return false;
-          
-      /* lock array filled with tables names? */
-      if (!is_array($this->cnf['TablesToLock']) || empty($this->cnf['TablesToLock']))
-        return false;
         
       switch($fn) {
         case 'checkPass':
@@ -72,14 +70,17 @@ class auth_mysql extends auth_basic {
         case 'createUser':
           $config = array('getUserInfo','getGroups','addUser',
              'getUserID','addGroup','addUserGroup','delGroup');
+          $wop = true;
           break;
         case 'modifyUser':
           $config = array('getUserID','updateUser','UpdateTarget',
              'getGroups','getGroupID','addGroup','addUserGroup',
              'delGroup','getGroupID','delUserGroup');
+          $wop = true;
           break;
         case 'deleteUsers':
           $config = array('getUserID','delUser','delUserRefs');
+          $wop = true;
           break;
         case 'getUserCount':
           $config = array('getUsers');
@@ -90,14 +91,20 @@ class auth_mysql extends auth_basic {
         case 'joinGroup':
           $config = array('getUserID','getGroupID','addGroup',
              'addUserGroup','delGroup');
+          $wop = true;
           break;
         case 'leaveGroup':
           $config = array('getUserID','getGroupID','delUserGroup');
+          $wop = true;
           break;
         default:
           return false; /* unknown function call */
       }
       
+      /* write operation and lock array filled with tables names? */
+      if ($wop && (!is_array($this->cnf['TablesToLock']) || empty($this->cnf['TablesToLock'])))
+        return false;
+        
       foreach ($config as $statement)
         if (empty($this->cnf[$statement]))
           return false; /* required statement not set */
-- 
GitLab