From: <var...@us...> - 2014-12-03 12:46:53
|
Revision: 9410 http://sourceforge.net/p/phpwiki/code/9410 Author: vargenau Date: 2014-12-03 12:46:50 +0000 (Wed, 03 Dec 2014) Log Message: ----------- functions lock, unlock and close are abstract Modified Paths: -------------- trunk/lib/WikiDB/backend/ADODB.php trunk/lib/WikiDB/backend/PDO.php trunk/lib/WikiDB/backend/PearDB.php trunk/lib/WikiDB/backend/cvs.php trunk/lib/WikiDB/backend/dba.php trunk/lib/WikiDB/backend/dbaBase.php trunk/lib/WikiDB/backend/file.php trunk/lib/WikiDB/backend.php Modified: trunk/lib/WikiDB/backend/ADODB.php =================================================================== --- trunk/lib/WikiDB/backend/ADODB.php 2014-12-03 12:40:45 UTC (rev 9409) +++ trunk/lib/WikiDB/backend/ADODB.php 2014-12-03 12:46:50 UTC (rev 9410) @@ -141,7 +141,7 @@ '(lock_count = $this->_lock_count)' . "\n<br />", E_USER_WARNING); } - $this->unlock(false, 'force'); + $this->unlock(array(), 'force'); $this->_dbh->close(); $this->_dbh = false; @@ -542,7 +542,7 @@ array($id, $version + 1, $mtime, 0, '', $this->_serialize($meta))) and $dbh->Execute("DELETE FROM $nonempty_tbl WHERE id=$id") - and $this->set_links($pagename, false) + and $this->set_links($pagename, array()) // need to keep perms and LOCKED, otherwise you can reset the perm // by action=remove and re-create it with default perms // keep hits but delete meta-data @@ -572,7 +572,7 @@ $dbh->Execute("DELETE FROM $nonempty_tbl WHERE id=$id"); $dbh->Execute("DELETE FROM $recent_tbl WHERE id=$id"); $dbh->Execute("DELETE FROM $version_tbl WHERE id=$id"); - $this->set_links($pagename, false); + $this->set_links($pagename, array()); $row = $dbh->GetRow("SELECT COUNT(*) FROM $link_tbl WHERE linkto=$id"); if ($row and $row[0]) { // We're still in the link table (dangling link) so we can't delete this @@ -1212,7 +1212,7 @@ * Calls can be nested. The tables won't be unlocked until * _unlock_database() is called as many times as _lock_database(). */ - public function lock($tables, $write_lock = true) + public function lock($tables = array(), $write_lock = true) { $this->_dbh->StartTrans(); if ($this->_lock_count++ == 0) { @@ -1232,12 +1232,13 @@ /** * Release a write lock on the tables in the SQL database. * - * @param $force boolean Unlock even if not every call to lock() has been matched + * @param array $tables + * @param bool $force Unlock even if not every call to lock() has been matched * by a call to unlock(). * * @see _lock_database */ - public function unlock($tables = false, $force = false) + public function unlock($tables = array(), $force = false) { if ($this->_lock_count == 0) { $this->_current_lock = false; Modified: trunk/lib/WikiDB/backend/PDO.php =================================================================== --- trunk/lib/WikiDB/backend/PDO.php 2014-12-03 12:40:45 UTC (rev 9409) +++ trunk/lib/WikiDB/backend/PDO.php 2014-12-03 12:46:50 UTC (rev 9410) @@ -212,7 +212,7 @@ '(lock_count = $this->_lock_count)' . "\n<br />", E_USER_WARNING); } - $this->unlock(false, 'force'); + $this->unlock(array(), 'force'); unset($this->_dbh); } @@ -659,7 +659,7 @@ $insert->bindParam(6, $this->_serialize($meta), PDO::PARAM_STR, 100); if ($insert->execute() and $dbh->query("DELETE FROM $nonempty_tbl WHERE id=$id") - and $this->set_links($pagename, false) + and $this->set_links($pagename, array()) ) { // need to keep perms and LOCKED, otherwise you can reset the perm // by action=remove and re-create it with default perms @@ -690,7 +690,7 @@ $dbh->query("DELETE FROM $version_tbl WHERE id=$id"); $dbh->query("DELETE FROM $recent_tbl WHERE id=$id"); $dbh->query("DELETE FROM $nonempty_tbl WHERE id=$id"); - $this->set_links($pagename, false); + $this->set_links($pagename, array()); $sth = $dbh->prepare("SELECT COUNT(*) FROM $link_tbl WHERE linkto=$id"); $sth->execute(); if ($sth->fetchColumn()) { @@ -1189,7 +1189,7 @@ * Calls can be nested. The tables won't be unlocked until * _unlock_database() is called as many times as _lock_database(). */ - public function lock($tables, $write_lock = true) + public function lock($tables = array(), $write_lock = true) { if ($this->_lock_count++ == 0) { $this->_current_lock = $tables; @@ -1218,7 +1218,7 @@ * * @see _lock_database */ - public function unlock($tables = false, $force = false) + public function unlock($tables = array(), $force = false) { if ($this->_lock_count == 0) { $this->_current_lock = false; Modified: trunk/lib/WikiDB/backend/PearDB.php =================================================================== --- trunk/lib/WikiDB/backend/PearDB.php 2014-12-03 12:40:45 UTC (rev 9409) +++ trunk/lib/WikiDB/backend/PearDB.php 2014-12-03 12:46:50 UTC (rev 9410) @@ -1025,7 +1025,7 @@ * Calls can be nested. The tables won't be unlocked until * _unlock_database() is called as many times as _lock_database(). */ - public function lock($tables = false, $write_lock = true) + public function lock($tables = array(), $write_lock = true) { if ($this->_lock_count++ == 0) $this->_lock_tables($write_lock); @@ -1042,12 +1042,12 @@ /** * Release a write lock on the tables in the SQL database. * - * @param $force boolean Unlock even if not every call to lock() has been matched + * @param bool $force Unlock even if not every call to lock() has been matched * by a call to unlock(). * * @see _lock_database */ - public function unlock($tables = false, $force = false) + public function unlock($tables = array(), $force = false) { if ($this->_lock_count == 0) { return; Modified: trunk/lib/WikiDB/backend/cvs.php =================================================================== --- trunk/lib/WikiDB/backend/cvs.php 2014-12-03 12:40:45 UTC (rev 9409) +++ trunk/lib/WikiDB/backend/cvs.php 2014-12-03 12:46:50 UTC (rev 9410) @@ -486,13 +486,13 @@ return new Cvs_Backend_Array_Iterator($returnVal); } - function lock($write_lock = true) + function lock($tables = array(), $write_lock = true) { // TODO: to be implemented trigger_error("lock: Not Implemented", E_USER_WARNING); } - function unlock($force = false) + function unlock($tables = array(), $force = false) { // TODO: to be implemented trigger_error("unlock: Not Implemented", E_USER_WARNING); Modified: trunk/lib/WikiDB/backend/dba.php =================================================================== --- trunk/lib/WikiDB/backend/dba.php 2014-12-03 12:40:45 UTC (rev 9409) +++ trunk/lib/WikiDB/backend/dba.php 2014-12-03 12:46:50 UTC (rev 9410) @@ -34,6 +34,14 @@ parent::__construct($db); } + + function lock($tables = array(), $write_lock = true) + { + } + + function unlock($tables = array(), $force = false) + { + } } // Local Variables: Modified: trunk/lib/WikiDB/backend/dbaBase.php =================================================================== --- trunk/lib/WikiDB/backend/dbaBase.php 2014-12-03 12:40:45 UTC (rev 9409) +++ trunk/lib/WikiDB/backend/dbaBase.php 2014-12-03 12:46:50 UTC (rev 9410) @@ -62,6 +62,14 @@ return array('pagename', 'mtime' /*,'author_id','author'*/); } + function lock($tables = array(), $write_lock = true) + { + } + + function unlock($tables = array(), $force = false) + { + } + function close() { $this->_db->close(); Modified: trunk/lib/WikiDB/backend/file.php =================================================================== --- trunk/lib/WikiDB/backend/file.php 2014-12-03 12:40:45 UTC (rev 9409) +++ trunk/lib/WikiDB/backend/file.php 2014-12-03 12:46:50 UTC (rev 9410) @@ -624,31 +624,16 @@ /** * Lock backend database. - * - * Calls may be nested. - * - * @param $write_lock boolean Unless this is set to false, a write lock - * is acquired, otherwise a read lock. If the backend doesn't support - * read locking, then it should make a write lock no matter which type - * of lock was requested. - * - * All backends <em>should</em> support write locking. */ - function lock($write_lock = true) + function lock($tables = array(), $write_lock = true) { - //trigger_error("lock: Not Implemented", E_USER_WARNING); } /** * Unlock backend database. - * - * @param $force boolean Normally, the database is not unlocked until - * unlock() is called as many times as lock() has been. If $force is - * set to true, the the database is unconditionally unlocked. */ - function unlock($force = false) + function unlock($tables = array(), $force = false) { - //trigger_error("unlock: Not Implemented", E_USER_WARNING); } /** @@ -656,7 +641,6 @@ */ function close() { - //trigger_error("close: Not Implemented", E_USER_WARNING); } /** @@ -666,7 +650,6 @@ */ function sync() { - //trigger_error("sync: Not Implemented", E_USER_WARNING); } /** Modified: trunk/lib/WikiDB/backend.php =================================================================== --- trunk/lib/WikiDB/backend.php 2014-12-03 12:40:45 UTC (rev 9409) +++ trunk/lib/WikiDB/backend.php 2014-12-03 12:46:50 UTC (rev 9410) @@ -432,6 +432,7 @@ * * Calls may be nested. * + * @param array $tables * @param bool $write_lock Unless this is set to false, a write lock * is acquired, otherwise a read lock. If the backend doesn't support * read locking, then it should make a write lock no matter which type @@ -439,27 +440,22 @@ * * All backends <em>should</em> support write locking. */ - function lock($write_lock = true) - { - } + abstract function lock($tables = array(), $write_lock = true); /** * Unlock backend database. * + * @param array $tables * @param bool $force Normally, the database is not unlocked until * unlock() is called as many times as lock() has been. If $force is * set to true, the the database is unconditionally unlocked. */ - function unlock($force = false) - { - } + abstract function unlock($tables = array(), $force = false); /** * Close database. */ - function close() - { - } + abstract function close(); /** * Synchronize with filesystem. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |