From: Reini U. <ru...@us...> - 2004-07-08 21:32:45
|
Update of /cvsroot/phpwiki/phpwiki/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8291 Modified Files: PageList.php WikiDB.php WikiPlugin.php Log Message: Prevent from more warnings, minor db and sort optimizations Index: PageList.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/PageList.php,v retrieving revision 1.101 retrieving revision 1.102 diff -u -2 -b -p -d -r1.101 -r1.102 --- PageList.php 8 Jul 2004 19:04:41 -0000 1.101 +++ PageList.php 8 Jul 2004 21:32:35 -0000 1.102 @@ -746,5 +746,5 @@ class PageList { */ function sortby ($column, $action) { - if (empty($column)) return; + if (empty($column)) return ''; //support multiple comma-delimited sortby args: "+hits,+pagename" if (strstr($column,',')) { @@ -776,6 +776,10 @@ class PageList { strstr($GLOBALS['request']->getArg('sortby'),$column))); } elseif ($action == 'db') { + // native sort possible? + if (in_array($column, PageList::sortable_columns())) // asc or desc: +pagename, -pagename return $column . ($order == '+' ? ' ASC' : ' DESC'); + else + return ''; } return ''; @@ -806,9 +810,10 @@ class PageList { if (!$wildcard) return $allPages; } + $do_glob = preg_match('/[\?\*]/', $wildcard); while ($pagehandle = $allPagehandles->next()) { $name = $pagehandle->getName(); $author = $pagehandle->getAuthor(); if ($author) { - if (preg_match('/[\?\*]/', $wildcard)) { + if ($do_glob) { if (glob_match($wildcard, $author)) $allPages[] = $name; @@ -829,9 +834,10 @@ class PageList { if (!$wildcard) return $allPages; } + $do_glob = preg_match('/[\?\*]/', $wildcard); while ($pagehandle = $allPagehandles->next()) { $name = $pagehandle->getName(); $owner = $pagehandle->getOwner(); if ($owner) { - if (preg_match('/[\?\*]/', $wildcard)) { + if ($do_glob) { if (glob_match($wildcard, $owner)) $allPages[] = $name; @@ -852,9 +858,10 @@ class PageList { if (!$wildcard) return $allPages; } + $do_glob = preg_match('/[\?\*]/', $wildcard); while ($pagehandle = $allPagehandles->next()) { $name = $pagehandle->getName(); $creator = $pagehandle->getCreator(); if ($creator) { - if (preg_match('/[\?\*]/', $wildcard)) { + if ($do_glob) { if (glob_match($wildcard, $creator)) $allPages[] = $name; @@ -1070,9 +1077,17 @@ class PageList { */ function _sortPages() { + //TODO: if the sortby cols are already sorted by the DB call don't do usort. if (count($this->_sortby) > 0) { + $need_sort = 0; + foreach ($this->_sortby as $col) { + if (!$this->sortby($col,'db')) + $need_sort = 1; + } + if ($need_sort) { // There are columns to sort by usort($this->_pages, array('PageList', '_pageCompare')); } } + } function limit($limit) { @@ -1268,4 +1283,7 @@ extends PageList { // $Log$ +// Revision 1.102 2004/07/08 21:32:35 rurban +// Prevent from more warnings, minor db and sort optimizations +// // Revision 1.101 2004/07/08 19:04:41 rurban // more unittest fixes (file backend, metadata RatingsDb) Index: WikiDB.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/WikiDB.php,v retrieving revision 1.77 retrieving revision 1.78 diff -u -2 -b -p -d -r1.77 -r1.78 --- WikiDB.php 8 Jul 2004 19:04:42 -0000 1.77 +++ WikiDB.php 8 Jul 2004 21:32:35 -0000 1.78 @@ -1200,5 +1200,5 @@ class WikiDB_Page $latestversion = $backend->get_latest_version($pagename); for ($v=1; $v <= $latestversion; $v++) { - $rev = $this->getRevision($v); + $rev = $this->getRevision($v,false); if ($rev and $owner = $rev->get('author_id')) { return ($owner == "The PhpWiki programming team") ? ADMIN_USER : $owner; @@ -1210,5 +1210,5 @@ class WikiDB_Page // The authenticated author of the first revision or empty if not authenticated then. function getCreator() { - if ($current = $this->getRevision(1)) return $current->get('author_id'); + if ($current = $this->getRevision(1,false)) return $current->get('author_id'); else return ''; } @@ -1893,4 +1893,7 @@ class WikiDB_cache // $Log$ +// Revision 1.78 2004/07/08 21:32:35 rurban +// Prevent from more warnings, minor db and sort optimizations +// // Revision 1.77 2004/07/08 19:04:42 rurban // more unittest fixes (file backend, metadata RatingsDb) Index: WikiPlugin.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/WikiPlugin.php,v retrieving revision 1.48 retrieving revision 1.49 diff -u -2 -b -p -d -r1.48 -r1.49 --- WikiPlugin.php 8 Jul 2004 20:30:07 -0000 1.48 +++ WikiPlugin.php 8 Jul 2004 21:32:35 -0000 1.49 @@ -100,15 +100,15 @@ class WikiPlugin if (!empty($defaults)) foreach ($defaults as $arg => $default_val) { - if (isset($argstr_args[$arg])) + if (isset($argstr_args[$arg])) { $args[$arg] = $argstr_args[$arg]; - elseif ( $request and ($argval = $request->getArg($arg)) !== false ) + } elseif ( $request and ($argval = $request->getArg($arg)) !== false ) { $args[$arg] = $argval; - elseif (isset($argstr_defaults[$arg])) + } elseif (isset($argstr_defaults[$arg])) { $args[$arg] = (string) $argstr_defaults[$arg]; - else + } else { $args[$arg] = $default_val; - - // only expand given args - if ($request and !empty($argstr)) { + } + // expand [arg] + if ($request and strstr($args[$arg], "[")) { $args[$arg] = $this->expandArg($args[$arg], $request); } @@ -132,5 +132,5 @@ class WikiPlugin // Patch by Dan F: // Expand [arg] to $request->getArg("arg") unless preceded by ~ - function expandArg($argval, $request) { + function expandArg($argval, &$request) { // return preg_replace('/\[(\w[\w\d]*)\]/e', '$request->getArg("$1")', // Replace the arg unless it is preceded by a ~ |