From: <var...@us...> - 2014-07-28 13:11:31
|
Revision: 9016 http://sourceforge.net/p/phpwiki/code/9016 Author: vargenau Date: 2014-07-28 13:11:28 +0000 (Mon, 28 Jul 2014) Log Message: ----------- Merge lib/WikiDB/backend/ADODB.php, lib/WikiDB/backend/PDO.php, lib/WikiDB/backend/PearDB.php Modified Paths: -------------- trunk/lib/WikiDB/backend/ADODB.php trunk/lib/WikiDB/backend/PDO.php trunk/lib/WikiDB/backend/PearDB.php Modified: trunk/lib/WikiDB/backend/ADODB.php =================================================================== --- trunk/lib/WikiDB/backend/ADODB.php 2014-07-28 12:25:57 UTC (rev 9015) +++ trunk/lib/WikiDB/backend/ADODB.php 2014-07-28 13:11:28 UTC (rev 9016) @@ -141,7 +141,6 @@ '(lock_count = $this->_lock_count)' . "\n<br />", E_USER_WARNING); } -// $this->_dbh->setErrorHandling(PEAR_ERROR_PRINT); // prevent recursive loops. $this->unlock(false, 'force'); $this->_dbh->close(); @@ -289,7 +288,6 @@ function _get_pageid($pagename, $create_if_missing = false) { - // check id_cache global $request; $cache =& $request->_dbi->_cache->_id_cache; @@ -355,11 +353,11 @@ extract($this->_table_names); // Use SELECTLIMIT for maximum portability $rs = $dbh->SelectLimit(sprintf("SELECT version" - . " FROM $version_tbl, $page_tbl" - . " WHERE $version_tbl.id=$page_tbl.id" - . " AND pagename=%s" - . " AND version < %d" - . " ORDER BY version DESC", + . " FROM $version_tbl, $page_tbl" + . " WHERE $version_tbl.id=$page_tbl.id" + . " AND pagename=%s" + . " AND version < %d" + . " ORDER BY version DESC", $dbh->qstr($pagename), $version), 1); @@ -394,10 +392,10 @@ . "$version_tbl.versiondata as versiondata"; } $row = $dbh->GetRow(sprintf("SELECT $fields" - . " FROM $page_tbl, $version_tbl" - . " WHERE $page_tbl.id=$version_tbl.id" - . " AND pagename=%s" - . " AND version=%d", + . " FROM $page_tbl, $version_tbl" + . " WHERE $page_tbl.id=$version_tbl.id" + . " AND pagename=%s" + . " AND version=%d", $dbh->qstr($pagename), $version)); return $row ? $this->_extract_version_data_num($row, $want_content) : false; } @@ -555,6 +553,10 @@ } } + /** + * 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) { $dbh = &$this->_dbh; @@ -595,6 +597,7 @@ */ function set_links($pagename, $links) { + // Update link table. // FIXME: optimize: mysql can do this all in one big INSERT/REPLACE. $dbh = &$this->_dbh; @@ -837,9 +840,6 @@ return $row[0]; } - /* - * - */ function get_all_pages($include_empty = false, $sortby = '', $limit = '', $exclude = '') { $dbh = &$this->_dbh; @@ -932,11 +932,10 @@ } else { $callback = new WikiMethodCb($searchobj, "_pagename_match_clause"); } - $search_clause = $search->makeSqlClauseObj($callback); $sql = "SELECT $fields FROM $table" . " WHERE $join_clause" - . " AND ($search_clause)" + . " AND ($search_clause)" . $orderby; if ($limit) { // extract from,count from limit @@ -1095,15 +1094,15 @@ all empty pages, independent of linkstatus: select pagename as empty from page left join nonempty using(id) where is null(nonempty.id); only all empty pages, which have a linkto: - select page.pagename, linked.pagename as wantedfrom from link, page linked - left join page on link.linkto=page.id left join nonempty on link.linkto=nonempty.id - where nonempty.id is null and linked.id=link.linkfrom; + select page.pagename, linked.pagename as wantedfrom from link, page linked + left join page on link.linkto=page.id left join nonempty on link.linkto=nonempty.id + where nonempty.id is null and linked.id=link.linkfrom; */ - $sql = "SELECT p.pagename, pp.pagename as wantedfrom" + $sql = "SELECT p.pagename, pp.pagename AS wantedfrom" . " FROM $page_tbl p, $link_tbl linked" . " LEFT JOIN $page_tbl pp ON (linked.linkto = pp.id)" . " LEFT JOIN $nonempty_tbl ne ON (linked.linkto = ne.id)" - . " WHERE ne.id is NULL" + . " WHERE ne.id IS NULL" . " AND (p.id = linked.linkfrom)" . $exclude_from . $exclude @@ -1194,7 +1193,7 @@ . " SELECT $recent_tbl.id" . " FROM $recent_tbl, $version_tbl" . " WHERE $recent_tbl.id=$version_tbl.id" - . " AND version=latestversion" + . " AND version=latestversion" // We have some specifics here (Oracle) //. " AND content<>''" . " AND content $notempty" // On Oracle not just "<>''" Modified: trunk/lib/WikiDB/backend/PDO.php =================================================================== --- trunk/lib/WikiDB/backend/PDO.php 2014-07-28 12:25:57 UTC (rev 9015) +++ trunk/lib/WikiDB/backend/PDO.php 2014-07-28 13:11:28 UTC (rev 9016) @@ -241,6 +241,9 @@ return $sth->fetchAll(PDO::FETCH_NUM); } + /* + * filter (nonempty pages) currently ignored + */ function numPages($filter = false, $exclude = '') { $dbh = &$this->_dbh; @@ -369,7 +372,6 @@ return $cache[$pagename]; } } - // attributes play this game. if ($pagename === '') return 0; @@ -661,6 +663,10 @@ } } + /** + * 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) { $dbh = &$this->_dbh; @@ -696,6 +702,10 @@ //function update_versiondata($pagename, $version, $data) { //} + /* + * Update link table. + * on DEBUG: delete old, deleted links from page + */ function set_links($pagename, $links) { // Update link table. @@ -748,7 +758,8 @@ * * Optimization: save request->_dbi->_iwpcache[] to avoid further iswikipage checks * (linkExistingWikiWord or linkUnknownWikiWord) - * This is called on every page header GleanDescription, so we can store all the existing links. + * This is called on every page header GleanDescription, so we can store all the + * existing links. */ function get_links($pagename, $reversed = true, $include_empty = false, $sortby = '', $limit = '', $exclude = '') @@ -862,9 +873,10 @@ } /** - * Title search. + * Title and fulltext search. */ - function text_search($search, $fullsearch = false, $sortby = '', $limit = '', $exclude = '') + function text_search($search, $fullsearch = false, + $sortby = '', $limit = '', $exclude = '') { $dbh = &$this->_dbh; extract($this->_table_names); @@ -891,11 +903,10 @@ } else { $callback = new WikiMethodCb($searchobj, "_pagename_match_clause"); } - $search_clause = $search->makeSqlClauseObj($callback); $sth = $dbh->prepare("SELECT $fields FROM $table" . " WHERE $join_clause" - . " AND ($search_clause)" + . " AND ($search_clause)" . $orderby . $limit); $sth->execute(); @@ -1051,11 +1062,11 @@ left join page on(link.linkto=page.id) left join nonempty on(link.linkto=nonempty.id) where isnull(nonempty.id) and linked.id=link.linkfrom; */ - $sql = "SELECT p.pagename, pp.pagename as wantedfrom" + $sql = "SELECT p.pagename, pp.pagename AS wantedfrom" . " FROM $page_tbl p JOIN $link_tbl linked" . " LEFT JOIN $page_tbl pp ON linked.linkto = pp.id" . " LEFT JOIN $nonempty_tbl ne ON linked.linkto = ne.id" - . " WHERE ne.id is NULL" + . " WHERE ne.id IS NULL" . " AND p.id = linked.linkfrom" . $exclude_from . $exclude @@ -1151,10 +1162,10 @@ . " SELECT $recent_tbl.id" . " FROM $recent_tbl, $version_tbl" . " WHERE $recent_tbl.id=$version_tbl.id" - . " AND version=latestversion" + . " AND version=latestversion" // We have some specifics here (Oracle) //. " AND content<>''" - . " AND content $notempty" + . " AND content $notempty" // On Oracle not just "<>''" . ($pageid ? " AND $recent_tbl.id=$pageid" : "")); $this->unlock(array('nonempty')); } Modified: trunk/lib/WikiDB/backend/PearDB.php =================================================================== --- trunk/lib/WikiDB/backend/PearDB.php 2014-07-28 12:25:57 UTC (rev 9015) +++ trunk/lib/WikiDB/backend/PearDB.php 2014-07-28 13:11:28 UTC (rev 9016) @@ -1,5 +1,25 @@ <?php +/* + * Copyright 2002,2004,2005,2006 $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. + */ + require_once 'lib/WikiDB/backend.php'; class WikiDB_backend_PearDB @@ -92,7 +112,8 @@ if (!$this->_dbh) return; if ($this->_lock_count) { - trigger_error("WARNING: database still locked " . '(lock_count = $this->_lock_count)' . "\n<br />", + trigger_error("WARNING: database still locked " . + '(lock_count = $this->_lock_count)' . "\n<br />", E_USER_WARNING); } $this->_dbh->setErrorHandling(PEAR_ERROR_PRINT); // prevent recursive loops. @@ -106,13 +127,13 @@ } /* - * Test fast wikipage. + * Fast test for wikipage. */ 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'", @@ -128,6 +149,9 @@ . " WHERE $nonempty_tbl.id=$page_tbl.id"); } + /* + * filter (nonempty pages) currently ignored + */ function numPages($filter = false, $exclude = '') { $dbh = &$this->_dbh; @@ -245,7 +269,6 @@ function _get_pageid($pagename, $create_if_missing = false) { - // check id_cache global $request; $cache =& $request->_dbi->_cache->_id_cache; @@ -328,14 +351,13 @@ extract($this->_table_names); extract($this->_expressions); - assert(is_string($pagename) and $pagename != ""); + assert(is_string($pagename) and $pagename != ''); assert($version > 0); - //trigger_error("GET_REVISION $pagename $version $want_content", E_USER_NOTICE); // FIXME: optimization: sometimes don't get page data? if ($want_content) { $fields = $this->page_tbl_fields - . ",$page_tbl.pagedata as pagedata," + . ",$page_tbl.pagedata AS pagedata," . $this->version_tbl_fields; } else { $fields = $this->page_tbl_fields . "," @@ -384,11 +406,9 @@ unset($query_result['versiondata']); $data['%pagedata'] = $this->_extract_page_data($query_result); } - return $data; } - /** * Create a new revision of a page. */ @@ -406,7 +426,6 @@ $content = isset($data['%content']) ? (string)$data['%content'] : ''; unset($data['%content']); - unset($data['%pagedata']); $this->lock(); @@ -440,7 +459,6 @@ if (($id = $this->_get_pageid($pagename))) { $dbh->query("DELETE FROM $version_tbl" . " WHERE id=$id AND version=$version"); - $this->_update_recent_table($id); // This shouldn't be needed (as long as the latestversion // never gets deleted.) But, let's be safe. @@ -512,10 +530,14 @@ //function update_versiondata($pagename, $version, $data) { //} + /* + * Update link table. + * on DEBUG: delete old, deleted links from page + */ function set_links($pagename, $links) { // Update link table. - // FIXME: optimize: mysql can do this all in one big INSERT. + // FIXME: optimize: mysql can do this all in one big INSERT/REPLACE. $dbh = &$this->_dbh; extract($this->_table_names); @@ -720,7 +742,6 @@ $callback = new WikiMethodCb($searchobj, "_pagename_match_clause"); } $search_clause = $search->makeSqlClauseObj($callback); - $sql = "SELECT $fields FROM $table" . " WHERE $join_clause" . " AND ($search_clause)" @@ -808,7 +829,6 @@ } else { $result = $dbh->query($sql); } - return new WikiDB_backend_PearDB_iter($this, $result); } @@ -991,12 +1011,11 @@ . " SELECT $recent_tbl.id" . " FROM $recent_tbl, $version_tbl" . " WHERE $recent_tbl.id=$version_tbl.id" - . " AND version=latestversion" + . " AND version=latestversion" // We have some specifics here (Oracle) //. " AND content<>''" . " AND content $notempty" . ($pageid ? " AND $recent_tbl.id=$pageid" : "")); - $this->unlock(); } @@ -1030,8 +1049,9 @@ */ public function unlock($tables = false, $force = false) { - if ($this->_lock_count == 0) + if ($this->_lock_count == 0) { return; + } if (--$this->_lock_count <= 0 || $force) { $this->_unlock_tables(); $this->_lock_count = 0; @@ -1046,7 +1066,6 @@ trigger_error("virtual", E_USER_ERROR); } - /** * Serialize data */ @@ -1274,7 +1293,6 @@ class WikiDB_backend_PearDB_iter extends WikiDB_backend_PearDB_generic_iter { - function next() { $backend = &$this->_backend; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |