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] |