From: <ru...@us...> - 2010-06-08 10:42:15
|
Revision: 7495 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=7495&view=rev Author: rurban Date: 2010-06-08 10:42:09 +0000 (Tue, 08 Jun 2010) Log Message: ----------- support backend slicing Modified Paths: -------------- trunk/lib/WikiDB/backend/dbaBase.php trunk/lib/WikiDB/backend/file.php trunk/lib/WikiDB/backend.php Modified: trunk/lib/WikiDB/backend/dbaBase.php =================================================================== --- trunk/lib/WikiDB/backend/dbaBase.php 2010-06-08 10:41:29 UTC (rev 7494) +++ trunk/lib/WikiDB/backend/dbaBase.php 2010-06-08 10:42:09 UTC (rev 7495) @@ -355,8 +355,7 @@ } return new WikiDB_backend_dbaBase_pageiter ($this, $pages, - array('sortby'=>$sortby/*, - 'limit' =>$limit*/)); + array('sortby'=>$sortby)); // already limited } function set_links($pagename, $links) { Modified: trunk/lib/WikiDB/backend/file.php =================================================================== --- trunk/lib/WikiDB/backend/file.php 2010-06-08 10:41:29 UTC (rev 7494) +++ trunk/lib/WikiDB/backend/file.php 2010-06-08 10:42:09 UTC (rev 7495) @@ -695,9 +695,10 @@ class WikiDB_backend_file_iter extends WikiDB_backend_iterator { - function WikiDB_backend_file_iter(&$backend, &$query_result) { + function WikiDB_backend_file_iter(&$backend, &$query_result, $options=array()) { $this->_backend = &$backend; $this->_result = $query_result; + $this->_options = $options; if (count($this->_result) > 0) reset($this->_result); Modified: trunk/lib/WikiDB/backend.php =================================================================== --- trunk/lib/WikiDB/backend.php 2010-06-08 10:41:29 UTC (rev 7494) +++ trunk/lib/WikiDB/backend.php 2010-06-08 10:42:09 UTC (rev 7495) @@ -692,6 +692,15 @@ return $result; } } + + /** + * limit - if empty the pagelist iterator will do nothing. + * Some backends limit the result set itself (dba, file, flatfile), + * Some SQL based leave it to WikiDB/PageList - deferred filtering in the iterator. + */ + function limit() { + return empty($this->_options['limit']) ? 0 : $this->_options['limit']; + } /** * Release resources held by this iterator. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2012-10-02 12:47:54
|
Revision: 8382 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=8382&view=rev Author: vargenau Date: 2012-10-02 12:47:45 +0000 (Tue, 02 Oct 2012) Log Message: ----------- Whitespace only Modified Paths: -------------- trunk/lib/WikiDB/ADODB.php trunk/lib/WikiDB/PDO.php trunk/lib/WikiDB/adodb/adodb-errorpear.inc.php trunk/lib/WikiDB/adodb/adodb-exceptions.inc.php trunk/lib/WikiDB/adodb/adodb-iterator.inc.php trunk/lib/WikiDB/adodb/adodb-pear.inc.php trunk/lib/WikiDB/adodb/adodb-php4.inc.php trunk/lib/WikiDB/adodb/adodb-time.inc.php trunk/lib/WikiDB/adodb/drivers/adodb-ado.inc.php trunk/lib/WikiDB/adodb/drivers/adodb-csv.inc.php trunk/lib/WikiDB/adodb/drivers/adodb-mssql.inc.php trunk/lib/WikiDB/adodb/drivers/adodb-mssqlnative.inc.php trunk/lib/WikiDB/adodb/drivers/adodb-mysqli.inc.php trunk/lib/WikiDB/adodb/drivers/adodb-odbc.inc.php trunk/lib/WikiDB/adodb/drivers/adodb-odbtp.inc.php trunk/lib/WikiDB/adodb/drivers/adodb-postgres.inc.php trunk/lib/WikiDB/adodb/drivers/adodb-proxy.inc.php Modified: trunk/lib/WikiDB/ADODB.php =================================================================== --- trunk/lib/WikiDB/ADODB.php 2012-10-02 12:39:40 UTC (rev 8381) +++ trunk/lib/WikiDB/ADODB.php 2012-10-02 12:47:45 UTC (rev 8382) @@ -1,6 +1,5 @@ -<?php // -*-php-*- +<?php - require_once 'lib/WikiDB.php'; /** Modified: trunk/lib/WikiDB/PDO.php =================================================================== --- trunk/lib/WikiDB/PDO.php 2012-10-02 12:39:40 UTC (rev 8381) +++ trunk/lib/WikiDB/PDO.php 2012-10-02 12:47:45 UTC (rev 8382) @@ -1,6 +1,5 @@ -<?php // -*-php-*- +<?php - require_once 'lib/WikiDB.php'; /** Modified: trunk/lib/WikiDB/adodb/adodb-errorpear.inc.php =================================================================== --- trunk/lib/WikiDB/adodb/adodb-errorpear.inc.php 2012-10-02 12:39:40 UTC (rev 8381) +++ trunk/lib/WikiDB/adodb/adodb-errorpear.inc.php 2012-10-02 12:47:45 UTC (rev 8382) @@ -84,4 +84,3 @@ return $ADODB_Last_PEAR_Error; } - Modified: trunk/lib/WikiDB/adodb/adodb-exceptions.inc.php =================================================================== --- trunk/lib/WikiDB/adodb/adodb-exceptions.inc.php 2012-10-02 12:39:40 UTC (rev 8381) +++ trunk/lib/WikiDB/adodb/adodb-exceptions.inc.php 2012-10-02 12:47:45 UTC (rev 8382) @@ -73,4 +73,3 @@ else $errfn = 'ADODB_EXCEPTION'; throw new $errfn($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection); } - Modified: trunk/lib/WikiDB/adodb/adodb-iterator.inc.php =================================================================== --- trunk/lib/WikiDB/adodb/adodb-iterator.inc.php 2012-10-02 12:39:40 UTC (rev 8381) +++ trunk/lib/WikiDB/adodb/adodb-iterator.inc.php 2012-10-02 12:47:45 UTC (rev 8382) @@ -68,4 +68,3 @@ return new ADODB_Iterator($this); } } - Modified: trunk/lib/WikiDB/adodb/adodb-pear.inc.php =================================================================== --- trunk/lib/WikiDB/adodb/adodb-pear.inc.php 2012-10-02 12:39:40 UTC (rev 8381) +++ trunk/lib/WikiDB/adodb/adodb-pear.inc.php 2012-10-02 12:47:45 UTC (rev 8382) @@ -354,4 +354,3 @@ return true; } } - Modified: trunk/lib/WikiDB/adodb/adodb-php4.inc.php =================================================================== --- trunk/lib/WikiDB/adodb/adodb-php4.inc.php 2012-10-02 12:39:40 UTC (rev 8381) +++ trunk/lib/WikiDB/adodb/adodb-php4.inc.php 2012-10-02 12:47:45 UTC (rev 8382) @@ -11,4 +11,3 @@ class ADODB_BASE_RS { } - Modified: trunk/lib/WikiDB/adodb/adodb-time.inc.php =================================================================== --- trunk/lib/WikiDB/adodb/adodb-time.inc.php 2012-10-02 12:39:40 UTC (rev 8381) +++ trunk/lib/WikiDB/adodb/adodb-time.inc.php 2012-10-02 12:47:45 UTC (rev 8382) @@ -903,4 +903,3 @@ //print " dmy=$day/$mon/$year $hr:$min:$sec => " .$ret; return $ret; } - Modified: trunk/lib/WikiDB/adodb/drivers/adodb-ado.inc.php =================================================================== --- trunk/lib/WikiDB/adodb/drivers/adodb-ado.inc.php 2012-10-02 12:39:40 UTC (rev 8381) +++ trunk/lib/WikiDB/adodb/drivers/adodb-ado.inc.php 2012-10-02 12:47:45 UTC (rev 8382) @@ -601,4 +601,3 @@ } } - Modified: trunk/lib/WikiDB/adodb/drivers/adodb-csv.inc.php =================================================================== --- trunk/lib/WikiDB/adodb/drivers/adodb-csv.inc.php 2012-10-02 12:39:40 UTC (rev 8381) +++ trunk/lib/WikiDB/adodb/drivers/adodb-csv.inc.php 2012-10-02 12:47:45 UTC (rev 8382) @@ -193,4 +193,3 @@ } } // define - Modified: trunk/lib/WikiDB/adodb/drivers/adodb-mssql.inc.php =================================================================== --- trunk/lib/WikiDB/adodb/drivers/adodb-mssql.inc.php 2012-10-02 12:39:40 UTC (rev 8381) +++ trunk/lib/WikiDB/adodb/drivers/adodb-mssql.inc.php 2012-10-02 12:47:45 UTC (rev 8382) @@ -915,4 +915,3 @@ http://www.databasejournal.com/scripts/article.php/1440551 */ - Modified: trunk/lib/WikiDB/adodb/drivers/adodb-mssqlnative.inc.php =================================================================== --- trunk/lib/WikiDB/adodb/drivers/adodb-mssqlnative.inc.php 2012-10-02 12:39:40 UTC (rev 8381) +++ trunk/lib/WikiDB/adodb/drivers/adodb-mssqlnative.inc.php 2012-10-02 12:47:45 UTC (rev 8382) @@ -916,4 +916,3 @@ http://www.databasejournal.com/scripts/article.php/1440551 */ - Modified: trunk/lib/WikiDB/adodb/drivers/adodb-mysqli.inc.php =================================================================== --- trunk/lib/WikiDB/adodb/drivers/adodb-mysqli.inc.php 2012-10-02 12:39:40 UTC (rev 8381) +++ trunk/lib/WikiDB/adodb/drivers/adodb-mysqli.inc.php 2012-10-02 12:47:45 UTC (rev 8382) @@ -822,4 +822,3 @@ } } - Modified: trunk/lib/WikiDB/adodb/drivers/adodb-odbc.inc.php =================================================================== --- trunk/lib/WikiDB/adodb/drivers/adodb-odbc.inc.php 2012-10-02 12:39:40 UTC (rev 8381) +++ trunk/lib/WikiDB/adodb/drivers/adodb-odbc.inc.php 2012-10-02 12:47:45 UTC (rev 8382) @@ -701,4 +701,3 @@ } } - Modified: trunk/lib/WikiDB/adodb/drivers/adodb-odbtp.inc.php =================================================================== --- trunk/lib/WikiDB/adodb/drivers/adodb-odbtp.inc.php 2012-10-02 12:39:40 UTC (rev 8381) +++ trunk/lib/WikiDB/adodb/drivers/adodb-odbtp.inc.php 2012-10-02 12:47:45 UTC (rev 8382) @@ -624,4 +624,3 @@ return @odbtp_free_query($this->_queryID); } } - Modified: trunk/lib/WikiDB/adodb/drivers/adodb-postgres.inc.php =================================================================== --- trunk/lib/WikiDB/adodb/drivers/adodb-postgres.inc.php 2012-10-02 12:39:40 UTC (rev 8381) +++ trunk/lib/WikiDB/adodb/drivers/adodb-postgres.inc.php 2012-10-02 12:47:45 UTC (rev 8382) @@ -10,4 +10,3 @@ remapped to "postgres7". Maintaining multiple postgres drivers is no easy job, so hopefully this will ensure greater consistency and fewer bugs. */ - Modified: trunk/lib/WikiDB/adodb/drivers/adodb-proxy.inc.php =================================================================== --- trunk/lib/WikiDB/adodb/drivers/adodb-proxy.inc.php 2012-10-02 12:39:40 UTC (rev 8381) +++ trunk/lib/WikiDB/adodb/drivers/adodb-proxy.inc.php 2012-10-02 12:47:45 UTC (rev 8382) @@ -26,4 +26,3 @@ } }; } // define - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2014-07-16 16:06:39
|
Revision: 8966 http://sourceforge.net/p/phpwiki/code/8966 Author: vargenau Date: 2014-07-16 16:06:31 +0000 (Wed, 16 Jul 2014) Log Message: ----------- Escape string to search Modified Paths: -------------- trunk/lib/WikiDB/backend/PearDB_mysql.php trunk/lib/WikiDB/backend.php Modified: trunk/lib/WikiDB/backend/PearDB_mysql.php =================================================================== --- trunk/lib/WikiDB/backend/PearDB_mysql.php 2014-07-16 14:00:21 UTC (rev 8965) +++ trunk/lib/WikiDB/backend/PearDB_mysql.php 2014-07-16 16:06:31 UTC (rev 8966) @@ -215,6 +215,8 @@ function _pagename_match_clause($node) { $word = $node->sql(); + $dbh = &$this->_dbh; + $word = $dbh->escapeSimple($word); if ($node->op == 'REGEX') { // posix regex extensions return "pagename REGEXP '$word'"; } else { Modified: trunk/lib/WikiDB/backend.php =================================================================== --- trunk/lib/WikiDB/backend.php 2014-07-16 14:00:21 UTC (rev 8965) +++ trunk/lib/WikiDB/backend.php 2014-07-16 16:06:31 UTC (rev 8966) @@ -864,15 +864,17 @@ function _fulltext_match_clause($node) { // force word-style %word% for fulltext search - $word = '%' . $node->sql_quote($node->word) . '%'; + $dbh = &$this->_dbh; + $word = '%' . $dbh->escapeSimple($word) . '%'; // eliminate stoplist words - if ($this->isStoplisted($node)) + if ($this->isStoplisted($node)) { return "1=1"; // and (pagename or 1) => and 1 - else + } else { return $this->_pagename_match_clause($node) // probably convert this MATCH AGAINST or SUBSTR/POSITION without wildcards . ($this->_case_exact ? " OR content LIKE '$word'" : " OR LOWER(content) LIKE '$word'"); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2014-07-17 17:04:07
|
Revision: 8985 http://sourceforge.net/p/phpwiki/code/8985 Author: vargenau Date: 2014-07-17 17:03:59 +0000 (Thu, 17 Jul 2014) Log Message: ----------- Use __construct Modified Paths: -------------- trunk/lib/WikiDB/ADODB.php trunk/lib/WikiDB/PDO.php trunk/lib/WikiDB/SQL.php trunk/lib/WikiDB/dba.php trunk/lib/WikiDB/file.php trunk/lib/WikiDB/flatfile.php Modified: trunk/lib/WikiDB/ADODB.php =================================================================== --- trunk/lib/WikiDB/ADODB.php 2014-07-17 16:58:49 UTC (rev 8984) +++ trunk/lib/WikiDB/ADODB.php 2014-07-17 17:03:59 UTC (rev 8985) @@ -12,7 +12,7 @@ */ class WikiDB_ADODB extends WikiDB { - function WikiDB_ADODB($dbparams) + function __construct($dbparams) { $backend = 'ADODB'; if (is_array($dbparams['dsn'])) @@ -35,7 +35,7 @@ $backend_class = "WikiDB_backend_" . $backend; $backend = new $backend_class($dbparams); if (!$backend->_dbh->_connectionID) return false; - $this->WikiDB($backend, $dbparams); + parent::__construct($backend, $dbparams); } /** Modified: trunk/lib/WikiDB/PDO.php =================================================================== --- trunk/lib/WikiDB/PDO.php 2014-07-17 16:58:49 UTC (rev 8984) +++ trunk/lib/WikiDB/PDO.php 2014-07-17 17:03:59 UTC (rev 8985) @@ -18,7 +18,7 @@ */ class WikiDB_PDO extends WikiDB { - function WikiDB_PDO($dbparams) + function __construct($dbparams) { if (is_array($dbparams['dsn'])) $backend = $dbparams['dsn']['phptype']; @@ -33,7 +33,7 @@ include_once("lib/WikiDB/backend/$backend.php"); $backend_class = "WikiDB_backend_$backend"; $backend = new $backend_class($dbparams); - $this->WikiDB($backend, $dbparams); + parent::__construct($backend, $dbparams); } /** Modified: trunk/lib/WikiDB/SQL.php =================================================================== --- trunk/lib/WikiDB/SQL.php 2014-07-17 16:58:49 UTC (rev 8984) +++ trunk/lib/WikiDB/SQL.php 2014-07-17 17:03:59 UTC (rev 8985) @@ -1,12 +1,7 @@ <?php require_once 'lib/WikiDB.php'; -//require_once('lib/WikiDB/backend/PearDB.php'); -//require_once('DB.php'); // Always favor use our local pear copy -/** - * - */ class WikiDB_SQL extends WikiDB { function __construct($dbparams) Modified: trunk/lib/WikiDB/dba.php =================================================================== --- trunk/lib/WikiDB/dba.php 2014-07-17 16:58:49 UTC (rev 8984) +++ trunk/lib/WikiDB/dba.php 2014-07-17 17:03:59 UTC (rev 8985) @@ -2,15 +2,13 @@ require_once 'lib/WikiDB.php'; require_once 'lib/WikiDB/backend/dba.php'; -/** - * - */ + class WikiDB_dba extends WikiDB { - function WikiDB_dba($dbparams) + function __construct($dbparams) { $backend = new WikiDB_backend_dba($dbparams); - $this->WikiDB($backend, $dbparams); + parent::__construct($backend, $dbparams); if (empty($dbparams['directory']) || preg_match('@^/tmp\b@', $dbparams['directory']) Modified: trunk/lib/WikiDB/file.php =================================================================== --- trunk/lib/WikiDB/file.php 2014-07-17 16:58:49 UTC (rev 8984) +++ trunk/lib/WikiDB/file.php 2014-07-17 17:03:59 UTC (rev 8985) @@ -34,7 +34,7 @@ function __construct($dbparams) { $backend = new WikiDB_backend_file($dbparams); - $this->WikiDB($backend, $dbparams); + parent::__construct($backend, $dbparams); if (empty($dbparams['directory']) || preg_match('@^/tmp\b@', $dbparams['directory']) Modified: trunk/lib/WikiDB/flatfile.php =================================================================== --- trunk/lib/WikiDB/flatfile.php 2014-07-17 16:58:49 UTC (rev 8984) +++ trunk/lib/WikiDB/flatfile.php 2014-07-17 17:03:59 UTC (rev 8985) @@ -34,7 +34,7 @@ { $backend = new WikiDB_backend_flatfile($dbparams); $backend->_wikidb =& $this; - $this->WikiDB($backend, $dbparams); + parent::__construct($backend, $dbparams); if (empty($dbparams['directory']) || preg_match('@^/tmp\b@', $dbparams['directory']) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |
From: <var...@us...> - 2021-09-16 15:23:42
|
Revision: 10555 http://sourceforge.net/p/phpwiki/code/10555 Author: vargenau Date: 2021-09-16 15:23:40 +0000 (Thu, 16 Sep 2021) Log Message: ----------- Move function delete_page from lib/WikiDB/backend.php to lib/WikiDB/backend/PearDB.php; all backends implement it Modified Paths: -------------- trunk/lib/WikiDB/backend/PearDB.php trunk/lib/WikiDB/backend.php Modified: trunk/lib/WikiDB/backend/PearDB.php =================================================================== --- trunk/lib/WikiDB/backend/PearDB.php 2021-09-14 16:59:19 UTC (rev 10554) +++ trunk/lib/WikiDB/backend/PearDB.php 2021-09-16 15:23:40 UTC (rev 10555) @@ -939,6 +939,45 @@ return $id; } + /** + * Delete page from the database with backup possibility. + * This should remove all links (from the named page) from + * the link database. + * + * @param string $pagename Page name. + * i.e save_page('') and DELETE nonempty id + * Can be undone and is seen in RecentChanges. + */ + + function delete_page($pagename) + { + /** + * @var WikiRequest $request + */ + global $request; + + $mtime = time(); + $user =& $request->_user; + $vdata = array('author' => $user->getId(), + 'author_id' => $user->getAuthenticatedId(), + 'mtime' => $mtime); + + $this->lock(); // critical section: + $version = $this->get_latest_version($pagename); + $this->set_versiondata($pagename, $version + 1, $vdata); + $this->set_links($pagename, array()); // links are purged. + // SQL needs to invalidate the non_empty id + if (!WIKIDB_NOCACHE_MARKUP) { + // need the hits, perms and LOCKED, otherwise you can reset the perm + // by action=remove and re-create it with default perms + $pagedata = $this->get_pagedata($pagename); + unset($pagedata['_cached_html']); + $this->update_pagedata($pagename, $pagedata); + } + $this->unlock(); + } + + function _update_recent_table($pageid = false) { $dbh = &$this->_dbh; Modified: trunk/lib/WikiDB/backend.php =================================================================== --- trunk/lib/WikiDB/backend.php 2021-09-14 16:59:19 UTC (rev 10554) +++ trunk/lib/WikiDB/backend.php 2021-09-16 15:23:40 UTC (rev 10555) @@ -170,7 +170,6 @@ * @param string $pagename Current page name * @param string $to Future page name */ - abstract function rename_page($pagename, $to); /** @@ -182,34 +181,8 @@ * i.e save_page('') and DELETE nonempty id * Can be undone and is seen in RecentChanges. */ - function delete_page($pagename) - { - /** - * @var WikiRequest $request - */ - global $request; + abstract function delete_page($pagename); - $mtime = time(); - $user =& $request->_user; - $vdata = array('author' => $user->getId(), - 'author_id' => $user->getAuthenticatedId(), - 'mtime' => $mtime); - - $this->lock(); // critical section: - $version = $this->get_latest_version($pagename); - $this->set_versiondata($pagename, $version + 1, $vdata); - $this->set_links($pagename, array()); // links are purged. - // SQL needs to invalidate the non_empty id - if (!WIKIDB_NOCACHE_MARKUP) { - // need the hits, perms and LOCKED, otherwise you can reset the perm - // by action=remove and re-create it with default perms - $pagedata = $this->get_pagedata($pagename); - unset($pagedata['_cached_html']); - $this->update_pagedata($pagename, $pagedata); - } - $this->unlock(); - } - /** * Delete page (and all its revisions) from the database. * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2021-09-17 14:16:46
|
Revision: 10567 http://sourceforge.net/p/phpwiki/code/10567 Author: vargenau Date: 2021-09-17 14:16:43 +0000 (Fri, 17 Sep 2021) Log Message: ----------- Remove default values in functions Modified Paths: -------------- trunk/lib/WikiDB/backend/dbaBase.php trunk/lib/WikiDB/backend/file.php trunk/lib/WikiDB/backend.php Modified: trunk/lib/WikiDB/backend/dbaBase.php =================================================================== --- trunk/lib/WikiDB/backend/dbaBase.php 2021-09-17 14:10:33 UTC (rev 10566) +++ trunk/lib/WikiDB/backend/dbaBase.php 2021-09-17 14:16:43 UTC (rev 10567) @@ -161,8 +161,7 @@ if (!$result) return false; list(, , $packed) = explode(':', $result, 3); - $data = unserialize($packed); - return $data; + return unserialize($packed); } function update_pagedata($pagename, $newdata) @@ -296,7 +295,7 @@ } else return false; - $links = $this->_linkdb->get_links($pagename, false, false); + $links = $this->_linkdb->get_links($pagename, false); $data['pagename'] = $to; $this->_pagedb->set($to, (int)$version . ':' @@ -351,8 +350,7 @@ // fix broken pages if (!is_array($data) or empty($data)) { if (is_string($data) and ($vdata = @unserialize($data))) { - trigger_error("broken page version $pagename. Run Check WikiDB", - E_USER_NOTICE); + trigger_error("broken page version $pagename. Run Check WikiDB"); $data = $vdata; } else $data = array(); @@ -732,9 +730,9 @@ // fields are stored in versiondata $av = $dbi->_backend->get_latest_version($aname); $bv = $dbi->_backend->get_latest_version($bname); - $a = $dbi->_backend->get_versiondata($aname, $av, false); + $a = $dbi->_backend->get_versiondata($aname, $av); if (!$a) return -1; - $b = $dbi->_backend->get_versiondata($bname, $bv, false); + $b = $dbi->_backend->get_versiondata($bname, $bv); if (!$b or !isset($b[$field])) return 0; if (empty($a[$field])) return -1; if ((!isset($a[$field]) and !isset($b[$field])) or ($a[$field] === $b[$field])) { @@ -846,7 +844,7 @@ function set_links($page, $links) { - $oldlinks = $this->get_links($page, false, false); + $oldlinks = $this->get_links($page, false); if (!is_array($links)) { assert(empty($links)); Modified: trunk/lib/WikiDB/backend/file.php =================================================================== --- trunk/lib/WikiDB/backend/file.php 2021-09-17 14:10:33 UTC (rev 10566) +++ trunk/lib/WikiDB/backend/file.php 2021-09-17 14:16:43 UTC (rev 10567) @@ -464,8 +464,7 @@ // try to delete the latest version! // so check if an older version exist: if ($this->get_versiondata($pagename, - $this->get_previous_version($pagename, $version), - false) == false + $this->get_previous_version($pagename, $version)) == false ) { // there is no older version.... // so the completely page will be removed: Modified: trunk/lib/WikiDB/backend.php =================================================================== --- trunk/lib/WikiDB/backend.php 2021-09-17 14:10:33 UTC (rev 10566) +++ trunk/lib/WikiDB/backend.php 2021-09-17 14:16:43 UTC (rev 10567) @@ -494,9 +494,9 @@ global $request; $dbh = $request->getDbh(); - $iter = $dbh->getAllPages(false); + $iter = $dbh->getAllPages(); while ($page = $iter->next()) { - $current = $page->getCurrentRevision(true); + $current = $page->getCurrentRevision(); $pagename = $page->getName(); $meta = $current->_data; $version = $current->getVersion(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2014-12-04 15:51:50
|
Revision: 9417 http://sourceforge.net/p/phpwiki/code/9417 Author: vargenau Date: 2014-12-04 15:51:47 +0000 (Thu, 04 Dec 2014) Log Message: ----------- Add public Modified Paths: -------------- trunk/lib/WikiDB/ADODB.php trunk/lib/WikiDB/PDO.php trunk/lib/WikiDB/SQL.php Modified: trunk/lib/WikiDB/ADODB.php =================================================================== --- trunk/lib/WikiDB/ADODB.php 2014-12-04 15:42:49 UTC (rev 9416) +++ trunk/lib/WikiDB/ADODB.php 2014-12-04 15:51:47 UTC (rev 9417) @@ -40,9 +40,9 @@ /** * Determine whether page exists (in non-default form). - * @see WikiDB::isWikiPage + * @see WikiDB::isWikiPage for the slow generic version */ - function isWikiPage($pagename) + public function isWikiPage($pagename) { $pagename = (string)$pagename; if ($pagename === '') { @@ -70,7 +70,7 @@ // ADODB handles everything as string // Don't add surrounding quotes '', same as in PearDB - function qstr($in) + public function qstr($in) { return $this->_backend->_dbh->addq($in); } @@ -90,7 +90,7 @@ // SQL result: for simple select or create/update queries // returns the database specific resource type - public function genericSqlQuery($sql, $args = false) + public function genericSqlQuery($sql, $args = array()) { if ($args) $result = $this->_backend->_dbh->Execute($sql, $args); @@ -105,7 +105,7 @@ } // SQL iter: for simple select or create/update queries - // returns the generic iterator object (count,next) + // returns the generic iterator object (count, next) public function genericSqlIter($sql, $field_list = NULL) { $result = $this->genericSqlQuery($sql); Modified: trunk/lib/WikiDB/PDO.php =================================================================== --- trunk/lib/WikiDB/PDO.php 2014-12-04 15:42:49 UTC (rev 9416) +++ trunk/lib/WikiDB/PDO.php 2014-12-04 15:51:47 UTC (rev 9417) @@ -30,17 +30,17 @@ } else { $backend = 'PDO'; } - include_once("lib/WikiDB/backend/$backend.php"); - $backend_class = "WikiDB_backend_$backend"; + include_once 'lib/WikiDB/backend/' . $backend . '.php'; + $backend_class = "WikiDB_backend_" . $backend; $backend = new $backend_class($dbparams); parent::__construct($backend, $dbparams); } /** * Determine whether page exists (in non-default form). - * @see WikiDB::isWikiPage + * @see WikiDB::isWikiPage for the slow generic version */ - function isWikiPage($pagename) + public function isWikiPage($pagename) { $pagename = (string)$pagename; if ($pagename === '') { @@ -69,7 +69,7 @@ // Don't add surrounding quotes '', same as in PearDB // PDO-0.2.1 added now ::quote() - function qstr($in) + public function qstr($in) { $in = str_replace(array('\\', "\0"), array('\\\\', "\\\0"), $in); return str_replace("'", "\'", $in); Modified: trunk/lib/WikiDB/SQL.php =================================================================== --- trunk/lib/WikiDB/SQL.php 2014-12-04 15:42:49 UTC (rev 9416) +++ trunk/lib/WikiDB/SQL.php 2014-12-04 15:51:47 UTC (rev 9417) @@ -23,7 +23,7 @@ parent::__construct($backend, $dbparams); } - static function view_dsn($dsn = false) + public static function view_dsn($dsn = false) { if (!$dsn) $dsninfo = DB::parseDSN($GLOBALS['DBParams']['dsn']); @@ -41,7 +41,7 @@ * Determine whether page exists (in non-default form). * @see WikiDB::isWikiPage for the slow generic version */ - function isWikiPage($pagename) + public function isWikiPage($pagename) { $pagename = (string)$pagename; if ($pagename === '') { @@ -60,7 +60,7 @@ } // no surrounding quotes because we know it's a string - function qstr($s) + public function qstr($s) { return $this->_backend->_dbh->escapeSimple($s); } @@ -80,7 +80,7 @@ // SQL result: for simple select or create/update queries // returns the database specific resource type - public function genericSqlQuery($sql, $args = false) + public function genericSqlQuery($sql, $args = array()) { if ($args) $result = $this->_backend->_dbh->query($sql, $args); @@ -96,7 +96,7 @@ } // SQL iter: for simple select or create/update queries - // returns the generic iterator object (count,next) + // returns the generic iterator object (count, next) public function genericSqlIter($sql, $field_list = NULL) { $result = $this->genericSqlQuery($sql); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2015-01-06 16:56:37
|
Revision: 9456 http://sourceforge.net/p/phpwiki/code/9456 Author: vargenau Date: 2015-01-06 16:56:26 +0000 (Tue, 06 Jan 2015) Log Message: ----------- function text_search must be public (reported by Harold Hallikainen); harmonize parameters Modified Paths: -------------- trunk/lib/WikiDB/backend/ADODB.php trunk/lib/WikiDB/backend/PDO.php trunk/lib/WikiDB/backend/PearDB.php trunk/lib/WikiDB/backend/PearDB_ffpgsql.php trunk/lib/WikiDB/backend/PearDB_pgsql.php trunk/lib/WikiDB/backend/cvs.php trunk/lib/WikiDB/backend.php Modified: trunk/lib/WikiDB/backend/ADODB.php =================================================================== --- trunk/lib/WikiDB/backend/ADODB.php 2015-01-06 16:19:51 UTC (rev 9455) +++ trunk/lib/WikiDB/backend/ADODB.php 2015-01-06 16:56:26 UTC (rev 9456) @@ -845,7 +845,8 @@ return $row[0]; } - function get_all_pages($include_empty = false, $sortby = '', $limit = '', $exclude = '') + public function get_all_pages($include_empty = false, + $sortby = '', $limit = '', $exclude = '') { $dbh = &$this->_dbh; extract($this->_table_names); @@ -909,8 +910,8 @@ /** * Title and fulltext search. */ - function text_search($search, $fullsearch = false, - $sortby = '', $limit = '', $exclude = '') + public function text_search($search, $fulltext = false, + $sortby = '', $limit = '', $exclude = '') { $dbh = &$this->_dbh; extract($this->_table_names); @@ -923,7 +924,7 @@ $field_list = $this->page_tbl_field_list; $searchobj = new WikiDB_backend_ADODB_search($search, $dbh); - if ($fullsearch) { + if ($fulltext) { $table .= ", $recent_tbl"; $join_clause .= " AND $page_tbl.id=$recent_tbl.id"; @@ -950,7 +951,7 @@ $result = $dbh->Execute($sql); } $iter = new WikiDB_backend_ADODB_iter($this, $result, $field_list); - if ($fullsearch) + if ($fulltext) $iter->stoplisted = $searchobj->stoplisted; return $iter; } Modified: trunk/lib/WikiDB/backend/PDO.php =================================================================== --- trunk/lib/WikiDB/backend/PDO.php 2015-01-06 16:19:51 UTC (rev 9455) +++ trunk/lib/WikiDB/backend/PDO.php 2015-01-06 16:56:26 UTC (rev 9456) @@ -832,7 +832,8 @@ return $sth->fetchColumn(); } - function get_all_pages($include_empty = false, $sortby = '', $limit = '', $exclude = '') + public function get_all_pages($include_empty = false, + $sortby = '', $limit = '', $exclude = '') { $dbh = &$this->_dbh; extract($this->_table_names); @@ -888,8 +889,8 @@ /** * Title and fulltext search. */ - function text_search($search, $fullsearch = false, - $sortby = '', $limit = '', $exclude = '') + public function text_search($search, $fulltext = false, + $sortby = '', $limit = '', $exclude = '') { $dbh = &$this->_dbh; extract($this->_table_names); @@ -903,7 +904,7 @@ $field_list = $this->page_tbl_field_list; $searchobj = new WikiDB_backend_PDO_search($search, $dbh); - if ($fullsearch) { + if ($fulltext) { $table .= ", $recent_tbl"; $join_clause .= " AND $page_tbl.id=$recent_tbl.id"; Modified: trunk/lib/WikiDB/backend/PearDB.php =================================================================== --- trunk/lib/WikiDB/backend/PearDB.php 2015-01-06 16:19:51 UTC (rev 9455) +++ trunk/lib/WikiDB/backend/PearDB.php 2015-01-06 16:56:26 UTC (rev 9456) @@ -648,7 +648,8 @@ return $row['result']; } - function get_all_pages($include_empty = false, $sortby = '', $limit = '', $exclude = '') + public function get_all_pages($include_empty = false, + $sortby = '', $limit = '', $exclude = '') { $dbh = &$this->_dbh; extract($this->_table_names); @@ -707,11 +708,11 @@ } /** - * Title search. + * Text search (title or full text) * Todo: exclude */ - function text_search($search, $fulltext = false, $sortby = '', $limit = '', - $exclude = '') + public function text_search($search, $fulltext = false, + $sortby = '', $limit = '', $exclude = '') { $dbh = &$this->_dbh; extract($this->_table_names); Modified: trunk/lib/WikiDB/backend/PearDB_ffpgsql.php =================================================================== --- trunk/lib/WikiDB/backend/PearDB_ffpgsql.php 2015-01-06 16:19:51 UTC (rev 9455) +++ trunk/lib/WikiDB/backend/PearDB_ffpgsql.php 2015-01-06 16:56:26 UTC (rev 9456) @@ -317,7 +317,8 @@ return new WikiDB_backend_PearDB_iter($this, $result); } - function get_all_pages($include_empty = false, $sortby = '', $limit = '', $exclude = '') + public function get_all_pages($include_empty = false, + $sortby = '', $limit = '', $exclude = '') { $dbh = &$this->_dbh; extract($this->_table_names); @@ -584,10 +585,10 @@ } /** - * Title search. + * Text search (title or full text) */ - function text_search($search, $fulltext = false, $sortby = '', $limit = '', - $exclude = '') + public function text_search($search, $fulltext = false, + $sortby = '', $limit = '', $exclude = '') { $dbh = &$this->_dbh; extract($this->_table_names); Modified: trunk/lib/WikiDB/backend/PearDB_pgsql.php =================================================================== --- trunk/lib/WikiDB/backend/PearDB_pgsql.php 2015-01-06 16:19:51 UTC (rev 9455) +++ trunk/lib/WikiDB/backend/PearDB_pgsql.php 2015-01-06 16:56:26 UTC (rev 9456) @@ -217,10 +217,10 @@ } /** - * Title search. + * Text search (title or full text) */ - function text_search($search, $fulltext = false, $sortby = '', $limit = '', - $exclude = '') + public function text_search($search, $fulltext = false, + $sortby = '', $limit = '', $exclude = '') { $dbh = &$this->_dbh; extract($this->_table_names); Modified: trunk/lib/WikiDB/backend/cvs.php =================================================================== --- trunk/lib/WikiDB/backend/cvs.php 2015-01-06 16:19:51 UTC (rev 9455) +++ trunk/lib/WikiDB/backend/cvs.php 2015-01-06 16:56:26 UTC (rev 9456) @@ -407,16 +407,18 @@ return new WikiDB_backend_dumb_AllRevisionsIter($this, $pagename); } */ - function get_all_pages($include_empty = false, $orderby = false, $limit = '', $exclude = '') + public function get_all_pages($include_empty = false, + $sortby = '', $limit = '', $exclude = '') { // FIXME: this ignores the parameters. return new Cvs_Backend_Array_Iterator( $this->_getAllFileNamesInDir($this->_docDir)); } - function text_search($search, $fullsearch = false, $orderby = false, $limit = '', $exclude = '') + public function text_search($search, $fulltext = false, + $sortby = '', $limit = '', $exclude = '') { - if ($fullsearch) { + if ($fulltext) { $iter = new Cvs_Backend_Full_Search_Iterator( $this->_getAllFileNamesInDir($this->_docDir), $search, Modified: trunk/lib/WikiDB/backend.php =================================================================== --- trunk/lib/WikiDB/backend.php 2015-01-06 16:19:51 UTC (rev 9455) +++ trunk/lib/WikiDB/backend.php 2015-01-06 16:56:26 UTC (rev 9456) @@ -307,7 +307,7 @@ * Pages should be returned in alphabetical order if that is * feasible. * - * @param bool $include_defaulted + * @param bool $include_empty * If set, even pages with no content will be returned * --- but still only if they have at least one revision (not * counting the default revision 0) entered in the database. @@ -316,12 +316,13 @@ * are not returned as these pages are considered to be * non-existing. * - * @param bool $orderby + * @param string $sortby * @param string $limit * @param string $exclude * @return object A WikiDB_backend_iterator. */ - abstract public function get_all_pages($include_defaulted, $orderby = false, $limit = '', $exclude = ''); + abstract public function get_all_pages($include_empty, + $sortby = '', $limit = '', $exclude = ''); /** * Title or full text search. @@ -343,8 +344,8 @@ * * @see WikiDB::titleSearch */ - protected function text_search($search, $fulltext = false, $sortby = '', - $limit = '', $exclude = '') + public function text_search($search, $fulltext = false, + $sortby = '', $limit = '', $exclude = '') { // This method implements a simple linear search // through all the pages in the database. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2015-01-14 16:37:49
|
Revision: 9478 http://sourceforge.net/p/phpwiki/code/9478 Author: vargenau Date: 2015-01-14 16:37:46 +0000 (Wed, 14 Jan 2015) Log Message: ----------- functions most_popular and most_recent are public Modified Paths: -------------- trunk/lib/WikiDB/backend/ADODB.php trunk/lib/WikiDB/backend/PDO.php trunk/lib/WikiDB/backend/PearDB.php trunk/lib/WikiDB/backend/PearDB_ffpgsql.php trunk/lib/WikiDB/backend/cvs.php trunk/lib/WikiDB/backend.php Modified: trunk/lib/WikiDB/backend/ADODB.php =================================================================== --- trunk/lib/WikiDB/backend/ADODB.php 2015-01-14 15:48:57 UTC (rev 9477) +++ trunk/lib/WikiDB/backend/ADODB.php 2015-01-14 16:37:46 UTC (rev 9478) @@ -974,7 +974,7 @@ /** * Find highest or lowest hit counts. */ - function most_popular($limit = 20, $sortby = '-hits') + public function most_popular($limit = 20, $sortby = '-hits') { $dbh = &$this->_dbh; extract($this->_table_names); @@ -1010,7 +1010,7 @@ /** * Find recent changes. */ - function most_recent($params) + public function most_recent($params) { $limit = 0; $since = 0; Modified: trunk/lib/WikiDB/backend/PDO.php =================================================================== --- trunk/lib/WikiDB/backend/PDO.php 2015-01-14 15:48:57 UTC (rev 9477) +++ trunk/lib/WikiDB/backend/PDO.php 2015-01-14 16:37:46 UTC (rev 9478) @@ -948,7 +948,7 @@ /** * Find highest or lowest hit counts. */ - function most_popular($limit = 20, $sortby = '-hits') + public function most_popular($limit = 20, $sortby = '-hits') { $dbh = &$this->_dbh; extract($this->_table_names); @@ -984,7 +984,7 @@ /** * Find recent changes. */ - function most_recent($params) + public function most_recent($params) { $limit = 0; $since = 0; Modified: trunk/lib/WikiDB/backend/PearDB.php =================================================================== --- trunk/lib/WikiDB/backend/PearDB.php 2015-01-14 15:48:57 UTC (rev 9477) +++ trunk/lib/WikiDB/backend/PearDB.php 2015-01-14 16:37:46 UTC (rev 9478) @@ -798,7 +798,7 @@ /** * Find highest or lowest hit counts. */ - function most_popular($limit = 20, $sortby = '-hits') + public function most_popular($limit = 20, $sortby = '-hits') { $dbh = &$this->_dbh; extract($this->_table_names); @@ -836,7 +836,7 @@ /** * Find recent changes. */ - function most_recent($params) + public function most_recent($params) { $limit = 0; $since = 0; Modified: trunk/lib/WikiDB/backend/PearDB_ffpgsql.php =================================================================== --- trunk/lib/WikiDB/backend/PearDB_ffpgsql.php 2015-01-14 15:48:57 UTC (rev 9477) +++ trunk/lib/WikiDB/backend/PearDB_ffpgsql.php 2015-01-14 16:37:46 UTC (rev 9478) @@ -385,7 +385,7 @@ return new WikiDB_backend_PearDB_iter($this, $result, $options); } - function most_popular($limit = 20, $sortby = '-hits') + public function most_popular($limit = 20, $sortby = '-hits') { $dbh = &$this->_dbh; extract($this->_table_names); @@ -424,7 +424,7 @@ return new WikiDB_backend_PearDB_iter($this, $result); } - function most_recent($params) + public function most_recent($params) { $limit = 0; $since = 0; Modified: trunk/lib/WikiDB/backend/cvs.php =================================================================== --- trunk/lib/WikiDB/backend/cvs.php 2015-01-14 15:48:57 UTC (rev 9477) +++ trunk/lib/WikiDB/backend/cvs.php 2015-01-14 16:37:46 UTC (rev 9478) @@ -432,7 +432,7 @@ } } - function most_popular($limit, $sortby = '') + public function most_popular($limit = 20, $sortby = '') { // TODO: needs to be tested ... $mp = $this->_getMostPopular(); @@ -455,7 +455,7 @@ * This only accepts the 'since' and 'limit' attributes, everything * else is ignored. */ - function most_recent($params) + public function most_recent($params) { // TODO: needs to be tested ... // most recent are those pages with the highest time value ... Modified: trunk/lib/WikiDB/backend.php =================================================================== --- trunk/lib/WikiDB/backend.php 2015-01-14 15:48:57 UTC (rev 9477) +++ trunk/lib/WikiDB/backend.php 2015-01-14 16:37:46 UTC (rev 9478) @@ -388,7 +388,7 @@ * @param string $sortby * @return object A WikiDB_backend_iterator. */ - protected function most_popular($limit, $sortby = '-hits') + public function most_popular($limit = 20, $sortby = '-hits') { // This is method fetches all pages, then // sorts them by hit count. @@ -409,7 +409,7 @@ * @return object A WikiDB_backend_iterator. * @see WikiDB::mostRecent */ - protected function most_recent($params) + public function most_recent($params) { // This method is very inefficient and searches through // all pages for the most recent changes. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2015-03-03 15:39:40
|
Revision: 9591 http://sourceforge.net/p/phpwiki/code/9591 Author: vargenau Date: 2015-03-03 15:39:31 +0000 (Tue, 03 Mar 2015) Log Message: ----------- fix prototype for _lock_tables and _unlock_tables; PHP Doc Modified Paths: -------------- trunk/lib/WikiDB/ADODB.php trunk/lib/WikiDB/PDO.php trunk/lib/WikiDB/SQL.php trunk/lib/WikiDB/backend/ADODB.php trunk/lib/WikiDB/backend/ADODB_mssql.php trunk/lib/WikiDB/backend/ADODB_mssqlnative.php trunk/lib/WikiDB/backend/ADODB_mysql.php trunk/lib/WikiDB/backend/ADODB_oci8po.php trunk/lib/WikiDB/backend/ADODB_postgres7.php trunk/lib/WikiDB/backend/PDO.php trunk/lib/WikiDB/backend/PDO_oci8.php trunk/lib/WikiDB/backend/PearDB.php trunk/lib/WikiDB/backend/PearDB_ffpgsql.php trunk/lib/WikiDB/backend/PearDB_mysql.php trunk/lib/WikiDB/backend/PearDB_oci8.php trunk/lib/WikiDB/backend/PearDB_pgsql.php trunk/lib/WikiDB/backend/PearDB_sqlite.php trunk/lib/WikiDB/backend/file.php trunk/lib/WikiDB/backend/flatfile.php trunk/lib/WikiDB/backend.php Modified: trunk/lib/WikiDB/ADODB.php =================================================================== --- trunk/lib/WikiDB/ADODB.php 2015-03-03 15:37:03 UTC (rev 9590) +++ trunk/lib/WikiDB/ADODB.php 2015-03-03 15:39:31 UTC (rev 9591) @@ -38,7 +38,7 @@ parent::__construct($backend, $dbparams); } - /** + /* * Determine whether page exists (in non-default form). * @see WikiDB::isWikiPage for the slow generic version */ Modified: trunk/lib/WikiDB/PDO.php =================================================================== --- trunk/lib/WikiDB/PDO.php 2015-03-03 15:37:03 UTC (rev 9590) +++ trunk/lib/WikiDB/PDO.php 2015-03-03 15:39:31 UTC (rev 9591) @@ -36,7 +36,7 @@ parent::__construct($backend, $dbparams); } - /** + /* * Determine whether page exists (in non-default form). * @see WikiDB::isWikiPage for the slow generic version */ Modified: trunk/lib/WikiDB/SQL.php =================================================================== --- trunk/lib/WikiDB/SQL.php 2015-03-03 15:37:03 UTC (rev 9590) +++ trunk/lib/WikiDB/SQL.php 2015-03-03 15:39:31 UTC (rev 9591) @@ -37,7 +37,7 @@ ); } - /** + /* * Determine whether page exists (in non-default form). * @see WikiDB::isWikiPage for the slow generic version */ Modified: trunk/lib/WikiDB/backend/ADODB.php =================================================================== --- trunk/lib/WikiDB/backend/ADODB.php 2015-03-03 15:37:03 UTC (rev 9590) +++ trunk/lib/WikiDB/backend/ADODB.php 2015-03-03 15:39:31 UTC (rev 9591) @@ -198,7 +198,7 @@ return; } - /** + /* * Read page information from database. */ function get_pagedata($pagename) @@ -367,7 +367,9 @@ /** * Get version data. * - * @param int $version Which version to get. + * @param string $pagename Name of the page + * @param int $version Which version to get + * @param bool $want_content Do we need content? * * @return array hash The version data, or false if specified version does not * exist. @@ -443,7 +445,7 @@ return $data; } - /** + /* * Create a new revision of a page. */ function set_versiondata($pagename, $version, $data) @@ -481,7 +483,7 @@ $this->unlock(array('page', 'recent', 'version', 'nonempty')); } - /** + /* * Delete an old revision of a page. */ function delete_versiondata($pagename, $version) @@ -501,7 +503,7 @@ $this->unlock(array('version')); } - /** + /* * Delete page from the database with backup possibility. * i.e save_page('') and DELETE nonempty id * @@ -557,9 +559,8 @@ } } - /** + /* * Delete page completely from the database. - * I'm not sure if this is what we want. Maybe just delete the revisions */ function purge_page($pagename) { @@ -760,7 +761,7 @@ return true; } - /** + /* * Find pages which link to or are linked from a page. * * Optimization: save request->_dbi->_iwpcache[] to avoid further iswikipage checks @@ -822,7 +823,7 @@ return new WikiDB_backend_ADODB_iter($this, $result, $fields); } - /** + /* * Find if a page links to another page */ function exists_link($pagename, $link, $reversed = false) @@ -906,7 +907,7 @@ return new WikiDB_backend_ADODB_iter($this, $result, $this->page_tbl_field_list); } - /** + /* * Title and fulltext search. */ public function text_search($search, $fulltext = false, @@ -970,7 +971,7 @@ return substr($s, 0, -1) . ")"; } - /** + /* * Find highest or lowest hit counts. */ public function most_popular($limit = 20, $sortby = '-hits') @@ -1006,7 +1007,7 @@ return new WikiDB_backend_ADODB_iter($this, $result, $this->page_tbl_field_list); } - /** + /* * Find recent changes. */ public function most_recent($params) @@ -1080,7 +1081,7 @@ array_merge($this->page_tbl_field_list, $this->version_tbl_field_list)); } - /** + /* * Find referenced empty pages. */ function wanted_pages($exclude_from = '', $exclude = '', $sortby = '', $limit = '') @@ -1122,7 +1123,7 @@ return new WikiDB_backend_ADODB_iter($this, $result, array('pagename', 'wantedfrom')); } - /** + /* * Rename page in the database. */ function rename_page($pagename, $to) @@ -1206,7 +1207,7 @@ $this->unlock(array('nonempty')); } - /** + /* * Grab a write lock on the tables in the SQL database. * * Calls can be nested. The tables won't be unlocked until @@ -1221,10 +1222,10 @@ } } - /** + /* * Overridden by non-transaction safe backends. */ - function _lock_tables($tables, $write_lock) + protected function _lock_tables($tables, $write_lock = true) { return $this->_current_lock; } @@ -1245,22 +1246,22 @@ return; } if (--$this->_lock_count <= 0 || $force) { - $this->_unlock_tables($tables, $force); + $this->_unlock_tables($tables); $this->_current_lock = false; $this->_lock_count = 0; } $this->_dbh->CompleteTrans(!$force); } - /** + /* * overridden by non-transaction safe backends */ - function _unlock_tables($tables, $write_lock = false) + protected function _unlock_tables($tables) { return; } - /** + /* * Serialize data */ function _serialize($data) @@ -1271,7 +1272,7 @@ return serialize($data); } - /** + /* * Unserialize data */ function _unserialize($data) Modified: trunk/lib/WikiDB/backend/ADODB_mssql.php =================================================================== --- trunk/lib/WikiDB/backend/ADODB_mssql.php 2015-03-03 15:37:03 UTC (rev 9590) +++ trunk/lib/WikiDB/backend/ADODB_mssql.php 2015-03-03 15:39:31 UTC (rev 9591) @@ -35,14 +35,14 @@ return true; } - /** + /* * Lock tables. * * We don't really need to lock exclusive, but I'll relax it when I fully * understand phpWiki locking ;-) * */ - function _lock_tables($tables, $write_lock = true) + protected function _lock_tables($tables, $write_lock = true) { if (!$tables) return; @@ -62,16 +62,16 @@ } } - /** + /* * Release the locks. */ - function _unlock_tables($tables) + protected function _unlock_tables($tables) { $dbh = &$this->_dbh; $dbh->Execute("COMMIT WORK"); } - // Search callabcks + // Search callbacks // Page name function _sql_match_clause($word) { @@ -89,7 +89,7 @@ . "OR CHARINDEX(content, '$word') > 0"; } - /** + /* * Serialize data */ function _serialize($data) @@ -100,7 +100,7 @@ return serialize(addslashes($data)); } - /** + /* * Unserialize data */ function _unserialize($data) Modified: trunk/lib/WikiDB/backend/ADODB_mssqlnative.php =================================================================== --- trunk/lib/WikiDB/backend/ADODB_mssqlnative.php 2015-03-03 15:37:03 UTC (rev 9590) +++ trunk/lib/WikiDB/backend/ADODB_mssqlnative.php 2015-03-03 15:39:31 UTC (rev 9591) @@ -53,7 +53,7 @@ . "OR CHARINDEX(content, '$word') > 0"; } - /** + /* * Serialize data */ function _serialize($data) @@ -64,7 +64,7 @@ return addslashes(serialize($data)); } - /** + /* * Unserialize data */ function _unserialize($data) Modified: trunk/lib/WikiDB/backend/ADODB_mysql.php =================================================================== --- trunk/lib/WikiDB/backend/ADODB_mysql.php 2015-03-03 15:37:03 UTC (rev 9590) +++ trunk/lib/WikiDB/backend/ADODB_mysql.php 2015-03-03 15:39:31 UTC (rev 9591) @@ -51,8 +51,8 @@ } } - /** - * Kill timed out processes. ( so far only called on about every 50-th save. ) + /* + * Kill timed out processes (so far only called on about every 50-th save). */ function _timeout() { @@ -70,7 +70,7 @@ } } - /** + /* * Pack tables. */ function optimize() @@ -83,7 +83,7 @@ return true; } - /** + /* * Lock tables. As fine-grained application lock, which locks only the * same transaction (conflicting updates and edits), and as full table * write lock. @@ -91,7 +91,7 @@ * New: which tables as params, * support nested locks via app locks */ - function _lock_tables($tables, $write_lock = true) + protected function _lock_tables($tables, $write_lock = true) { if (!$tables) return; if (DO_APP_LOCK) { @@ -113,11 +113,11 @@ } } - /** + /* * Release the locks. * Support nested locks */ - function _unlock_tables($tables) + protected function _unlock_tables($tables) { if (!$tables) { $this->_dbh->Execute("UNLOCK TABLES"); @@ -187,7 +187,7 @@ return $id; } - /** + /* * Create a new revision of a page. */ function set_versiondata($pagename, $version, $data) Modified: trunk/lib/WikiDB/backend/ADODB_oci8po.php =================================================================== --- trunk/lib/WikiDB/backend/ADODB_oci8po.php 2015-03-03 15:37:03 UTC (rev 9590) +++ trunk/lib/WikiDB/backend/ADODB_oci8po.php 2015-03-03 15:39:31 UTC (rev 9591) @@ -38,14 +38,14 @@ return true; } - /** + /* * Lock tables. * * We don't really need to lock exclusive, but I'll relax it when I fully * understand phpWiki locking ;-) * */ - function _lock_tables($tables, $write_lock = true) + protected function _lock_tables($tables, $write_lock = true) { if (!$tables) return; @@ -65,10 +65,10 @@ } } - /** + /* * Release the locks. */ - function _unlock_tables($tables) + protected function _unlock_tables($tables) { $dbh = &$this->_dbh; $dbh->Execute("COMMIT WORK"); @@ -97,7 +97,7 @@ } */ - /** + /* * Serialize data */ function _serialize($data) @@ -108,7 +108,7 @@ return $this->_dbh->BlobEncode(serialize($data)); } - /** + /* * Unserialize data */ function _unserialize($data) Modified: trunk/lib/WikiDB/backend/ADODB_postgres7.php =================================================================== --- trunk/lib/WikiDB/backend/ADODB_postgres7.php 2015-03-03 15:37:03 UTC (rev 9590) +++ trunk/lib/WikiDB/backend/ADODB_postgres7.php 2015-03-03 15:39:31 UTC (rev 9591) @@ -98,25 +98,25 @@ } } - /** + /* * Lock all tables we might use. * postgresql has proper transactions so we dont need table locks. */ - function _lock_tables($tables, $write_lock = true) + protected function _lock_tables($tables, $write_lock = true) { ; } - /** + /* * Unlock all tables. * postgresql has proper transactions so we dont need table locks. */ - function _unlock_tables($tables, $write_lock = false) + protected function _unlock_tables($tables) { ; } - /** + /* * Serialize data */ function _serialize($data) @@ -127,7 +127,7 @@ return $this->_quote(serialize($data)); } - /** + /* * Unserialize data */ function _unserialize($data) Modified: trunk/lib/WikiDB/backend/PDO.php =================================================================== --- trunk/lib/WikiDB/backend/PDO.php 2015-03-03 15:37:03 UTC (rev 9590) +++ trunk/lib/WikiDB/backend/PDO.php 2015-03-03 15:39:31 UTC (rev 9591) @@ -265,7 +265,7 @@ $sth->execute(); } - /** + /* * Read page information from database. */ function get_pagedata($pagename) @@ -448,7 +448,9 @@ /** * Get version data. * - * @param $version int Which version to get. + * @param string $pagename Name of the page + * @param int $version Which version to get + * @param bool $want_content Do we need content? * * @return array hash The version data, or false if specified version does not * exist. @@ -526,7 +528,7 @@ return $data; } - /** + /* * Create a new revision of a page. */ function set_versiondata($pagename, $version, $data) @@ -585,7 +587,7 @@ $this->unlock(array('page', 'recent', 'version', 'nonempty')); } - /** + /* * Delete an old revision of a page. */ function delete_versiondata($pagename, $version) @@ -605,7 +607,7 @@ $this->unlock(array('version')); } - /** + /* * Delete page from the database with backup possibility. * i.e save_page('') and DELETE nonempty id * @@ -671,9 +673,8 @@ } } - /** + /* * Delete page completely from the database. - * I'm not sure if this is what we want. Maybe just delete the revisions */ function purge_page($pagename) { @@ -761,7 +762,7 @@ return true; } - /** + /* * Find pages which link to or are linked from a page. * * Optimization: save request->_dbi->_iwpcache[] to avoid further iswikipage checks @@ -804,7 +805,7 @@ return new WikiDB_backend_PDO_iter($this, $result, $this->page_tbl_field_list); } - /** + /* * Find if a page links to another page */ function exists_link($pagename, $link, $reversed = false) @@ -881,7 +882,7 @@ return new WikiDB_backend_PDO_iter($this, $result, $this->page_tbl_field_list); } - /** + /* * Title and fulltext search. */ public function text_search($search, $fulltext = false, @@ -940,7 +941,7 @@ return substr($s, 0, -1) . ")"; } - /** + /* * Find highest or lowest hit counts. */ public function most_popular($limit = 20, $sortby = '-hits') @@ -976,7 +977,7 @@ return new WikiDB_backend_PDO_iter($this, $result, $this->page_tbl_field_list); } - /** + /* * Find recent changes. */ public function most_recent($params) @@ -1048,7 +1049,7 @@ array_merge($this->page_tbl_field_list, $this->version_tbl_field_list)); } - /** + /* * Find referenced empty pages. */ function wanted_pages($exclude_from = '', $exclude = '', $sortby = '', $limit = '') @@ -1090,7 +1091,7 @@ return new WikiDB_backend_PDO_iter($this, $result, array('pagename', 'wantedfrom')); } - /** + /* * Rename page in the database. */ function rename_page($pagename, $to) @@ -1179,7 +1180,7 @@ $this->unlock(array('nonempty')); } - /** + /* * Grab a write lock on the tables in the SQL database. * * Calls can be nested. The tables won't be unlocked until @@ -1194,10 +1195,10 @@ } } - /** + /* * Overridden by non-transaction safe backends. */ - function _lock_tables($tables, $write_lock) + protected function _lock_tables($tables, $write_lock = true) { $lock_type = $write_lock ? "WRITE" : "READ"; foreach ($this->_table_names as $key => $table) { @@ -1209,7 +1210,8 @@ /** * 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 @@ -1222,21 +1224,21 @@ } if (--$this->_lock_count <= 0 || $force) { if (!$this->_hasTransactions) - $this->_unlock_tables($tables); + $this->_unlock_tables(); $this->_current_lock = false; $this->_lock_count = 0; } } - /** + /* * overridden by non-transaction safe backends */ - function _unlock_tables($tables) + protected function _unlock_tables() { $this->_dbh->query("UNLOCK TABLES"); } - /** + /* * Serialize data */ function _serialize($data) @@ -1247,7 +1249,7 @@ return serialize($data); } - /** + /* * Unserialize data */ function _unserialize($data) Modified: trunk/lib/WikiDB/backend/PDO_oci8.php =================================================================== --- trunk/lib/WikiDB/backend/PDO_oci8.php 2015-03-03 15:37:03 UTC (rev 9590) +++ trunk/lib/WikiDB/backend/PDO_oci8.php 2015-03-03 15:39:31 UTC (rev 9591) @@ -36,10 +36,10 @@ return true; } - /** + /* * Lock all tables we might use. */ - function _lock_tables($write_lock = true) + protected function _lock_tables($tables, $write_lock = true) { $dbh = &$this->_dbh; Modified: trunk/lib/WikiDB/backend/PearDB.php =================================================================== --- trunk/lib/WikiDB/backend/PearDB.php 2015-03-03 15:37:03 UTC (rev 9590) +++ trunk/lib/WikiDB/backend/PearDB.php 2015-03-03 15:39:31 UTC (rev 9591) @@ -173,7 +173,7 @@ $dbh->escapeSimple($pagename))); } - /** + /* * Read page information from database. */ function get_pagedata($pagename) @@ -339,7 +339,9 @@ /** * Get version data. * - * @param $version int Which version to get. + * @param string $pagename Name of the page + * @param int $version Which version to get + * @param bool $want_content Do we need content? * * @return array hash The version data, or false if specified version does not * exist. @@ -408,7 +410,7 @@ return $data; } - /** + /* * Create a new revision of a page. */ function set_versiondata($pagename, $version, $data) @@ -446,7 +448,7 @@ $this->unlock(); } - /** + /* * Delete an old revision of a page. */ function delete_versiondata($pagename, $version) @@ -466,7 +468,7 @@ $this->unlock(); } - /** + /* * Delete page from the database with backup possibility. * i.e save_page('') and DELETE nonempty id * Can be undone and is seen in RecentChanges. @@ -489,9 +491,8 @@ } */ - /** + /* * Delete page completely from the database. - * I'm not sure if this is what we want. Maybe just delete the revisions */ function purge_page($pagename) { @@ -576,7 +577,7 @@ $this->unlock(); } - /** + /* * Find pages which link to or are linked from a page. * * TESTME relations: get_links is responsible to add the relation to the pagehash @@ -625,7 +626,7 @@ return new WikiDB_backend_PearDB_iter($this, $result); } - /** + /* * Find if a page links to another page */ function exists_link($pagename, $link, $reversed = false) @@ -706,7 +707,7 @@ return new WikiDB_backend_PearDB_iter($this, $result, $options); } - /** + /* * Text search (title or full text) * Todo: exclude */ @@ -794,7 +795,7 @@ return "pagename LIKE '%$word%' OR content LIKE '%$word%'"; } - /** + /* * Find highest or lowest hit counts. */ public function most_popular($limit = 20, $sortby = '-hits') @@ -832,7 +833,7 @@ return new WikiDB_backend_PearDB_iter($this, $result); } - /** + /* * Find recent changes. */ public function most_recent($params) @@ -905,7 +906,7 @@ return new WikiDB_backend_PearDB_iter($this, $result); } - /** + /* * Find referenced empty pages. */ function wanted_pages($exclude_from = '', $exclude = '', $sortby = '', $limit = '') @@ -947,7 +948,7 @@ return substr($s, 0, -1) . ")"; } - /** + /* * Rename page in the database. */ function rename_page($pagename, $to) @@ -1019,7 +1020,7 @@ $this->unlock(); } - /** + /* * Grab a write lock on the tables in the SQL database. * * Calls can be nested. The tables won't be unlocked until @@ -1031,10 +1032,10 @@ $this->_lock_tables($write_lock); } - /** + /* * Actually lock the required tables. */ - function _lock_tables($write_lock) + protected function _lock_tables($write_lock = true) { trigger_error("virtual", E_USER_ERROR); } @@ -1042,6 +1043,7 @@ /** * Release a write lock on the tables in the SQL database. * + * @param array $tables * @param bool $force Unlock even if not every call to lock() has been matched * by a call to unlock(). * @@ -1061,12 +1063,12 @@ /** * Actually unlock the required tables. */ - function _unlock_tables($write_lock) + protected function _unlock_tables() { trigger_error("virtual", E_USER_ERROR); } - /** + /* * Serialize data */ function _serialize($data) @@ -1077,7 +1079,7 @@ return serialize($data); } - /** + /* * Unserialize data */ function _unserialize($data) @@ -1088,7 +1090,7 @@ /** * Callback for PEAR (DB) errors. * - * @param A PEAR_error object. + * @param $error PEAR_error object. */ public function _pear_error_callback($error) { @@ -1100,7 +1102,7 @@ trigger_error($this->_pear_error_message($error), E_USER_ERROR); } - /** + /* * Detect false errors messages from PEAR DB. * * The version of PEAR DB which ships with PHP 4.0.6 has a bug in that @@ -1153,7 +1155,7 @@ return str_replace($this->_dsn, $safe_dsn, $message); } - /** + /* * Filter PHP errors notices from PEAR DB code. * * The PEAR DB code which ships with PHP 4.0.6 produces spurious Modified: trunk/lib/WikiDB/backend/PearDB_ffpgsql.php =================================================================== --- trunk/lib/WikiDB/backend/PearDB_ffpgsql.php 2015-03-03 15:37:03 UTC (rev 9590) +++ trunk/lib/WikiDB/backend/PearDB_ffpgsql.php 2015-03-03 15:39:31 UTC (rev 9591) @@ -604,7 +604,7 @@ return true; } - /** + /* * Text search (title or full text) */ public function text_search($search, $fulltext = false, @@ -709,7 +709,7 @@ } } - /** + /* * use tsearch2. See schemas/psql-tsearch2.sql and /usr/share/postgresql/contrib/tsearch2.sql * TODO: don't parse the words into nodes. rather replace "[ +]" with & and "-" with "!" and " or " with "|" * tsearch2 query language: @@ "word | word", "word & word", ! word Modified: trunk/lib/WikiDB/backend/PearDB_mysql.php =================================================================== --- trunk/lib/WikiDB/backend/PearDB_mysql.php 2015-03-03 15:37:03 UTC (rev 9590) +++ trunk/lib/WikiDB/backend/PearDB_mysql.php 2015-03-03 15:39:31 UTC (rev 9591) @@ -50,7 +50,7 @@ } } - /** + /* * Create a new revision of a page. */ function set_versiondata($pagename, $version, $data) @@ -169,10 +169,10 @@ return true; } - /** + /* * Lock tables. */ - function _lock_tables($write_lock = true) + protected function _lock_tables($write_lock = true) { $lock_type = $write_lock ? "WRITE" : "READ"; foreach ($this->_table_names as $table) { @@ -181,10 +181,10 @@ $this->_dbh->query("LOCK TABLES " . join(",", $tables)); } - /** + /* * Release all locks. */ - function _unlock_tables() + protected function _unlock_tables() { $this->_dbh->query("UNLOCK TABLES"); } Modified: trunk/lib/WikiDB/backend/PearDB_oci8.php =================================================================== --- trunk/lib/WikiDB/backend/PearDB_oci8.php 2015-03-03 15:37:03 UTC (rev 9590) +++ trunk/lib/WikiDB/backend/PearDB_oci8.php 2015-03-03 15:39:31 UTC (rev 9591) @@ -41,10 +41,10 @@ return true; } - /** + /* * Lock all tables we might use. */ - function _lock_tables($write_lock = true) + protected function _lock_tables($write_lock = true) { $dbh = &$this->_dbh; Modified: trunk/lib/WikiDB/backend/PearDB_pgsql.php =================================================================== --- trunk/lib/WikiDB/backend/PearDB_pgsql.php 2015-03-03 15:37:03 UTC (rev 9590) +++ trunk/lib/WikiDB/backend/PearDB_pgsql.php 2015-03-03 15:39:31 UTC (rev 9591) @@ -81,7 +81,7 @@ array($this->_quote($data), $pagename)); } - /** + /* * Create a new revision of a page. */ function _todo_set_versiondata($pagename, $version, $data) @@ -113,7 +113,7 @@ $this->unlock(); } - /** + /* * Delete an old revision of a page. */ function _todo_delete_versiondata($pagename, $version) @@ -123,7 +123,7 @@ $dbh->query(sprintf("SELECT delete_versiondata (%d, %d)", $id, $version)); } - /** + /* * Rename page in the database. */ function _todo_rename_page($pagename, $to) @@ -146,23 +146,23 @@ return $id; } - /** + /* * Lock all tables we might use. */ - function _lock_tables($write_lock = true) + protected function _lock_tables($write_lock = true) { $this->_dbh->query("BEGIN"); } - /** + /* * Unlock all tables. */ - function _unlock_tables() + protected function _unlock_tables() { $this->_dbh->query("COMMIT"); } - /** + /* * Serialize data */ function _serialize($data) @@ -173,7 +173,7 @@ return $this->_quote(serialize($data)); } - /** + /* * Unserialize data */ function _unserialize($data) @@ -187,7 +187,7 @@ return unserialize($this->_unquote($data)); } - /** + /* * Text search (title or full text) */ public function text_search($search, $fulltext = false, @@ -280,21 +280,20 @@ default | 39 | 124 */ - /** + /* * use tsearch2. See schemas/psql-tsearch2.sql and /usr/share/postgresql/contrib/tsearch2.sql * TODO: don't parse the words into nodes. rather replace "[ +]" with & and "-" with "!" and " or " with "|" * tsearch2 query language: @@ "word | word", "word & word", ! word * ~* '.*something that does not exist.*' + * + * phrase search for "history lesson": + * + * SELECT id FROM tab WHERE ts_idx_col @@ to_tsquery('history&lesson') + * AND text_col ~* '.*history\\s+lesson.*'; + * + * The full-text index will still be used, and the regex will be used to + * prune the results afterwards. */ - /* - phrase search for "history lesson": - - SELECT id FROM tab WHERE ts_idx_col @@ to_tsquery('history&lesson') - AND text_col ~* '.*history\\s+lesson.*'; - - The full-text index will still be used, and the regex will be used to - prune the results afterwards. - */ function _fulltext_match_clause($node) { $word = strtolower($node->word); Modified: trunk/lib/WikiDB/backend/PearDB_sqlite.php =================================================================== --- trunk/lib/WikiDB/backend/PearDB_sqlite.php 2015-03-03 15:37:03 UTC (rev 9590) +++ trunk/lib/WikiDB/backend/PearDB_sqlite.php 2015-03-03 15:39:31 UTC (rev 9591) @@ -22,7 +22,7 @@ class WikiDB_backend_PearDB_sqlite extends WikiDB_backend_PearDB { - /** + /* * Pack tables. */ function optimize() @@ -31,23 +31,23 @@ // NOP } - /** + /* * Lock tables. */ - function _lock_tables($write_lock = true) + protected function _lock_tables($write_lock = true) { // NOP - SQLite does all locking automatically } - /** + /* * Release all locks. */ - function _unlock_tables() + protected function _unlock_tables() { // NOP } - /** + /* * Serialize data */ function _serialize($data) @@ -58,7 +58,7 @@ return base64_encode(serialize($data)); } - /** + /* * Unserialize data */ function _unserialize($data) Modified: trunk/lib/WikiDB/backend/file.php =================================================================== --- trunk/lib/WikiDB/backend/file.php 2015-03-03 15:37:03 UTC (rev 9590) +++ trunk/lib/WikiDB/backend/file.php 2015-03-03 15:39:31 UTC (rev 9591) @@ -311,8 +311,7 @@ * * @param string $pagename Page name. * @param array $newdata hash New meta-data. - */ - /** + * * This will create a new page if page being requested does not * exist. */ @@ -397,7 +396,7 @@ return $vd; } - /** + /* * Rename all files for this page */ public function rename_page($pagename, $to) @@ -414,7 +413,7 @@ return true; } - /** + /* * See ADODB for a better delete_page(), which can be undone and is seen in RecentChanges. */ function delete_page($pagename) @@ -532,8 +531,13 @@ /** * Find pages which link to or are linked from a page. * - * @param $pagename string Page name. - * @param $reversed boolean True to get backlinks. + * @param string $pagename Page name. + * @param bool $reversed True to get backlinks. + * @param bool $include_empty True to get empty pages + * @param string $sortby + * @param string $limit + * @param string $exclude Pages to exclude. + * @param bool $want_relations True to get relations. * * FIXME: array or iterator? * @return object A WikiDB_backend_iterator. @@ -579,7 +583,7 @@ * Pages should be returned in alphabetical order if that is * feasable. * - * @param $include_defaulted boolean + * @param bool $include_empty * If set, even pages with no content will be returned * --- but still only if they have at least one revision (not * counting the default revision 0) entered in the database. @@ -588,6 +592,10 @@ * are not returned as these pages are considered to be * non-existing. * + * @param string $sortby + * @param string $limit + * @param string $exclude + * * @return object A WikiDB_backend_iterator. */ public function get_all_pages($include_empty = false, $sortby = '', $limit = '', $exclude = '') @@ -622,28 +630,28 @@ return count($this->_latest_versions); } - /** + /* * Lock backend database. */ function lock($tables = array(), $write_lock = true) { } - /** + /* * Unlock backend database. */ function unlock($tables = array(), $force = false) { } - /** + /* * Close database. */ function close() { } - /** + /* * Synchronize with filesystem. * * This should flush all unwritten data to the filesystem. @@ -652,7 +660,7 @@ { } - /** + /* * Optimize the database. */ function optimize() Modified: trunk/lib/WikiDB/backend/flatfile.php =================================================================== --- trunk/lib/WikiDB/backend/flatfile.php 2015-03-03 15:37:03 UTC (rev 9590) +++ trunk/lib/WikiDB/backend/flatfile.php 2015-03-03 15:39:31 UTC (rev 9591) @@ -97,7 +97,7 @@ return array(); // no values found } - /** Store latest version as full page_data flatfile, + /* Store latest version as full page_data flatfile, * earlier versions as file backend ver_data. * _cached_html will not be stored. * If the given ($pagename,$version) is already in the database, Modified: trunk/lib/WikiDB/backend.php =================================================================== --- trunk/lib/WikiDB/backend.php 2015-03-03 15:37:03 UTC (rev 9590) +++ trunk/lib/WikiDB/backend.php 2015-03-03 15:39:31 UTC (rev 9591) @@ -547,7 +547,7 @@ return array($words, $exclude); } - /** + /* * Split the given limit parameter into offset,limit. (offset is optional. default: 0) * Duplicate the PageList function here to avoid loading the whole PageList.php * Usage: @@ -571,7 +571,7 @@ } } - /** + /* * Handle sortby requests for the DB iterator and table header links. * Prefix the column with + or - like "+pagename","-mtime", ... * supported actions: 'flip_order' "mtime" => "+mtime" => "-mtime" ... This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2016-10-07 16:33:49
|
Revision: 9947 http://sourceforge.net/p/phpwiki/code/9947 Author: vargenau Date: 2016-10-07 16:33:46 +0000 (Fri, 07 Oct 2016) Log Message: ----------- Add SPDX-License-Identifier Modified Paths: -------------- trunk/lib/WikiDB/ADODB.php trunk/lib/WikiDB/PDO.php trunk/lib/WikiDB/SQL.php trunk/lib/WikiDB/backend.php trunk/lib/WikiDB/dba.php trunk/lib/WikiDB/file.php trunk/lib/WikiDB/flatfile.php Modified: trunk/lib/WikiDB/ADODB.php =================================================================== --- trunk/lib/WikiDB/ADODB.php 2016-10-07 16:32:07 UTC (rev 9946) +++ trunk/lib/WikiDB/ADODB.php 2016-10-07 16:33:46 UTC (rev 9947) @@ -1,4 +1,26 @@ <?php +/** + * Copyright © 2004-2010 $ThePhpWikiProgrammingTeam + * + * This file is part of PhpWiki. + * + * PhpWiki is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * PhpWiki is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with PhpWiki; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * SPDX-License-Identifier: GPL-2.0+ + * + */ require_once 'lib/WikiDB.php'; @@ -10,6 +32,7 @@ * * @author: Lawrence Akka, Reini Urban */ + class WikiDB_ADODB extends WikiDB { function __construct($dbparams) Modified: trunk/lib/WikiDB/PDO.php =================================================================== --- trunk/lib/WikiDB/PDO.php 2016-10-07 16:32:07 UTC (rev 9946) +++ trunk/lib/WikiDB/PDO.php 2016-10-07 16:33:46 UTC (rev 9947) @@ -1,4 +1,26 @@ <?php +/** + * Copyright © 2004-2010 $ThePhpWikiProgrammingTeam + * + * This file is part of PhpWiki. + * + * PhpWiki is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * PhpWiki is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with PhpWiki; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * SPDX-License-Identifier: GPL-2.0+ + * + */ require_once 'lib/WikiDB.php'; @@ -16,6 +38,7 @@ * * @author: Reini Urban */ + class WikiDB_PDO extends WikiDB { function __construct($dbparams) Modified: trunk/lib/WikiDB/SQL.php =================================================================== --- trunk/lib/WikiDB/SQL.php 2016-10-07 16:32:07 UTC (rev 9946) +++ trunk/lib/WikiDB/SQL.php 2016-10-07 16:33:46 UTC (rev 9947) @@ -1,4 +1,26 @@ <?php +/** + * Copyright © 2004-2010 $ThePhpWikiProgrammingTeam + * + * This file is part of PhpWiki. + * + * PhpWiki is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * PhpWiki is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with PhpWiki; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * SPDX-License-Identifier: GPL-2.0+ + * + */ require_once 'lib/WikiDB.php'; Modified: trunk/lib/WikiDB/backend.php =================================================================== --- trunk/lib/WikiDB/backend.php 2016-10-07 16:32:07 UTC (rev 9946) +++ trunk/lib/WikiDB/backend.php 2016-10-07 16:33:46 UTC (rev 9947) @@ -1,7 +1,6 @@ <?php - -/* - * Copyright 2004-2010 Reini Urban +/** + * Copyright © 2004-2010 Reini Urban * * This file is part of PhpWiki. * @@ -18,40 +17,43 @@ * You should have received a copy of the GNU General Public License along * with PhpWiki; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * SPDX-License-Identifier: GPL-2.0+ + * */ /* - Pagedata + * Pagedata + * + * maintained by WikiPage + * //:latestversion + * //:deleted (*) (Set if latest content is empty.) + * //:pagename (*) + * + * hits + * is_locked + * + * Versiondata + * + * %content (?should this be here?) + * _supplanted : Time version ceased to be the current version + * + * mtime (*) : Time of version edit. + * orig_mtime + * is_minor_edit (*) + * author : nominal author + * author_id : authenticated author + * summary + * + * //version + * //created (*) + * //%superceded + * + * //:serial + * + * (types are scalars: strings, ints, bools) + */ - maintained by WikiPage - //:latestversion - //:deleted (*) (Set if latest content is empty.) - //:pagename (*) - - hits - is_locked - - Versiondata - - %content (?should this be here?) - _supplanted : Time version ceased to be the current version - - mtime (*) : Time of version edit. - orig_mtime - is_minor_edit (*) - author : nominal author - author_id : authenticated author - summary - - //version - //created (*) - //%superceded - - //:serial - - (types are scalars: strings, ints, bools) -*/ - /** * A WikiDB_backend handles the storage and retrieval of data for a WikiDB. * @@ -69,6 +71,7 @@ * @access protected * @see WikiDB */ + abstract class WikiDB_backend { public $_sortby; Modified: trunk/lib/WikiDB/dba.php =================================================================== --- trunk/lib/WikiDB/dba.php 2016-10-07 16:32:07 UTC (rev 9946) +++ trunk/lib/WikiDB/dba.php 2016-10-07 16:33:46 UTC (rev 9947) @@ -1,4 +1,26 @@ <?php +/** + * Copyright © 2004-2010 $ThePhpWikiProgrammingTeam + * + * This file is part of PhpWiki. + * + * PhpWiki is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * PhpWiki is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with PhpWiki; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * SPDX-License-Identifier: GPL-2.0+ + * + */ require_once 'lib/WikiDB.php'; require_once 'lib/WikiDB/backend/dba.php'; Modified: trunk/lib/WikiDB/file.php =================================================================== --- trunk/lib/WikiDB/file.php 2016-10-07 16:32:07 UTC (rev 9946) +++ trunk/lib/WikiDB/file.php 2016-10-07 16:33:46 UTC (rev 9947) @@ -1,7 +1,6 @@ <?php - /** - * Copyright 1999, 2000, 2001, 2002, 2003 $ThePhpWikiProgrammingTeam + * Copyright © 1999, 2000, 2001, 2002, 2003 $ThePhpWikiProgrammingTeam * * This file is part of PhpWiki. * @@ -18,6 +17,9 @@ * You should have received a copy of the GNU General Public License along * with PhpWiki; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * SPDX-License-Identifier: GPL-2.0+ + * */ require_once 'lib/WikiDB.php'; @@ -29,6 +31,7 @@ * Authors: Gerrit Riessen, ger...@op... * Jochen Kalmbach <Jo...@Ka...> */ + class WikiDB_file extends WikiDB { function __construct($dbparams) Modified: trunk/lib/WikiDB/flatfile.php =================================================================== --- trunk/lib/WikiDB/flatfile.php 2016-10-07 16:32:07 UTC (rev 9946) +++ trunk/lib/WikiDB/flatfile.php 2016-10-07 16:33:46 UTC (rev 9947) @@ -1,7 +1,6 @@ <?php - /** - * Copyright 1999, 2005 $ThePhpWikiProgrammingTeam + * Copyright © 1999, 2005 $ThePhpWikiProgrammingTeam * * This file is part of PhpWiki. * @@ -18,6 +17,9 @@ * You should have received a copy of the GNU General Public License along * with PhpWiki; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * SPDX-License-Identifier: GPL-2.0+ + * */ require_once 'lib/WikiDB.php'; @@ -28,6 +30,7 @@ * flatfile has readable (mimified) page_data files, the rest is the * same as in the file backend (serialized arrays). */ + class WikiDB_flatfile extends WikiDB { function __construct($dbparams) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2016-10-07 16:41:54
|
Revision: 9948 http://sourceforge.net/p/phpwiki/code/9948 Author: vargenau Date: 2016-10-07 16:41:52 +0000 (Fri, 07 Oct 2016) Log Message: ----------- Fix Copyright Modified Paths: -------------- trunk/lib/WikiDB/ADODB.php trunk/lib/WikiDB/PDO.php trunk/lib/WikiDB/SQL.php trunk/lib/WikiDB/dba.php Modified: trunk/lib/WikiDB/ADODB.php =================================================================== --- trunk/lib/WikiDB/ADODB.php 2016-10-07 16:33:46 UTC (rev 9947) +++ trunk/lib/WikiDB/ADODB.php 2016-10-07 16:41:52 UTC (rev 9948) @@ -1,6 +1,8 @@ <?php /** - * Copyright © 2004-2010 $ThePhpWikiProgrammingTeam + * Copyright © 2001,2003 Jeff Dairiki + * Copyright © 2001-2002 Carsten Klapp + * Copyright © 2004-2010 Reini Urban * * This file is part of PhpWiki. * Modified: trunk/lib/WikiDB/PDO.php =================================================================== --- trunk/lib/WikiDB/PDO.php 2016-10-07 16:33:46 UTC (rev 9947) +++ trunk/lib/WikiDB/PDO.php 2016-10-07 16:41:52 UTC (rev 9948) @@ -1,6 +1,6 @@ <?php /** - * Copyright © 2004-2010 $ThePhpWikiProgrammingTeam + * Copyright © 2005 Reini Urban * * This file is part of PhpWiki. * Modified: trunk/lib/WikiDB/SQL.php =================================================================== --- trunk/lib/WikiDB/SQL.php 2016-10-07 16:33:46 UTC (rev 9947) +++ trunk/lib/WikiDB/SQL.php 2016-10-07 16:41:52 UTC (rev 9948) @@ -1,6 +1,7 @@ <?php /** - * Copyright © 2004-2010 $ThePhpWikiProgrammingTeam + * Copyright © 2001,2003 Jeff Dairiki + * Copyright © 2004-2005,2007,2009 Reini Urban * * This file is part of PhpWiki. * Modified: trunk/lib/WikiDB/dba.php =================================================================== --- trunk/lib/WikiDB/dba.php 2016-10-07 16:33:46 UTC (rev 9947) +++ trunk/lib/WikiDB/dba.php 2016-10-07 16:41:52 UTC (rev 9948) @@ -1,6 +1,9 @@ <?php /** - * Copyright © 2004-2010 $ThePhpWikiProgrammingTeam + * Copyright © 2001 Jeff Dairiki + * Copyright © 2001 Carsten Klapp + * Copyright © 2004-2005 Reini Urban + * Copyright © 2005 Joel Uckelman * * This file is part of PhpWiki. * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2021-08-11 10:40:11
|
Revision: 10486 http://sourceforge.net/p/phpwiki/code/10486 Author: vargenau Date: 2021-08-11 10:40:09 +0000 (Wed, 11 Aug 2021) Log Message: ----------- Use same parameter name as parent Modified Paths: -------------- trunk/lib/WikiDB/ADODB.php trunk/lib/WikiDB/PDO.php Modified: trunk/lib/WikiDB/ADODB.php =================================================================== --- trunk/lib/WikiDB/ADODB.php 2021-08-11 10:38:12 UTC (rev 10485) +++ trunk/lib/WikiDB/ADODB.php 2021-08-11 10:40:09 UTC (rev 10486) @@ -80,16 +80,16 @@ } // add surrounding quotes '' if string - public function quote($in) + public function quote($s) { - if (is_int($in) || is_double($in)) { - return $in; - } elseif (is_bool($in)) { - return $in ? 1 : 0; - } elseif (is_null($in)) { + if (is_int($s) || is_double($s)) { + return $s; + } elseif (is_bool($s)) { + return $s ? 1 : 0; + } elseif (is_null($s)) { return 'NULL'; } else { - return $this->_backend->_dbh->qstr($in); + return $this->_backend->_dbh->qstr($s); } } Modified: trunk/lib/WikiDB/PDO.php =================================================================== --- trunk/lib/WikiDB/PDO.php 2021-08-11 10:38:12 UTC (rev 10485) +++ trunk/lib/WikiDB/PDO.php 2021-08-11 10:40:09 UTC (rev 10486) @@ -77,16 +77,16 @@ // With PDO we should really use native quoting using prepared statements with ? // Add surrounding quotes '' if string - public function quote($in) + public function quote($s) { - if (is_int($in) || is_double($in)) { - return $in; - } elseif (is_bool($in)) { - return $in ? 1 : 0; - } elseif (is_null($in)) { + if (is_int($s) || is_double($s)) { + return $s; + } elseif (is_bool($s)) { + return $s ? 1 : 0; + } elseif (is_null($s)) { return 'NULL'; } else { - return $this->qstr($in); + return $this->qstr($s); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2021-08-14 19:33:29
|
Revision: 10519 http://sourceforge.net/p/phpwiki/code/10519 Author: vargenau Date: 2021-08-14 19:33:26 +0000 (Sat, 14 Aug 2021) Log Message: ----------- function set_links returns no value; remove DEBUG part Modified Paths: -------------- trunk/lib/WikiDB/backend/ADODB.php trunk/lib/WikiDB/backend/ADODB_mssqlnative.php trunk/lib/WikiDB/backend/PDO.php trunk/lib/WikiDB/backend.php Modified: trunk/lib/WikiDB/backend/ADODB.php =================================================================== --- trunk/lib/WikiDB/backend/ADODB.php 2021-08-14 19:14:38 UTC (rev 10518) +++ trunk/lib/WikiDB/backend/ADODB.php 2021-08-14 19:33:26 UTC (rev 10519) @@ -545,12 +545,12 @@ array($id, $version + 1, $mtime, 0, '', $this->_serialize($meta))) and $dbh->Execute("DELETE FROM $nonempty_tbl WHERE id=$id") - 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 //and $dbh->Execute("UPDATE $page_tbl SET pagedata='' WHERE id=$id") ) { + $this->set_links($pagename, array()); $this->unlock(array('version', 'recent', 'nonempty', 'page', 'link')); $dbh->CommitTrans(); return true; @@ -597,8 +597,6 @@ * * @param string $pagename Page name * @param array $links List of page(names) which page links to. - * - * on DEBUG: delete old, deleted links from page */ function set_links($pagename, $links) { @@ -649,29 +647,7 @@ } } } - // purge page table: delete all non-referenced pages - // for all previously linked pages, which have no other linkto links - if (DEBUG and $oldlinks) { - // trigger_error("purge page table: delete all non-referenced pages...", E_USER_NOTICE); - foreach ($oldlinks as $id => $name) { - // ...check if the page is empty and has no version - $result = $dbh->getRow("SELECT $page_tbl.id FROM $page_tbl" - . " LEFT JOIN $nonempty_tbl USING (id) " - . " LEFT JOIN $version_tbl USING (id)" - . " WHERE $nonempty_tbl.id is NULL" - . " AND $version_tbl.id is NULL" - . " AND $page_tbl.id=$id"); - $linkto = $dbh->getRow("SELECT linkfrom FROM $link_tbl WHERE linkto=$id"); - if ($result and empty($linkto)) { - trigger_error("delete empty and non-referenced link $name ($id)", E_USER_NOTICE); - $dbh->Execute("DELETE FROM $recent_tbl WHERE id=$id"); // may fail - $dbh->Execute("DELETE FROM $link_tbl WHERE linkto=$id"); - $dbh->Execute("DELETE FROM $page_tbl WHERE id=$id"); // this purges the link - } - } - } $this->unlock(array('link')); - return true; } /* get all oldlinks in hash => id, relation Modified: trunk/lib/WikiDB/backend/ADODB_mssqlnative.php =================================================================== --- trunk/lib/WikiDB/backend/ADODB_mssqlnative.php 2021-08-14 19:14:38 UTC (rev 10518) +++ trunk/lib/WikiDB/backend/ADODB_mssqlnative.php 2021-08-14 19:33:26 UTC (rev 10519) @@ -100,8 +100,6 @@ * * @param string $pagename Page name * @param array $links List of page(names) which page links to. - * - * on DEBUG: delete old, deleted links from page */ function set_links($pagename, $links) { @@ -151,31 +149,7 @@ } } } - // purge page table: delete all non-referenced pages - // for all previously linked pages, which have no other linkto links - if (DEBUG and $oldlinks) { - // trigger_error("purge page table: delete all non-referenced pages...", E_USER_NOTICE); - foreach ($oldlinks as $id => $name) { - // ...check if the page is empty and has no version - if ($id != '') { - $result = $dbh->getRow("SELECT $page_tbl.id FROM $page_tbl" - . " LEFT JOIN $nonempty_tbl ON ($nonempty_tbl.id = $page_tbl.id)" //'"id" is not a recognized table hints option' - . " LEFT JOIN $version_tbl ON ($version_tbl.id = $page_tbl.id)" //'"id" is not a recognized table hints option' - . " WHERE $nonempty_tbl.id is NULL" - . " AND $version_tbl.id is NULL" - . " AND $page_tbl.id=$id"); - $linkto = $dbh->getRow("SELECT linkfrom FROM $link_tbl WHERE linkto=$id"); - if ($result and empty($linkto)) { - trigger_error("delete empty and non-referenced link $name ($id)", E_USER_NOTICE); - $dbh->Execute("DELETE FROM $recent_tbl WHERE id=$id"); // may fail - $dbh->Execute("DELETE FROM $link_tbl WHERE linkto=$id"); - $dbh->Execute("DELETE FROM $page_tbl WHERE id=$id"); // this purges the link - } - } - } - } $this->unlock(array('link')); - return true; } /* get all oldlinks in hash => id, relation Modified: trunk/lib/WikiDB/backend/PDO.php =================================================================== --- trunk/lib/WikiDB/backend/PDO.php 2021-08-14 19:14:38 UTC (rev 10518) +++ trunk/lib/WikiDB/backend/PDO.php 2021-08-14 19:33:26 UTC (rev 10519) @@ -654,8 +654,8 @@ $insert->bindParam(6, $meta_serialized, PDO::PARAM_STR, 100); if ($insert->execute() and $dbh->query("DELETE FROM $nonempty_tbl WHERE id=$id") - and $this->set_links($pagename, array()) ) { + $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 Modified: trunk/lib/WikiDB/backend.php =================================================================== --- trunk/lib/WikiDB/backend.php 2021-08-14 19:14:38 UTC (rev 10518) +++ trunk/lib/WikiDB/backend.php 2021-08-14 19:33:26 UTC (rev 10519) @@ -278,8 +278,6 @@ * * @param string $pagename Page name * @param array $links List of page(names) which page links to. - * - * on DEBUG: delete old, deleted links from page */ abstract function set_links($pagename, $links); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2022-03-24 13:40:21
|
Revision: 11010 http://sourceforge.net/p/phpwiki/code/11010 Author: vargenau Date: 2022-03-24 13:40:18 +0000 (Thu, 24 Mar 2022) Log Message: ----------- run php-cs-fixer Modified Paths: -------------- trunk/lib/WikiDB/PDO.php trunk/lib/WikiDB/SQL.php trunk/lib/WikiDB/backend/PDO.php trunk/lib/WikiDB/backend/PDO_mysql.php trunk/lib/WikiDB/backend/PDO_oci8.php trunk/lib/WikiDB/backend/PDO_pgsql.php trunk/lib/WikiDB/backend/PearDB.php trunk/lib/WikiDB/backend/PearDB_ffpgsql.php trunk/lib/WikiDB/backend/PearDB_mysqli.php trunk/lib/WikiDB/backend/PearDB_oci8.php trunk/lib/WikiDB/backend/PearDB_pgsql.php trunk/lib/WikiDB/backend/dba.php trunk/lib/WikiDB/backend/dbaBase.php trunk/lib/WikiDB/backend/dumb/AllRevisionsIter.php trunk/lib/WikiDB/backend/dumb/LinkSearchIter.php trunk/lib/WikiDB/backend/dumb/MostPopularIter.php trunk/lib/WikiDB/backend/dumb/MostRecentIter.php trunk/lib/WikiDB/backend/dumb/TextSearchIter.php trunk/lib/WikiDB/backend/dumb/WantedPagesIter.php trunk/lib/WikiDB/backend/file.php trunk/lib/WikiDB/backend/flatfile.php trunk/lib/WikiDB/backend.php trunk/lib/WikiDB/dba.php trunk/lib/WikiDB/file.php trunk/lib/WikiDB/flatfile.php Modified: trunk/lib/WikiDB/PDO.php =================================================================== --- trunk/lib/WikiDB/PDO.php 2022-03-24 13:32:25 UTC (rev 11009) +++ trunk/lib/WikiDB/PDO.php 2022-03-24 13:40:18 UTC (rev 11010) @@ -41,12 +41,13 @@ class WikiDB_PDO extends WikiDB { - function __construct($dbparams) + public function __construct($dbparams) { - if (is_array($dbparams['dsn'])) + if (is_array($dbparams['dsn'])) { $backend = $dbparams['dsn']['phptype']; - elseif (preg_match('/^(\w+):/', $dbparams['dsn'], $m)) + } elseif (preg_match('/^(\w+):/', $dbparams['dsn'], $m)) { $backend = $m[1]; + } // Do we have a override? Currently: mysql, oci8, pgsql if ($backend == "mysqli") { $backend = "mysql"; @@ -124,10 +125,11 @@ $sth->bindParam($key, $val); } } - if ($sth->execute()) + if ($sth->execute()) { $result = $sth->fetch(PDO::FETCH_BOTH); - else + } else { return false; + } } catch (PDOException $e) { trigger_error("SQL Error: " . $e->getMessage(), E_USER_WARNING); return false; @@ -137,10 +139,9 @@ // SQL iter: for simple select or create/update queries // returns the generic iterator object (count, next) - public function genericSqlIter($sql, $field_list = NULL) + public function genericSqlIter($sql, $field_list = null) { $result = $this->genericSqlQuery($sql); return new WikiDB_backend_PDO_generic_iter($this->_backend, $result, $field_list); } - } Modified: trunk/lib/WikiDB/SQL.php =================================================================== --- trunk/lib/WikiDB/SQL.php 2022-03-24 13:32:25 UTC (rev 11009) +++ trunk/lib/WikiDB/SQL.php 2022-03-24 13:40:18 UTC (rev 11010) @@ -27,17 +27,19 @@ class WikiDB_SQL extends WikiDB { - function __construct($dbparams) + public function __construct($dbparams) { $backend = 'PearDB'; - if (is_array($dbparams['dsn'])) + if (is_array($dbparams['dsn'])) { $backend = $dbparams['dsn']['phptype']; - elseif (preg_match('/^(\w+):/', $dbparams['dsn'], $m)) + } elseif (preg_match('/^(\w+):/', $dbparams['dsn'], $m)) { $backend = $m[1]; + } if ($backend == 'postgres7') { $backend = 'pgsql'; - if (is_string($dbparams['dsn'])) + if (is_string($dbparams['dsn'])) { $dbparams['dsn'] = $backend . ':' . substr($dbparams['dsn'], 10); + } } if ($backend == 'mysql') { $backend = 'mysqli'; @@ -46,17 +48,21 @@ include_once 'lib/WikiDB/backend/PearDB_' . $backend . '.php'; $backend_class = "WikiDB_backend_PearDB_" . $backend; $backend = new $backend_class($dbparams); - if (DB::isError($backend->_dbh)) return; + if (DB::isError($backend->_dbh)) { + return; + } parent::__construct($backend, $dbparams); } public static function view_dsn($dsn = false) { - if (!$dsn) + if (!$dsn) { $dsninfo = DB::parseDSN($GLOBALS['DBParams']['dsn']); - else + } else { $dsninfo = DB::parseDSN($dsn); - return sprintf("%s://%s:<not displayed>@%s/%s", + } + return sprintf( + "%s://%s:<not displayed>@%s/%s", $dsninfo['phptype'], $dsninfo['username'], $dsninfo['hostspec'], @@ -108,10 +114,11 @@ // returns the database specific resource type public function genericSqlQuery($sql, $args = array()) { - if ($args) + if ($args) { $result = $this->_backend->_dbh->query($sql, $args); - else + } else { $result = $this->_backend->_dbh->query($sql); + } if (DB::isError($result)) { $msg = $result->getMessage(); trigger_error("SQL Error: " . DB::errorMessage($result), E_USER_WARNING); @@ -123,10 +130,9 @@ // SQL iter: for simple select or create/update queries // returns the generic iterator object (count, next) - public function genericSqlIter($sql, $field_list = NULL) + public function genericSqlIter($sql, $field_list = null) { $result = $this->genericSqlQuery($sql); return new WikiDB_backend_PearDB_generic_iter($this->_backend, $result); } - } Modified: trunk/lib/WikiDB/backend/PDO.php =================================================================== --- trunk/lib/WikiDB/backend/PDO.php 2022-03-24 13:32:25 UTC (rev 11009) +++ trunk/lib/WikiDB/backend/PDO.php 2022-03-24 13:40:18 UTC (rev 11010) @@ -28,8 +28,7 @@ require_once 'lib/WikiDB/backend.php'; -class WikiDB_backend_PDO - extends WikiDB_backend +class WikiDB_backend_PDO extends WikiDB_backend { public $_dbparams; public $_dsn; @@ -39,7 +38,7 @@ private $_lock_count; private $_current_lock; - function __construct($dbparams) + public function __construct($dbparams) { $this->_dbparams = $dbparams; if (strstr($dbparams['dsn'], "://")) { // pear DB syntax @@ -100,7 +99,8 @@ try { // persistent is defined as DSN option, or with a config value. // phptype://username:password@hostspec/database?persistent=false - $this->_dbh = new PDO($dbparams['dsn'], + $this->_dbh = new PDO( + $dbparams['dsn'], $this->_parsedDSN['username'], $this->_parsedDSN['password'], array(PDO::ATTR_AUTOCOMMIT => true, @@ -107,7 +107,8 @@ PDO::ATTR_TIMEOUT => DATABASE_TIMEOUT, PDO::ATTR_PERSISTENT => !empty($parsed['persistent']) or DATABASE_PERSISTENT - )); + ) + ); } catch (PDOException $e) { echo "<br>\nCan't connect to database: " . $e->getMessage(); if (DEBUG & _DEBUG_VERBOSE or DEBUG & _DEBUG_SQL) { @@ -161,26 +162,29 @@ $this->_lock_count = 0; } - function beginTransaction() + public function beginTransaction() { - if ($this->_hasTransactions) + if ($this->_hasTransactions) { $this->_dbh->beginTransaction(); + } } - function commit() + public function commit() { - if ($this->_hasTransactions) + if ($this->_hasTransactions) { $this->_dbh->commit(); + } } - function rollBack() + public function rollBack() { - if ($this->_hasTransactions) + if ($this->_hasTransactions) { $this->_dbh->rollBack(); + } } /* no result */ - function query($sql) + public function query($sql) { $sth = $this->_dbh->prepare($sql); return $sth->execute(); @@ -187,27 +191,30 @@ } /* with one result row */ - function getRow($sql) + public function getRow($sql) { $sth = $this->_dbh->prepare($sql); - if ($sth->execute()) + if ($sth->execute()) { return $sth->fetch(PDO::FETCH_BOTH); - else + } else { return false; + } } /** * Close database connection. */ - function close() + public function close() { if (!$this->_dbh) { return; } if ($this->_lock_count) { - trigger_error("WARNING: database still locked " . + trigger_error( + "WARNING: database still locked " . '(lock_count = $this->_lock_count)' . "\n<br />", - E_USER_WARNING); + E_USER_WARNING + ); } $this->unlock(array(), 'force'); @@ -217,7 +224,7 @@ /* * Fast test for wikipage. */ - function is_wiki_page($pagename) + public function is_wiki_page($pagename) { $dbh = &$this->_dbh; extract($this->_table_names); @@ -226,13 +233,14 @@ . " WHERE $nonempty_tbl.id=$page_tbl.id" . " AND pagename=?"); $sth->bindParam(1, $pagename, PDO::PARAM_STR, MAX_PAGENAME_LENGTH); - if ($sth->execute()) + if ($sth->execute()) { return $sth->fetchColumn(); - else + } else { return false; + } } - function get_all_pagenames() + public function get_all_pagenames() { $dbh = &$this->_dbh; extract($this->_table_names); @@ -246,7 +254,7 @@ /* * filter (nonempty pages) currently ignored */ - function numPages($filter = false, $exclude = '') + public function numPages($filter = false, $exclude = '') { $dbh = &$this->_dbh; extract($this->_table_names); @@ -256,7 +264,7 @@ return $sth->fetchColumn(); } - function increaseHitCount($pagename) + public function increaseHitCount($pagename) { $dbh = &$this->_dbh; $page_tbl = $this->_table_names['page_tbl']; @@ -270,7 +278,7 @@ /* * Read page information from database. */ - function get_pagedata($pagename) + public function get_pagedata($pagename) { $dbh = &$this->_dbh; $page_tbl = $this->_table_names['page_tbl']; @@ -291,7 +299,7 @@ } } - function update_pagedata($pagename, $newdata) + public function update_pagedata($pagename, $newdata) { $dbh = &$this->_dbh; $page_tbl = $this->_table_names['page_tbl']; @@ -318,12 +326,13 @@ unset($data['hits']); foreach ($newdata as $key => $val) { - if ($key == 'hits') + if ($key == 'hits') { $hits = (int)$val; - else if (empty($val)) + } elseif (empty($val)) { unset($data[$key]); - else + } else { $data[$key] = $val; + } } $sth = $dbh->prepare("UPDATE $page_tbl" . " SET hits=?, pagedata=?" @@ -342,7 +351,7 @@ } } - function get_cached_html($pagename) + public function get_cached_html($pagename) { $dbh = &$this->_dbh; $page_tbl = $this->_table_names['page_tbl']; @@ -352,11 +361,13 @@ return $sth->fetchColumn(0); } - function set_cached_html($pagename, $data) + public function set_cached_html($pagename, $data) { $dbh = &$this->_dbh; $page_tbl = $this->_table_names['page_tbl']; - if (empty($data)) $data = ''; + if (empty($data)) { + $data = ''; + } $sth = $dbh->prepare("UPDATE $page_tbl" . " SET cached_html=?" . " WHERE pagename=?" @@ -366,7 +377,7 @@ $sth->execute(); } - function _get_pageid($pagename, $create_if_missing = false) + public function _get_pageid($pagename, $create_if_missing = false) { // check id_cache global $request; @@ -378,7 +389,9 @@ } // attributes play this game. - if ($pagename === '') return 0; + if ($pagename === '') { + return 0; + } $dbh = &$this->_dbh; $page_tbl = $this->_table_names['page_tbl']; @@ -410,10 +423,11 @@ $id++; $sth->bindParam(1, $id, PDO::PARAM_INT); $sth->bindParam(2, $pagename, PDO::PARAM_STR, MAX_PAGENAME_LENGTH); - if ($sth->execute()) + if ($sth->execute()) { $this->commit(); - else + } else { $this->rollBack(); + } } } assert($id); @@ -420,7 +434,7 @@ return $id; } - function get_latest_version($pagename) + public function get_latest_version($pagename) { $dbh = &$this->_dbh; extract($this->_table_names); @@ -434,7 +448,7 @@ return $sth->fetchColumn(); } - function get_previous_version($pagename, $version) + public function get_previous_version($pagename, $version) { $dbh = &$this->_dbh; extract($this->_table_names); @@ -460,7 +474,7 @@ * * @return array|false The version data, or false if specified version does not exist. */ - function get_versiondata($pagename, $version, $want_content = false) + public function get_versiondata($pagename, $version, $want_content = false) { $dbh = &$this->_dbh; extract($this->_table_names); @@ -495,8 +509,9 @@ private function _extract_version_data_num($row, $want_content) { - if (!$row) + if (!$row) { return false; + } //$id &= $row[0]; //$pagename &= $row[1]; @@ -514,20 +529,23 @@ return $data; } - function _extract_version_data_assoc($row) + public function _extract_version_data_assoc($row) { - if (!$row) + if (!$row) { return false; + } extract($row); $data = empty($versiondata) ? array() : $this->_unserialize($versiondata); $data['mtime'] = $mtime; $data['is_minor_edit'] = !empty($minor_edit); - if (isset($content)) + if (isset($content)) { $data['%content'] = $content; - elseif ($have_content) - $data['%content'] = true; else + } elseif ($have_content) { + $data['%content'] = true; + } else { $data['%content'] = ''; + } if (!empty($pagedata)) { $data['%pagedata'] = $this->_extract_page_data($pagedata, $hits); } @@ -537,7 +555,7 @@ /* * Create a new revision of a page. */ - function set_versiondata($pagename, $version, $data) + public function set_versiondata($pagename, $version, $data) { $dbh = &$this->_dbh; $version_tbl = $this->_table_names['version_tbl']; @@ -593,7 +611,7 @@ /* * Delete an old revision of a page. */ - function delete_versiondata($pagename, $version) + public function delete_versiondata($pagename, $version) { $dbh = &$this->_dbh; extract($this->_table_names); @@ -619,7 +637,7 @@ * so that get_latest_version returns id+1 and get_previous_version returns prev id * and page->exists returns false. */ - function delete_page($pagename) + public function delete_page($pagename) { /** * @var WikiRequest $request @@ -681,7 +699,7 @@ /* * Delete page completely from the database. */ - function purge_page($pagename) + public function purge_page($pagename) { $dbh = &$this->_dbh; extract($this->_table_names); @@ -716,7 +734,7 @@ * @param string $pagename Page name * @param array $links List of page(names) which page links to. */ - function set_links($pagename, $links) + public function set_links($pagename, $links) { // Update link table. // FIXME: optimize: mysql can do this all in one big INSERT/REPLACE. @@ -735,10 +753,11 @@ if ($linkto === "") { // ignore attributes continue; } - if (isset($link['relation'])) + if (isset($link['relation'])) { $relation = $this->_get_pageid($link['relation'], true); - else + } else { $relation = 0; + } // avoid duplicates if (isset($linkseen[$linkto]) and !$relation) { continue; @@ -783,23 +802,33 @@ * as 'linkrelation' key as pagename. See WikiDB_PageIterator::next * if (isset($next['linkrelation'])) */ - function get_links($pagename, $reversed = true, $include_empty = false, - $sortby = '', $limit = '', $exclude = '', - $want_relations = false) + public function get_links( + $pagename, + $reversed = true, + $include_empty = false, + $sortby = '', + $limit = '', + $exclude = '', + $want_relations = false + ) { $dbh = &$this->_dbh; extract($this->_table_names); - if ($reversed) + if ($reversed) { list($have, $want) = array('linkee', 'linker'); - else + } else { list($have, $want) = array('linker', 'linkee'); + } $orderby = $this->sortby($sortby, 'db', array('pagename')); - if ($orderby) $orderby = " ORDER BY $want." . $orderby; - if ($exclude) // array of pagenames + if ($orderby) { + $orderby = " ORDER BY $want." . $orderby; + } + if ($exclude) { // array of pagenames $exclude = " AND $want.pagename NOT IN " . $this->_sql_set($exclude); - else + } else { $exclude = ''; + } $limit = $this->_limit_sql($limit); $sth = $dbh->prepare("SELECT $want.id AS id, $want.pagename AS pagename," @@ -821,15 +850,16 @@ /* * Find if a page links to another page */ - function exists_link($pagename, $link, $reversed = false) + public function exists_link($pagename, $link, $reversed = false) { $dbh = &$this->_dbh; extract($this->_table_names); - if ($reversed) + if ($reversed) { list($have, $want) = array('linkee', 'linker'); - else + } else { list($have, $want) = array('linker', 'linkee'); + } $sth = $dbh->prepare("SELECT CASE WHEN $want.pagename THEN 1 ELSE 0 END" . " FROM $link_tbl, $page_tbl linker, $page_tbl linkee, $nonempty_tbl" . " WHERE linkfrom=linker.id AND linkto=linkee.id" @@ -841,8 +871,12 @@ return $sth->fetchColumn(); } - public function get_all_pages($include_empty = false, - $sortby = '', $limit = '', $exclude = '') + public function get_all_pages( + $include_empty = false, + $sortby = '', + $limit = '', + $exclude = '' + ) { $dbh = &$this->_dbh; extract($this->_table_names); @@ -900,8 +934,13 @@ /* * Text search (title or full text) */ - public function text_search($search, $fulltext = false, - $sortby = '', $limit = '', $exclude = '') + public function text_search( + $search, + $fulltext = false, + $sortby = '', + $limit = '', + $exclude = '' + ) { $dbh = &$this->_dbh; extract($this->_table_names); @@ -925,8 +964,11 @@ $join_clause .= " AND $page_tbl.id=$version_tbl.id AND latestversion=version"; $fields .= ", $page_tbl.pagedata as pagedata, " . $this->version_tbl_fields; - $field_list = array_merge($field_list, array('pagedata'), - $this->version_tbl_field_list); + $field_list = array_merge( + $field_list, + array('pagedata'), + $this->version_tbl_field_list + ); $callback = new WikiMethodCb($searchobj, "_fulltext_match_clause"); } else { $callback = new WikiMethodCb($searchobj, "_pagename_match_clause"); @@ -949,7 +991,7 @@ * This is only for already resolved wildcards: * " WHERE $page_tbl.pagename NOT IN ".$this->_sql_set(array('page1','page2')); */ - function _sql_set($pagenames) + public function _sql_set($pagenames) { $s = '('; foreach ($pagenames as $p) { @@ -975,8 +1017,9 @@ } $orderby = ''; if ($sortby != '-hits') { - if ($order = $this->sortby($sortby, 'db')) + if ($order = $this->sortby($sortby, 'db')) { $orderby = " ORDER BY " . $order; + } } else { $orderby = " ORDER BY hits $order"; } @@ -1064,19 +1107,23 @@ $sth = $dbh->prepare($sql); } $sth->execute(); - return new WikiDB_backend_PDO_iter($this, $sth, - array_merge($this->page_tbl_field_list, $this->version_tbl_field_list)); + return new WikiDB_backend_PDO_iter( + $this, + $sth, + array_merge($this->page_tbl_field_list, $this->version_tbl_field_list) + ); } /* * Find referenced empty pages. */ - function wanted_pages($exclude = '', $sortby = '', $limit = '') + public function wanted_pages($exclude = '', $sortby = '', $limit = '') { $dbh = &$this->_dbh; extract($this->_table_names); - if ($orderby = $this->sortby($sortby, 'db', array('pagename', 'wantedfrom'))) + if ($orderby = $this->sortby($sortby, 'db', array('pagename', 'wantedfrom'))) { $orderby = 'ORDER BY ' . $orderby; + } if ($exclude) { // array of pagenames $exclude = " AND $page_tbl.pagename NOT IN " . $this->_sql_set($exclude); @@ -1114,7 +1161,7 @@ * @param string $to Future page name */ - function rename_page($pagename, $to) + public function rename_page($pagename, $to) { $dbh = &$this->_dbh; extract($this->_table_names); @@ -1129,7 +1176,7 @@ return $id; } - function _update_recent_table($pageid = false) + public function _update_recent_table($pageid = false) { $dbh = &$this->_dbh; extract($this->_table_names); @@ -1163,7 +1210,7 @@ } } - function _update_nonempty_table($pageid = false) + public function _update_nonempty_table($pageid = false) { $dbh = &$this->_dbh; extract($this->_table_names); @@ -1196,8 +1243,9 @@ { if ($this->_lock_count++ == 0) { $this->_current_lock = $tables; - if (!$this->_hasTransactions) + if (!$this->_hasTransactions) { $this->_lock_tables($tables, $write_lock); + } } } @@ -1229,8 +1277,9 @@ return; } if (--$this->_lock_count <= 0 || $force) { - if (!$this->_hasTransactions) + if (!$this->_hasTransactions) { $this->_unlock_tables(); + } $this->_current_lock = false; $this->_lock_count = 0; } @@ -1247,7 +1296,7 @@ /* * Serialize data */ - function _serialize($data) + public function _serialize($data) { if (empty($data)) { return ''; @@ -1259,11 +1308,11 @@ /* * Unserialize data */ - function _unserialize($data) + public function _unserialize($data) { if ($data === "") { return array(); - } else if (is_string($data)) { + } elseif (is_string($data)) { return unserialize($data); } else { return array(); @@ -1271,23 +1320,23 @@ } /* some variables and functions for DB backend abstraction (action=upgrade) */ - function database() + public function database() { return $this->_dbh->database; } - function backendType() + public function backendType() { return $this->_dbh->databaseType; } - function connection() + public function connection() { trigger_error("PDO: connectionID unsupported", E_USER_ERROR); return false; } - function listOfTables() + public function listOfTables() { trigger_error("PDO: virtual listOfTables", E_USER_ERROR); return array(); @@ -1313,7 +1362,7 @@ BETWEEN $offset AND $last ORDER BY $pk $asc_desc */ - function _limit_sql($limit = false) + public function _limit_sql($limit = false) { if ($limit) { list($offset, $count) = $this->limit($limit); @@ -1327,7 +1376,7 @@ return $limit; } - function write_accesslog(&$entry) + public function write_accesslog(&$entry) { $dbh = &$this->_dbh; $log_tbl = $entry->_accesslog->logtable; @@ -1355,10 +1404,9 @@ } } -class WikiDB_backend_PDO_generic_iter - extends WikiDB_backend_iterator +class WikiDB_backend_PDO_generic_iter extends WikiDB_backend_iterator { - function __construct($backend, $query_result, $field_list = NULL) + public function __construct($backend, $query_result, $field_list = null) { $this->_backend = &$backend; $this->_result = $query_result; @@ -1365,7 +1413,7 @@ //$this->_fields = $field_list; } - function count() + public function count() { if (!is_object($this->_result)) { return false; @@ -1373,7 +1421,7 @@ return $this->_result->rowCount(); } - function next() + public function next() { $result = &$this->_result; if (!is_object($result)) { @@ -1382,11 +1430,11 @@ return $result->fetch(PDO::FETCH_BOTH); } - function reset() + public function reset() { } - function free() + public function free() { if (isset($this->_result)) { unset($this->_result); @@ -1394,12 +1442,11 @@ } } -class WikiDB_backend_PDO_iter - extends WikiDB_backend_PDO_generic_iter +class WikiDB_backend_PDO_iter extends WikiDB_backend_PDO_generic_iter { public $_backend; - function next() + public function next() { $result = &$this->_result; if (!is_object($result)) { @@ -1408,8 +1455,9 @@ $backend = &$this->_backend; $rec = $result->fetch(PDO::FETCH_ASSOC); - if (isset($rec['pagedata'])) + if (isset($rec['pagedata'])) { $rec['pagedata'] = $backend->_extract_page_data($rec['pagedata'], $rec['hits']); + } if (!empty($rec['version'])) { $rec['versiondata'] = $backend->_extract_version_data_assoc($rec); } @@ -1419,7 +1467,7 @@ class WikiDB_backend_PDO_search extends WikiDB_backend_search_sql { - function _pagename_match_clause($node) + public function _pagename_match_clause($node) { $word = $node->sql(); if ($word == '%') { // ALL shortcut @@ -1433,7 +1481,7 @@ } } - function _fulltext_match_clause($node) + public function _fulltext_match_clause($node) { // force word-style %word% for fulltext search $dbh = &$this->_dbh; @@ -1556,7 +1604,7 @@ $proto_opts = $match[2] ? $match[2] : false; $dsn = $match[3]; - // $dsn => protocol+hostspec/database (old format) + // $dsn => protocol+hostspec/database (old format) } else { if (strpos($dsn, '+') !== false) { list($proto, $dsn) = explode('+', $dsn, 2); @@ -1588,7 +1636,7 @@ // /database if (($pos = strpos($dsn, '?')) === false) { $parsed['database'] = $dsn; - // /database?param1=value1¶m2=value2 + // /database?param1=value1¶m2=value2 } else { $parsed['database'] = substr($dsn, 0, $pos); $dsn = substr($dsn, $pos + 1); Modified: trunk/lib/WikiDB/backend/PDO_mysql.php =================================================================== --- trunk/lib/WikiDB/backend/PDO_mysql.php 2022-03-24 13:32:25 UTC (rev 11009) +++ trunk/lib/WikiDB/backend/PDO_mysql.php 2022-03-24 13:40:18 UTC (rev 11010) @@ -27,16 +27,15 @@ */ require_once 'lib/WikiDB/backend/PDO.php'; -class WikiDB_backend_PDO_mysql - extends WikiDB_backend_PDO +class WikiDB_backend_PDO_mysql extends WikiDB_backend_PDO { - function __construct($dbparams) + public function __construct($dbparams) { parent::__construct($dbparams); $this->_dbh->query("SET NAMES 'utf8'"); } - function backendType() + public function backendType() { return 'mysql'; } @@ -46,9 +45,11 @@ */ private function _timeout() { - if (empty($this->_dbparams['timeout'])) return; + if (empty($this->_dbparams['timeout'])) { + return; + } $sth = $this->_dbh->prepare("SHOW processlist"); - if ($sth->execute()) + if ($sth->execute()) { while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { if ($row["db"] == $this->_dbh->dsn['database'] and $row["User"] == $this->_dbh->dsn['username'] @@ -59,12 +60,13 @@ $this->query("KILL $process_id"); } } + } } /** * Pack tables. */ - function optimize() + public function optimize() { $this->_timeout(); foreach ($this->_table_names as $table) { @@ -73,7 +75,7 @@ return true; } - function listOfTables() + public function listOfTables() { $sth = $this->_dbh->prepare("SHOW TABLES"); $sth->execute(); @@ -88,7 +90,7 @@ * offset specific syntax within mysql * convert from,count to SQL "LIMIT $from, $count" */ - function _limit_sql($limit = false) + public function _limit_sql($limit = false) { if ($limit) { list($from, $count) = $this->limit($limit); Modified: trunk/lib/WikiDB/backend/PDO_oci8.php =================================================================== --- trunk/lib/WikiDB/backend/PDO_oci8.php 2022-03-24 13:32:25 UTC (rev 11009) +++ trunk/lib/WikiDB/backend/PDO_oci8.php 2022-03-24 13:40:18 UTC (rev 11010) @@ -27,15 +27,14 @@ */ require_once 'lib/WikiDB/backend/PDO.php'; -class WikiDB_backend_PDO_oci8 - extends WikiDB_backend_PDO +class WikiDB_backend_PDO_oci8 extends WikiDB_backend_PDO { - function backendType() + public function backendType() { return 'oci8'; } - function optimize() + public function optimize() { // Do nothing here -- Leave that for the DBA // Cost Based Optimizer tuning vary from version to version @@ -64,7 +63,7 @@ } } - function write_accesslog(&$entry) + public function write_accesslog(&$entry) { $dbh = &$this->_dbh; $log_tbl = $entry->_accesslog->logtable; Modified: trunk/lib/WikiDB/backend/PDO_pgsql.php =================================================================== --- trunk/lib/WikiDB/backend/PDO_pgsql.php 2022-03-24 13:32:25 UTC (rev 11009) +++ trunk/lib/WikiDB/backend/PDO_pgsql.php 2022-03-24 13:40:18 UTC (rev 11010) @@ -27,10 +27,9 @@ */ require_once 'lib/WikiDB/backend/PDO.php'; -class WikiDB_backend_PDO_pgsql - extends WikiDB_backend_PDO +class WikiDB_backend_PDO_pgsql extends WikiDB_backend_PDO { - function backendType() + public function backendType() { return 'pgsql'; } @@ -39,7 +38,7 @@ * offset specific syntax within pgsql * convert from,count to SQL "LIMIT $count OFFSET $from" */ - function _limit_sql($limit = false) + public function _limit_sql($limit = false) { if ($limit) { list($from, $count) = $this->limit($limit); Modified: trunk/lib/WikiDB/backend/PearDB.php =================================================================== --- trunk/lib/WikiDB/backend/PearDB.php 2022-03-24 13:32:25 UTC (rev 11009) +++ trunk/lib/WikiDB/backend/PearDB.php 2022-03-24 13:40:18 UTC (rev 11010) @@ -24,12 +24,11 @@ require_once 'lib/WikiDB/backend.php'; -class WikiDB_backend_PearDB - extends WikiDB_backend +class WikiDB_backend_PearDB extends WikiDB_backend { public $_dbh; - function __construct($dbparams) + public function __construct($dbparams) { require_once('lib/pear/DB/common.php'); require_once('lib/pear/DB.php'); @@ -47,12 +46,18 @@ $this->_dbh = DB::connect($this->_dsn, $dboptions); $dbh = &$this->_dbh; if (DB::isError($dbh)) { - trigger_error(sprintf("Can't connect to database: %s", - $this->_pear_error_message($dbh)), - E_USER_ERROR); + trigger_error( + sprintf( + "Can't connect to database: %s", + $this->_pear_error_message($dbh) + ), + E_USER_ERROR + ); } - $dbh->setErrorHandling(PEAR_ERROR_CALLBACK, - array($this, '_pear_error_callback')); + $dbh->setErrorHandling( + PEAR_ERROR_CALLBACK, + array($this, '_pear_error_callback') + ); $dbh->setFetchMode(DB_FETCHMODE_ASSOC); $prefix = isset($dbparams['prefix']) ? $dbparams['prefix'] : ''; @@ -74,11 +79,10 @@ 'maxversion' => "MAX(version)", 'notempty' => "<>''", 'iscontent' => "content<>''"); - } /* with one result row */ - function getRow($sql) + public function getRow($sql) { return $this->_dbh->getRow($sql); } @@ -86,15 +90,17 @@ /** * Close database connection. */ - function close() + public function close() { if (!$this->_dbh) { return; } if ($this->_lock_count) { - trigger_error("WARNING: database still locked " . + trigger_error( + "WARNING: database still locked " . '(lock_count = $this->_lock_count)' . "\n<br />", - E_USER_WARNING); + E_USER_WARNING + ); } $this->_dbh->setErrorHandling(PEAR_ERROR_PRINT); // prevent recursive loops. $this->unlock('force'); @@ -109,18 +115,20 @@ /* * Fast test for wikipage. */ - function is_wiki_page($pagename) + public function is_wiki_page($pagename) { $dbh = &$this->_dbh; extract($this->_table_names); - return $dbh->getOne(sprintf("SELECT $page_tbl.id AS id" + return $dbh->getOne(sprintf( + "SELECT $page_tbl.id AS id" . " FROM $nonempty_tbl, $page_tbl" . " WHERE $nonempty_tbl.id=$page_tbl.id" . " AND pagename='%s'", - $dbh->escapeSimple($pagename))); + $dbh->escapeSimple($pagename) + )); } - function get_all_pagenames() + public function get_all_pagenames() { $dbh = &$this->_dbh; extract($this->_table_names); @@ -132,7 +140,7 @@ /* * filter (nonempty pages) currently ignored */ - function numPages($filter = false, $exclude = '') + public function numPages($filter = false, $exclude = '') { $dbh = &$this->_dbh; extract($this->_table_names); @@ -141,7 +149,7 @@ . " WHERE $nonempty_tbl.id=$page_tbl.id"); } - function increaseHitCount($pagename) + public function increaseHitCount($pagename) { $dbh = &$this->_dbh; // Hits is the only thing we can update in a fast manner. @@ -148,22 +156,28 @@ // Note that this will fail silently if the page does not // have a record in the page table. Since it's just the // hit count, who cares? - $dbh->query(sprintf("UPDATE %s SET hits=hits+1 WHERE pagename='%s'", + $dbh->query(sprintf( + "UPDATE %s SET hits=hits+1 WHERE pagename='%s'", $this->_table_names['page_tbl'], - $dbh->escapeSimple($pagename))); + $dbh->escapeSimple($pagename) + )); } /* * Read page information from database. */ - function get_pagedata($pagename) + public function get_pagedata($pagename) { $dbh = &$this->_dbh; //trigger_error("GET_PAGEDATA $pagename", E_USER_NOTICE); - $result = $dbh->getRow(sprintf("SELECT hits,pagedata FROM %s WHERE pagename='%s'", - $this->_table_names['page_tbl'], - $dbh->escapeSimple($pagename)), - DB_FETCHMODE_ASSOC); + $result = $dbh->getRow( + sprintf( + "SELECT hits,pagedata FROM %s WHERE pagename='%s'", + $this->_table_names['page_tbl'], + $dbh->escapeSimple($pagename) + ), + DB_FETCHMODE_ASSOC + ); return $result ? $this->_extract_page_data($result) : false; } @@ -180,7 +194,7 @@ } } - function update_pagedata($pagename, $newdata) + public function update_pagedata($pagename, $newdata) { $dbh = &$this->_dbh; $page_tbl = $this->_table_names['page_tbl']; @@ -190,8 +204,11 @@ // Note that this will fail silently if the page does not // have a record in the page table. Since it's just the // hit count, who cares? - $dbh->query(sprintf("UPDATE $page_tbl SET hits=%d WHERE pagename='%s'", - $newdata['hits'], $dbh->escapeSimple($pagename))); + $dbh->query(sprintf( + "UPDATE $page_tbl SET hits=%d WHERE pagename='%s'", + $newdata['hits'], + $dbh->escapeSimple($pagename) + )); return; } @@ -206,39 +223,46 @@ unset($data['hits']); foreach ($newdata as $key => $val) { - if ($key == 'hits') + if ($key == 'hits') { $hits = (int)$val; - else if (empty($val)) + } elseif (empty($val)) { unset($data[$key]); - else + } else { $data[$key] = $val; + } } - $dbh->query("UPDATE $page_tbl" + $dbh->query( + "UPDATE $page_tbl" . " SET hits=?, pagedata=?" . " WHERE pagename=?", - array($hits, $this->_serialize($data), $pagename)); + array($hits, $this->_serialize($data), $pagename) + ); $this->unlock(array($page_tbl)); } - function get_cached_html($pagename) + public function get_cached_html($pagename) { $dbh = &$this->_dbh; $page_tbl = $this->_table_names['page_tbl']; - return $dbh->GetOne(sprintf("SELECT cached_html FROM $page_tbl WHERE pagename='%s'", - $dbh->escapeSimple($pagename))); + return $dbh->GetOne(sprintf( + "SELECT cached_html FROM $page_tbl WHERE pagename='%s'", + $dbh->escapeSimple($pagename) + )); } - function set_cached_html($pagename, $data) + public function set_cached_html($pagename, $data) { $dbh = &$this->_dbh; $page_tbl = $this->_table_names['page_tbl']; - $dbh->query("UPDATE $page_tbl" + $dbh->query( + "UPDATE $page_tbl" . " SET cached_html=?" . " WHERE pagename=?", - array($data, $pagename)); + array($data, $pagename) + ); } - function _get_pageid($pagename, $create_if_missing = false) + public function _get_pageid($pagename, $create_if_missing = false) { // check id_cache global $request; @@ -250,16 +274,21 @@ } // attributes play this game. - if ($pagename === '') return 0; + if ($pagename === '') { + return 0; + } $dbh = &$this->_dbh; $page_tbl = $this->_table_names['page_tbl']; - $query = sprintf("SELECT id FROM $page_tbl WHERE pagename='%s'", - $dbh->escapeSimple($pagename)); + $query = sprintf( + "SELECT id FROM $page_tbl WHERE pagename='%s'", + $dbh->escapeSimple($pagename) + ); - if (!$create_if_missing) + if (!$create_if_missing) { return $dbh->getOne($query); + } $id = $dbh->getOne($query); if (empty($id)) { @@ -268,34 +297,40 @@ $id = $max_id + 1; // requires createSequence and on mysql lock the interim table ->getSequenceName //$id = $dbh->nextId($page_tbl . "_id"); - $dbh->query(sprintf("INSERT INTO $page_tbl" + $dbh->query(sprintf( + "INSERT INTO $page_tbl" . " (id,pagename,hits)" . " VALUES (%d,'%s',0)", - $id, $dbh->escapeSimple($pagename))); + $id, + $dbh->escapeSimple($pagename) + )); $this->unlock(array($page_tbl)); } return $id; } - function get_latest_version($pagename) + public function get_latest_version($pagename) { $dbh = &$this->_dbh; extract($this->_table_names); return - (int)$dbh->getOne(sprintf("SELECT latestversion" + (int)$dbh->getOne(sprintf( + "SELECT latestversion" . " FROM $page_tbl, $recent_tbl" . " WHERE $page_tbl.id=$recent_tbl.id" . " AND pagename='%s'", - $dbh->escapeSimple($pagename))); + $dbh->escapeSimple($pagename) + )); } - function get_previous_version($pagename, $version) + public function get_previous_version($pagename, $version) { $dbh = &$this->_dbh; extract($this->_table_names); return - (int)$dbh->getOne(sprintf("SELECT version" + (int)$dbh->getOne(sprintf( + "SELECT version" . " FROM $version_tbl, $page_tbl" . " WHERE $version_tbl.id=$page_tbl.id" . " AND pagename='%s'" @@ -305,7 +340,8 @@ . " LIMIT 1", */ $dbh->escapeSimple($pagename), - $version)); + $version + )); } /** @@ -317,7 +353,7 @@ * * @return array|false The version data, or false if specified version does not exist. */ - function get_versiondata($pagename, $version, $want_content = false) + public function get_versiondata($pagename, $version, $want_content = false) { $dbh = &$this->_dbh; extract($this->_table_names); @@ -337,21 +373,27 @@ . "$iscontent AS have_content"; } - $result = $dbh->getRow(sprintf("SELECT $fields" + $result = $dbh->getRow( + sprintf( + "SELECT $fields" . " FROM $page_tbl, $version_tbl" . " WHERE $page_tbl.id=$version_tbl.id" . " AND pagename='%s'" . " AND version=%d", - $dbh->escapeSimple($pagename), $version), - DB_FETCHMODE_ASSOC); + $dbh->escapeSimple($pagename), + $version + ), + DB_FETCHMODE_ASSOC + ); return $this->_extract_version_data($result); } - function _extract_version_data($query_result) + public function _extract_version_data($query_result) { - if (!$query_result) + if (!$query_result) { return false; + } /* Earlier versions (<= 1.3.7) stored the version data in base64. This could be done here or in upgrade. @@ -365,12 +407,13 @@ $data['mtime'] = $query_result['mtime']; $data['is_minor_edit'] = !empty($query_result['minor_edit']); - if (isset($query_result['content'])) + if (isset($query_result['content'])) { $data['%content'] = $query_result['content']; - elseif ($query_result['have_content']) + } elseif ($query_result['have_content']) { $data['%content'] = true; - else + } else { $data['%content'] = ''; + } // FIXME: this is ugly. if (isset($query_result['pagedata'])) { @@ -385,7 +428,7 @@ /* * Create a new revision of a page. */ - function set_versiondata($pagename, $version, $data) + public function set_versiondata($pagename, $version, $data) { $dbh = &$this->_dbh; $version_tbl = $this->_table_names['version_tbl']; @@ -404,15 +447,20 @@ $this->lock(); $id = $this->_get_pageid($pagename, true); - $dbh->query(sprintf("DELETE FROM $version_tbl" + $dbh->query(sprintf( + "DELETE FROM $version_tbl" . " WHERE id=%d AND version=%d", - $id, $version)); + $id, + $version + )); // generic slow PearDB bind eh quoting. - $dbh->query("INSERT INTO $version_tbl" + $dbh->query( + "INSERT INTO $version_tbl" . " (id,version,mtime,minor_edit,content,versiondata)" . " VALUES(?, ?, ?, ?, ?, ?)", array($id, $version, $mtime, $minor_edit, $content, - $this->_serialize($data))); + $this->_serialize($data)) + ); $this->_update_recent_table($id); $this->_update_nonempty_table($id); @@ -423,7 +471,7 @@ /* * Delete an old revision of a page. */ - function delete_versiondata($pagename, $version) + public function delete_versiondata($pagename, $version) { $dbh = &$this->_dbh; extract($this->_table_names); @@ -443,7 +491,7 @@ /* * Delete page completely from the database. */ - function purge_page($pagename) + public function purge_page($pagename) { $dbh = &$this->_dbh; extract($this->_table_names); @@ -479,7 +527,7 @@ * @param string $pagename Page name * @param array $links List of page(names) which page links to. */ - function set_links($pagename, $links) + public function set_links($pagename, $links) { // Update link table. // FIXME: optimize: mysql can do this all in one big INSERT/REPLACE. @@ -498,10 +546,11 @@ if ($linkto === "") { // ignore attributes continue; } - if (isset($link['relation'])) + if (isset($link['relation'])) { $relation = $this->_get_pageid($link['relation'], true); - else + } else { $relation = 0; + } // avoid duplicates if (isset($linkseen[$linkto]) and !$relation) { continue; @@ -541,23 +590,33 @@ * as 'linkrelation' key as pagename. See WikiDB_PageIterator::next * if (isset($next['linkrelation'])) */ - function get_links($pagename, $reversed = true, $include_empty = false, - $sortby = '', $limit = '', $exclude = '', - $want_relations = false) + public function get_links( + $pagename, + $reversed = true, + $include_empty = false, + $sortby = '', + $limit = '', + $exclude = '', + $want_relations = false + ) { $dbh = &$this->_dbh; extract($this->_table_names); - if ($reversed) + if ($reversed) { list($have, $want) = array('linkee', 'linker'); - else + } else { list($have, $want) = array('linker', 'linkee'); + } $orderby = $this->sortby($sortby, 'db', array('pagename')); - if ($orderby) $orderby = " ORDER BY $want." . $orderby; - if ($exclude) // array of pagenames + if ($orderby) { + $orderby = " ORDER BY $want." . $orderby; + } + if ($exclude) { // array of pagenames $exclude = " AND $want.pagename NOT IN " . $this->_sql_set($exclude); - else + } else { $exclude = ''; + } $qpagename = $dbh->escapeSimple($pagename); $sql = "SELECT $want.id AS id, $want.pagename AS pagename, " @@ -586,15 +645,16 @@ /* * Find if a page links to another page */ - function exists_link($pagename, $link, $reversed = false) + public function exists_link($pagename, $link, $reversed = false) { $dbh = &$this->_dbh; extract($this->_table_names); - if ($reversed) + if ($reversed) { list($have, $want) = array('linkee', 'linker'); - else + } else { list($have, $want) = array('linker', 'linkee'); + } $qpagename = $dbh->escapeSimple($pagename); $qlink = $dbh->escapeSimple($link); $row = $dbh->GetRow("SELECT CASE WHEN $want.pagename='$qlink' THEN 1 ELSE 0 END as result" @@ -605,8 +665,12 @@ return $row['result']; } - public function get_all_pages($include_empty = false, - $sortby = '', $limit = '', $exclude = '') + public function get_all_pages( + $include_empty = false, + $sortby = '', + $limit = '', + $exclude = '' + ) { $dbh = &$this->_dbh; extract($this->_table_names); @@ -668,8 +732,13 @@ /* * Text search (title or full text) */ - public function text_search($search, $fulltext = false, - $sortby = '', $limit = '', $exclude = '') + public function text_search( + $search, + $fulltext = false, + $sortby = '', + $limit = '', + $exclude = '' + ) { $dbh = &$this->_dbh; extract($this->_table_names); @@ -679,8 +748,9 @@ } $searchclass = get_class($this) . "_search"; // no need to define it everywhere and then fallback. memory! - if (!class_exists($searchclass)) + if (!class_exists($searchclass)) { $searchclass = "WikiDB_backend_PearDB_search"; + } $searchobj = new $searchclass($search, $dbh); $table = "$nonempty_tbl, $page_tbl"; @@ -718,7 +788,7 @@ //Todo: check if the better Mysql MATCH operator is supported, // (ranked search) and also google like expressions. - function _sql_match_clause($word) + public function _sql_match_clause($word) { $word = preg_replace('/(?=[%_\\\\])/', "\\", $word); $word = $this->_dbh->escapeSimple($word); @@ -729,7 +799,7 @@ return "LOWER(pagename) LIKE '%$word%'"; } - function _sql_casematch_clause($word) + public function _sql_casematch_clause($word) { $word = preg_replace('/(?=[%_\\\\])/', "\\", $word); $word = $this->_dbh->escapeSimple($word); @@ -736,7 +806,7 @@ return "pagename LIKE '%$word%'"; } - function _fullsearch_sql_match_clause($word) + public function _fullsearch_sql_match_clause($word) { $word = preg_replace('/(?=[%_\\\\])/', "\\", $word); $word = $this->_dbh->escapeSimple($word); @@ -745,7 +815,7 @@ return "LOWER(pagename) LIKE '%$word%' OR content LIKE '%$word%'"; } - function _fullsearch_sql_casematch_clause($word) + public function _fullsearch_sql_casematch_clause($word) { $word = preg_replace('/(?=[%_\\\\])/', "\\", $word); $word = $this->_dbh->escapeSimple($word); @@ -752,7 +822,7 @@ return "pagename LIKE '%$word%' OR content LIKE '%$word%'"; } - function _sql_set(&$pagenames) + public function _sql_set(&$pagenames) { $s = '('; foreach ($pagenames as $p) { @@ -778,8 +848,9 @@ } $orderby = ''; if ($sortby != '-hits') { - if ($order = $this->sortby($sortby, 'db')) + if ($order = $this->sortby($sortby, 'db')) { $orderby = " ORDER BY " . $order; + } } else { $orderby = " ORDER BY hits $order"; } @@ -874,12 +945,13 @@ /* * Find referenced empty pages. */ - function wanted_pages($exclude = '', $sortby = '', $limit = '') + public function wanted_pages($exclude = '', $sortby = '', $limit = '') { $dbh = &$this->_dbh; extract($this->_table_names); - if ($orderby = $this->sortby($sortby, 'db', array('pagename', 'wantedfrom'))) + if ($orderby = $this->sortby($sortby, 'db', array('pagename', 'wantedfrom'))) { $orderby = 'ORDER BY ' . $orderby; + } if ($exclude) { // array of pagenames $exclude = " AND p.pagename NOT IN " . $this->_sql_set($exclude); @@ -909,7 +981,7 @@ * @param string $to Future page name */ - function rename_page($pagename, $to) + public function rename_page($pagename, $to) { $dbh = &$this->_dbh; extract($this->_table_names); @@ -916,8 +988,10 @@ $this->lock(); $id = $this->_get_pageid($pagename); - $dbh->query(sprintf("UPDATE $page_tbl SET pagename='%s' WHERE id=$id", - $dbh->escapeSimple($to))); + $dbh->query(sprintf( + "UPDATE $page_tbl SET pagename='%s' WHERE id=$id", + $dbh->escapeSimple($to) + )); $this->unlock(); return $id; } @@ -932,7 +1006,7 @@ * Can be undone and is seen in RecentChanges. */ - function delete_page($pagename) + public function delete_page($pagename) { /** * @var WikiRequest $request @@ -961,7 +1035,7 @@ } - function _update_recent_table($pageid = false) + public function _update_recent_table($pageid = false) { $dbh = &$this->_dbh; extract($this->_table_names); @@ -981,7 +1055,7 @@ $this->unlock(); } - function _update_nonempty_table($pageid = false) + public function _update_nonempty_table($pageid = false) { $dbh = &$this->_dbh; extract($this->_table_names); @@ -1012,8 +1086,9 @@ */ public function lock($tables = array(), $write_lock = true) { - if ($this->_lock_count++ == 0) + if ($this->_lock_count++ == 0) { $this->_lock_tables($write_lock); + } } /* @@ -1055,7 +1130,7 @@ /* * Serialize data */ - function _serialize($data) + public function _serialize($data) { if (empty($data)) { return ''; @@ -1067,7 +1142,7 @@ /* * Unserialize data */ - function _unserialize($data) + public function _unserialize($data) { return empty($data) ? array() : unserialize($data); } @@ -1100,8 +1175,9 @@ */ private function _is_false_error($error) { - if ($error->getCode() != DB_ERROR) + if ($error->getCode() != DB_ERROR) { return false; + } $query = $this->_dbh->last_query; @@ -1128,7 +1204,7 @@ return true; } - function _pear_error_message($error) + public function _pear_error_message($error) { $class = get_class($this); $message = "$class: fatal database error\n" @@ -1136,28 +1212,31 @@ . "\t(" . $error->getDebugInfo() . ")\n"; // Prevent password from being exposed during a connection error - $safe_dsn = preg_replace('| ( :// .*? ) : .* (?=@) |xs', - '\\1:XXXXXXXX', $this->_dsn); + $safe_dsn = preg_replace( + '| ( :// .*? ) : .* (?=@) |xs', + '\\1:XXXXXXXX', + $this->_dsn + ); return str_replace($this->_dsn, $safe_dsn, $message); } /* some variables and functions for DB backend abstraction (action=upgrade) */ - function database() + public function database() { return $this->_dbh->dsn['database']; } - function backendType() + public function backendType() { return $this->_dbh->phptype; } - function connection() + public function connection() { return $this->_dbh->connection; } - function listOfTables() + public function listOfTables() { return $this->_dbh->getListOf('tables'); } @@ -1175,10 +1254,9 @@ * * @author: Dan Frankowski */ -class WikiDB_backend_PearDB_generic_iter - extends WikiDB_backend_iterator +class WikiDB_backend_PearDB_generic_iter extends WikiDB_backend_iterator { - function __construct($backend, $query_result, $field_list = NULL) + public function __construct($backend, $query_result, $field_list = null) { if (DB::isError($query_result)) { // This shouldn't happen, I thought. @@ -1190,7 +1268,7 @@ $this->_options = $field_list; } - function count() + public function count() { if (!$this->_result) { return false; @@ -1198,7 +1276,7 @@ return $this->_result->numRows(); } - function next() + public function next() { if (!$this->_result) { return false; @@ -1213,7 +1291,7 @@ return $record; } - function reset() + public function reset() { if ($this->_result) { $this->_result->MoveFirst(); @@ -1220,7 +1298,7 @@ } } - function free() + public function free() { if ($this->_result) { $this->_result->free(); @@ -1228,19 +1306,19 @@ } } - function asArray() + public function asArray() { $result = array(); - while ($page = $this->next()) + while ($page = $this->next()) { $result[] = $page; + } return $result; } } -class WikiDB_backend_PearDB_iter - extends WikiDB_backend_PearDB_generic_iter +class WikiDB_backend_PearDB_iter extends WikiDB_backend_PearDB_generic_iter { - function next() + public function next() { $backend = &$this->_backend; if (!$this->_result) { Modified: trunk/lib/WikiDB/backend/PearDB_ffpgsql.php =================================================================== --- trunk/lib/WikiDB/backend/PearDB_ffpgsql.php 2022-03-24 13:32:25 UTC (rev 11009) +++ trunk/lib/WikiDB/backend/PearDB_ffpgsql.php 2022-03-24 13:40:18 UTC (rev 11010) @@ -48,10 +48,9 @@ require_once 'lib/ErrorManager.php'; require_once 'lib/WikiDB/backend/PearDB_pgsql.php'; -class WikiDB_backend_PearDB_ffpgsql - extends WikiDB_backend_PearDB_pgsql +class WikiDB_backend_PearDB_ffpgsql extends WikiDB_backend_PearDB_pgsql { - function __construct($dbparams) + public function __construct($dbparams) { $dbparams['dsn'] = str_replace('ffpgsql:', 'pgsql:', $dbparams['dsn']); parent::__construct($dbparams); @@ -64,7 +63,7 @@ pg_set_client_encoding("iso-8859-1"); } - function get_all_pagenames() + public function get_all_pagenames() { $dbh = &$this->_dbh; extract($this->_table_names); @@ -79,7 +78,7 @@ /* * filter (nonempty pages) currently ignored */ - function numPages($filter = false, $exclude = '') + public function numPages($filter = false, $exclude = '') { $dbh = &$this->_dbh; extract($this->_table_names); @@ -94,13 +93,13 @@ /* ... [truncated message content] |
From: <var...@us...> - 2023-07-14 11:09:41
|
Revision: 11053 http://sourceforge.net/p/phpwiki/code/11053 Author: vargenau Date: 2023-07-14 11:09:38 +0000 (Fri, 14 Jul 2023) Log Message: ----------- lib/WikiDB: PHP 7: add types for function arguments and return Modified Paths: -------------- trunk/lib/WikiDB/PDO.php trunk/lib/WikiDB/SQL.php trunk/lib/WikiDB/backend.php Modified: trunk/lib/WikiDB/PDO.php =================================================================== --- trunk/lib/WikiDB/PDO.php 2023-07-14 11:00:34 UTC (rev 11052) +++ trunk/lib/WikiDB/PDO.php 2023-07-14 11:09:38 UTC (rev 11053) @@ -101,7 +101,7 @@ return str_replace("'", "\'", $in); } - public function isOpen() + public function isOpen(): bool { /** * @var WikiRequest $request Modified: trunk/lib/WikiDB/SQL.php =================================================================== --- trunk/lib/WikiDB/SQL.php 2023-07-14 11:00:34 UTC (rev 11052) +++ trunk/lib/WikiDB/SQL.php 2023-07-14 11:09:38 UTC (rev 11053) @@ -54,7 +54,7 @@ parent::__construct($backend, $dbparams); } - public static function view_dsn($dsn = false) + public static function view_dsn($dsn = false): string { if (!$dsn) { $dsninfo = DB::parseDSN($GLOBALS['DBParams']['dsn']); @@ -97,7 +97,7 @@ return $this->_backend->_dbh->escapeSimple($s); } - public function isOpen() + public function isOpen(): bool { /** * @var WikiRequest $request Modified: trunk/lib/WikiDB/backend.php =================================================================== --- trunk/lib/WikiDB/backend.php 2023-07-14 11:00:34 UTC (rev 11052) +++ trunk/lib/WikiDB/backend.php 2023-07-14 11:09:38 UTC (rev 11053) @@ -91,7 +91,7 @@ * don't think we need this...) * </dl> */ - abstract public function get_pagedata($pagename); + abstract public function get_pagedata(string $pagename): array; /** * Update the page meta-data. @@ -116,7 +116,7 @@ * @param string $pagename Page name. * @param array $newdata hash New meta-data. */ - abstract public function update_pagedata($pagename, $newdata); + abstract public function update_pagedata(string $pagename, array $newdata); /** * Get the current version number for a page. @@ -125,7 +125,7 @@ * @return int The latest version number for the page. Returns zero if * no versions of a page exist. */ - abstract public function get_latest_version($pagename); + abstract public function get_latest_version(string $pagename): int; /** * Get preceding version number. @@ -135,7 +135,7 @@ * @return int The version number of the version in the database which * immediately precedes $version. */ - abstract public function get_previous_version($pagename, $version); + abstract public function get_previous_version(string $pagename, int $version): int; /** * Get revision meta-data and content. @@ -161,7 +161,7 @@ * For description of other version meta-data see WikiDB_PageRevision::get(). * @see WikiDB_PageRevision::get */ - abstract public function get_versiondata($pagename, $version, $want_content = false); + abstract public function get_versiondata(string $pagename, int $version, bool $want_content = false); /** * Create a new page revision. @@ -175,7 +175,7 @@ * * @see get_versiondata */ - abstract public function set_versiondata($pagename, $version, $data); + abstract public function set_versiondata(string $pagename, int $version, array $data); /** * Update page version meta-data. @@ -189,7 +189,7 @@ * @param array $newdata hash New revision metadata. * @see set_versiondata, get_versiondata */ - public function update_versiondata($pagename, $version, $newdata) + public function update_versiondata(string $pagename, int $version, array $newdata) { $data = $this->get_versiondata($pagename, $version, true); if (!$data) { @@ -218,7 +218,7 @@ * @param string $pagename Page name. * @param int $version int Version to delete. */ - abstract public function delete_versiondata($pagename, $version); + abstract public function delete_versiondata(string $pagename, int $version); /** * Rename page in the database. @@ -226,7 +226,7 @@ * @param string $pagename Current page name * @param string $to Future page name */ - abstract public function rename_page($pagename, $to); + abstract public function rename_page(string $pagename, string $to); /** * Delete page from the database with backup possibility. @@ -237,7 +237,7 @@ * i.e save_page('') and DELETE nonempty id * Can be undone and is seen in RecentChanges. */ - abstract public function delete_page($pagename); + abstract public function delete_page(string $pagename); /** * Delete page (and all its revisions) from the database. @@ -244,7 +244,7 @@ * * @param string $pagename Page name. */ - abstract public function purge_page($pagename); + abstract public function purge_page(string $pagename); /** * Find pages which link to or are linked from a page. @@ -261,13 +261,13 @@ * @return object A WikiDB_backend_iterator. */ abstract public function get_links( - $pagename, - $reversed = true, - $include_empty = false, - $sortby = '', - $limit = '', - $exclude = '', - $want_relations = false + string $pagename, + bool $reversed = true, + bool $include_empty = false, + string $sortby = '', + string $limit = '', + string $exclude = '', + bool $want_relations = false ); /** @@ -276,7 +276,7 @@ * @param string $pagename Page name * @param array $links List of page(names) which page links to. */ - abstract public function set_links($pagename, $links); + abstract public function set_links(string $pagename, array $links); /** * Get all revisions of a page. @@ -284,7 +284,7 @@ * @param string $pagename The page name. * @return object A WikiDB_backend_iterator. */ - public function get_all_revisions($pagename) + public function get_all_revisions(string $pagename) { include_once 'lib/WikiDB/backend/dumb/AllRevisionsIter.php'; return new WikiDB_backend_dumb_AllRevisionsIter($this, $pagename); @@ -311,10 +311,10 @@ * @return object A WikiDB_backend_iterator. */ abstract public function get_all_pages( - $include_empty = false, - $sortby = '', - $limit = '', - $exclude = '' + bool $include_empty = false, + string $sortby = '', + string $limit = '', + string $exclude = '' ); /** @@ -338,11 +338,11 @@ * @see WikiDB::titleSearch */ public function text_search( - $search, - $fulltext = false, - $sortby = '', - $limit = '', - $exclude = '' + object $search, + bool $fulltext = false, + string $sortby = '', + string $limit = '', + string $exclude = '' ) { // This method implements a simple linear search @@ -374,7 +374,7 @@ * @return object A WikiDB_backend_iterator. * @see WikiDB::linkSearch */ - public function link_search($pages, $linkvalue, $linktype, $relation = false, $options = array()) + public function link_search($pages, $linkvalue, string $linktype, $relation = false, array $options = array()) { include_once 'lib/WikiDB/backend/dumb/LinkSearchIter.php'; $pageiter = $this->text_search($pages); @@ -391,7 +391,7 @@ * @param string $sortby * @return object A WikiDB_backend_iterator. */ - public function most_popular($limit = 20, $sortby = '-hits') + public function most_popular(int $limit = 20, string $sortby = '-hits') { // This is method fetches all pages, then // sorts them by hit count. @@ -412,7 +412,7 @@ * @return object A WikiDB_backend_iterator. * @see WikiDB::mostRecent */ - public function most_recent($params) + public function most_recent(array $params) { // This method is very inefficient and searches through // all pages for the most recent changes. @@ -444,7 +444,7 @@ * * All backends <em>should</em> support write locking. */ - abstract public function lock($tables = array(), $write_lock = true); + abstract public function lock(array $tables = array(), bool $write_lock = true); /** * Unlock backend database. @@ -454,7 +454,7 @@ * unlock() is called as many times as lock() has been. If $force is * set to true, the the database is unconditionally unlocked. */ - abstract public function unlock($tables = array(), $force = false); + abstract public function unlock(array $tables = array(), bool $force = false); /** * Close database. @@ -475,7 +475,7 @@ * * @return bool */ - public function optimize() + public function optimize(): bool { return true; } @@ -492,7 +492,7 @@ * @param bool $args * @return bool True iff database is in a consistent state. */ - public function check($args = false) + public function check(bool $args = false): bool { return true; } @@ -507,7 +507,7 @@ * @param bool $args * @return bool True iff successful. */ - public function rebuild($args = false) + public function rebuild(bool $args = false): bool { /** * @var WikiRequest $request @@ -534,7 +534,7 @@ return true; } - public function _parse_searchwords($search) + public function _parse_searchwords($search): array { $search = strtolower(trim($search)); if (!$search) { @@ -559,7 +559,7 @@ * Usage: * list($offset,$count) = $this->limit($args['limit']); */ - public static function limit($limit) + public static function limit($limit): array { if (strstr($limit, ',')) { list($from, $limit) = explode(',', $limit); @@ -654,13 +654,13 @@ return ''; } - public function sortable_columns() + public function sortable_columns(): array { return array('pagename' /*,'mtime','author_id','author'*/); } // adds surrounding quotes - public function quote($s) + public function quote($s): string { return "'" . $s . "'"; } @@ -671,7 +671,7 @@ return $s; } - public function isSQL() + public function isSQL(): bool { return in_array(DATABASE_TYPE, array('SQL', 'PDO')); } @@ -746,7 +746,7 @@ */ abstract public function next(); - public function count() + public function count(): int { if (!empty($this->_pages)) { return count($this->_pages); @@ -800,28 +800,28 @@ $this->stoplisted = array(); } - public function _quote($word) + public function _quote($word): string { return preg_quote($word, "/"); } //TODO: use word anchors - public function EXACT($word) + public function EXACT($word): string { return "^" . $this->_quote($word) . "$"; } - public function STARTS_WITH($word) + public function STARTS_WITH($word): string { return "^" . $this->_quote($word); } - public function ENDS_WITH($word) + public function ENDS_WITH($word): string { return $this->_quote($word) . "$"; } - public function WORD($word) + public function WORD($word): string { return $this->_quote($word); } @@ -832,7 +832,7 @@ } //TESTME - public function _pagename_match_clause($node) + public function _pagename_match_clause($node): string { $method = $node->op; $word = $this->$method($node->word); @@ -842,7 +842,7 @@ /* Eliminate stoplist words. * Keep a list of Stoplisted words to inform the poor user. */ - public function isStoplisted($node) + public function isStoplisted($node): bool { // check only on WORD or EXACT fulltext search if ($node->op != 'WORD' and $node->op != 'EXACT') { @@ -861,7 +861,7 @@ */ class WikiDB_backend_search_sql extends WikiDB_backend_search { - public function _pagename_match_clause($node) + public function _pagename_match_clause($node): string { // word already quoted by TextSearchQuery_node_word::sql_quote() $word = $node->sql(); @@ -874,7 +874,7 @@ } } - public function _fulltext_match_clause($node) + public function _fulltext_match_clause($node): string { // force word-style %word% for fulltext search $dbh = &$this->_dbh; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |