From d085823724aac0caec13905d0e9c1a928660cf12 Mon Sep 17 00:00:00 2001 From: rurban Date: Tue, 9 Nov 2004 17:11:17 +0000 Subject: [PATCH] * revert to the wikidb ref passing. there's no memory abuse there. * use new wikidb->_cache->_id_cache[] instead of wikidb->_iwpcache, to effectively store page ids with getPageLinks (GleanDescription) of all existing pages, which are also needed at the rendering for linkExistingWikiWord(). pass options to pageiterator. use this cache also for _get_pageid() This saves about 8 SELECT count per page (num all pagelinks). * fix passing of all page fields to the pageiterator. * fix overlarge session data which got broken with the latest ACCESS_LOG_SQL changes git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@4117 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- lib/FileFinder.php | 6 +- lib/IniConfig.php | 57 +++++-- lib/PageType.php | 4 +- lib/Request.php | 52 ++++-- lib/Template.php | 7 +- lib/Theme.php | 17 +- lib/WikiDB.php | 253 ++++++++++++++-------------- lib/WikiDB/ADODB.php | 23 +-- lib/WikiDB/SQL.php | 25 +-- lib/WikiDB/backend/ADODB.php | 55 +++--- lib/WikiDB/backend/PearDB.php | 24 ++- lib/WikiDB/backend/PearDB_mysql.php | 4 +- lib/WikiDB/backend/dbaBase.php | 6 +- lib/WikiDB/backend/file.php | 7 +- lib/config.php | 13 +- lib/display.php | 17 +- lib/main.php | 38 ++--- lib/plugin/WikiAdminRemove.php | 12 +- 18 files changed, 350 insertions(+), 270 deletions(-) diff --git a/lib/FileFinder.php b/lib/FileFinder.php index c996b5f03..fbc976bda 100644 --- a/lib/FileFinder.php +++ b/lib/FileFinder.php @@ -1,4 +1,4 @@ -_path as $dir) { @@ -568,6 +569,9 @@ function isCygwin() { } // $Log: not supported by cvs2svn $ +// Revision 1.28 2004/11/06 17:02:33 rurban +// Workaround some php-win \\ duplication bug +// // Revision 1.27 2004/10/14 19:23:58 rurban // remove debugging prints // diff --git a/lib/IniConfig.php b/lib/IniConfig.php index 576ee3634..41fa6e57c 100644 --- a/lib/IniConfig.php +++ b/lib/IniConfig.php @@ -1,5 +1,5 @@ $value) { + foreach ($rs as $item => $v) { if (defined($item)) { continue; } else { - define($item, $value); + define($item, $v); } } + unset($item); unset($v); unset($rs); unset($rsdef); - unset($apkey); - fixup_static_configs(); + fixup_static_configs(); //[1ms] // Dump all globals and constants // The question is if reading this is faster then doing IniConfig() + fixup_static_configs() if (is_writable($dump)) { save_dump($dump); } - fixup_dynamic_configs(); // store locale[] in config.php? This is too problematic. + // store locale[] in config.php? This is too problematic. + fixup_dynamic_configs(); // [100ms] } -// moved from lib/config.php +// moved from lib/config.php [1ms] function fixup_static_configs() { global $FieldSeparator, $charset, $WikiNameRegexp, $KeywordLinkRegexp, $AllActionPages; global $HTTP_SERVER_VARS, $DBParams, $LANG; @@ -722,6 +742,9 @@ function fixup_dynamic_configs() { } // $Log: not supported by cvs2svn $ +// Revision 1.63 2004/11/07 16:47:32 rurban +// fix VIRTUAL_PATH +// // Revision 1.62 2004/11/07 16:02:51 rurban // new sql access log (for spam prevention), and restructured access log class // dbh->quote (generic) diff --git a/lib/PageType.php b/lib/PageType.php index d13282709..3ef54e822 100644 --- a/lib/PageType.php +++ b/lib/PageType.php @@ -1,5 +1,5 @@ _accesslog)) { $this->_accesslog->push($this); if (empty($this->_do_chunked_output)) @@ -420,6 +418,12 @@ class Request { // sql logging must be done before the db is closed. $this->_accesslog->write_sql(); } + + session_write_close(); + if (!empty($this->_dbi)) { + $this->_dbi->close(); + unset($this->_dbi); + } if (!empty($this->_is_buffering_output)) { /* This cannot work because it might destroy xml markup */ @@ -441,10 +445,6 @@ class Request { while (@ob_end_flush()); $this->_is_buffering_output = false; } - if (!empty($this->_dbi)) { - $this->_dbi->close(); - unset($this->_dbi); - } exit; } @@ -452,6 +452,27 @@ class Request { return $this->session->get($key); } function setSessionVar($key, $val) { + if ($key == 'wiki_user') { + if (empty($val->page)) + $val->page = $this->getArg('pagename'); + if (empty($val->action)) + $val->action = $this->getArg('action'); + // avoid recursive objects and session resource handles + // avoid overlarge session data (max 4000 byte!) + if (isset($val->_group)) { + unset($val->_group->_request); + unset($val->_group->_user); + } + if (ENABLE_USER_NEW) { + unset($val->_HomePagehandle); + unset($val->_auth_dbi); + } else { + unset($val->_dbi); + unset($val->_authdbi); + unset($val->_homepage); + unset($val->_request); + } + } return $this->session->set($key, $val); } function deleteSessionVar($key) { @@ -750,7 +771,7 @@ class Request_AccessLog { * @param $logfile string Log file name. */ function Request_AccessLog ($logfile, $do_sql = false) { - global $request; + //global $request; $this->logfile = $logfile; if ($logfile and !is_writeable($logfile)) { @@ -763,15 +784,17 @@ class Request_AccessLog { , E_USER_NOTICE); } //$request->_accesslog =& $this; - if (empty($request->_accesslog->entries)) - register_shutdown_function("Request_AccessLogEntry_shutdown_function"); + //if (empty($request->_accesslog->entries)) + register_shutdown_function("Request_AccessLogEntry_shutdown_function"); if ($do_sql) { global $DBParams; - if (!in_array($DBParams['dbtype'], array('SQL','ADODB'))) + if (!in_array($DBParams['dbtype'], array('SQL','ADODB'))) { trigger_error("Unsupported database backend for ACCESS_LOG_SQL.\nNeed DATABASE_TYPE=SQL or ADODB"); - $this->_dbi =& $request->_dbi; - $this->logtable = (!empty($DBParams['prefix']) ? $DBParams['prefix'] : '')."accesslog"; + } else { + $this->_dbi =& $request->_dbi; + $this->logtable = (!empty($DBParams['prefix']) ? $DBParams['prefix'] : '')."accesslog"; + } } $this->entries = array(); $this->entries[] = & new Request_AccessLogEntry($this); @@ -1284,6 +1307,9 @@ class HTTP_ValidatorSet { // $Log: not supported by cvs2svn $ +// Revision 1.76 2004/11/09 08:15:18 rurban +// fix ADODB quoting style +// // Revision 1.75 2004/11/07 18:34:28 rurban // more logging fixes // diff --git a/lib/Template.php b/lib/Template.php index 0fcafcad8..5fc286435 100644 --- a/lib/Template.php +++ b/lib/Template.php @@ -1,5 +1,5 @@ _request = $request; + $this->_request =& $request; $this->_name = $name; $request->_TemplatesProcessed[$name] = 1; $this->_basepage = $request->getArg('pagename'); @@ -270,6 +270,9 @@ function GeneratePageasXML($content, $title, $page_revision = false, $args = fal } // $Log: not supported by cvs2svn $ +// Revision 1.67 2004/11/05 18:03:35 rurban +// shorten the template chain in errmsg +// // Revision 1.66 2004/11/01 10:43:55 rurban // seperate PassUser methods into seperate dir (memory usage) // fix WikiUser (old) overlarge data session diff --git a/lib/Theme.php b/lib/Theme.php index 0a2e6ed77..b422dd1a0 100644 --- a/lib/Theme.php +++ b/lib/Theme.php @@ -1,4 +1,4 @@ -name; + if (!$wikipage->isValid('strict')) + return $WikiTheme->linkBadWikiWord($wikipage, $label); } else { $wikipage = new WikiPageName($page_or_rev, $request->getPage()); $pagename = $wikipage->name; + if (!$wikipage->isValid('strict')) + return $WikiTheme->linkBadWikiWord($wikipage, $label); } - if (!is_string($wikipage) and !$wikipage->isValid('strict')) - return $WikiTheme->linkBadWikiWord($wikipage, $label); - if ($type == 'auto' or $type == 'if_known') { if (isset($page)) { - $current = $page->getCurrentRevision(); - $exists = ! $current->hasDefaultContents(); + $exists = $page->exists(); } else { - $dbi = $request->getDbh(); + $dbi =& $request->_dbi; $exists = $dbi->isWikiPage($wikipage->name); } } @@ -1376,6 +1376,9 @@ function listAvailableLanguages() { } // $Log: not supported by cvs2svn $ +// Revision 1.112 2004/11/03 16:50:31 rurban +// some new defaults and constants, renamed USE_DOUBLECLICKEDIT to ENABLE_DOUBLECLICKEDIT +// // Revision 1.111 2004/10/21 20:20:53 rurban // From patch #970004 "Double clic to edit" by pixels. // diff --git a/lib/WikiDB.php b/lib/WikiDB.php index bba1bbee9..541c697e4 100644 --- a/lib/WikiDB.php +++ b/lib/WikiDB.php @@ -1,11 +1,8 @@ _cache = new WikiDB_cache($backend); - // If the database doesn't yet have a timestamp, initialize it now. $GLOBALS['request']->_dbi = $this; + + // If the database doesn't yet have a timestamp, initialize it now. if ($this->get('_timestamp') === false) $this->touch(); @@ -189,13 +179,13 @@ class WikiDB { $error_displayed = true; if (function_exists("xdebug_get_function_stack")) var_dump(xdebug_get_function_stack()); - trigger_error("empty pagename",E_USER_WARNING); + trigger_error("empty pagename", E_USER_WARNING); return false; } } else { assert($pagename != ''); } - return new WikiDB_Page(/*$this,*/ $pagename); + return new WikiDB_Page($this, $pagename); } /** @@ -265,7 +255,7 @@ class WikiDB { } } - //How to create a RecentChanges entry with explaining summary? + //How to create a RecentChanges entry with explaining summary? Dynamically /* $page = $this->getPage($pagename); $current = $page->getCurrentRevision(); @@ -300,15 +290,11 @@ class WikiDB { $GLOBALS['request']->setArg('paging','auto'); } $result = $this->_backend->get_all_pages($include_empty, $sortby, $limit); - return new WikiDB_PageIterator(/*$this,*/ $result); + return new WikiDB_PageIterator($this, $result, array('include_empty' => $include_empty, + 'limit' => $limit)); } - // Do we need this? - //function nPages() { - //} /** - * Yes, for paging. Renamed. - * * filter = true: include also empty pages * exclude: comma-seperated list pagenames */ @@ -343,7 +329,7 @@ class WikiDB { */ function titleSearch($search) { $result = $this->_backend->text_search($search); - return new WikiDB_PageIterator(/*$this,*/ $result); + return new WikiDB_PageIterator($this, $result); } /** @@ -364,7 +350,7 @@ class WikiDB { */ function fullSearch($search) { $result = $this->_backend->text_search($search, 'full_text'); - return new WikiDB_PageIterator(/*$this,*/ $result); + return new WikiDB_PageIterator($this, $result); } /** @@ -383,7 +369,7 @@ class WikiDB { */ function mostPopular($limit = 20, $sortby = '-hits') { $result = $this->_backend->most_popular($limit, $sortby); - return new WikiDB_PageIterator(/*$this,*/ $result); + return new WikiDB_PageIterator($this, $result); } /** @@ -416,7 +402,7 @@ class WikiDB { */ function mostRecent($params = false) { $result = $this->_backend->most_recent($params); - return new WikiDB_PageRevisionIterator(/*$this,*/ $result); + return new WikiDB_PageRevisionIterator($this, $result); } /** @@ -651,8 +637,8 @@ class WikiDB { */ class WikiDB_Page { - function WikiDB_Page(/*&$wikidb,*/ $pagename) { - //$this->_wikidb = &$wikidb; + function WikiDB_Page(&$wikidb, $pagename) { + $this->_wikidb = &$wikidb; $this->_pagename = $pagename; if (DEBUG) { if (!(is_string($pagename) and $pagename != '')) { @@ -682,11 +668,9 @@ class WikiDB_Page // we don't cache the content (only true or false) and // we purge the pagedata (_cached_html) also function exists() { + if (isset($this->_wikidb->_cache->_id_cache[$this->_pagename])) return true; $current = $this->getCurrentRevision(false); - unset($GLOBALS['request']->_dbi->_cache->_pagedata_cache[$this->_pagename]); - $exists = ! $current->hasDefaultContents(); - unset($current->_data->{'%pagedata'}); - return $exists; + return ! $current->hasDefaultContents(); } /** @@ -701,8 +685,8 @@ class WikiDB_Page * use a WikiDB_PageRevision object here.) */ function deleteRevision($version) { - $backend = &$GLOBALS['request']->_dbi->_backend; - $cache = &$GLOBALS['request']->_dbi->_cache; + $backend = &$this->_wikidb->_backend; + $cache = &$this->_wikidb->_cache; $pagename = &$this->_pagename; $version = $this->_coerce_to_version($version); @@ -750,8 +734,8 @@ class WikiDB_Page * */ function mergeRevision($version) { - $backend = &$GLOBALS['request']->_dbi->_backend; - $cache = &$GLOBALS['request']->_dbi->_cache; + $backend = &$this->_wikidb->_backend; + $cache = &$this->_wikidb->_cache; $pagename = &$this->_pagename; $version = $this->_coerce_to_version($version); @@ -815,9 +799,9 @@ class WikiDB_Page * @return WikiDB_PageRevision Returns the new WikiDB_PageRevision object. If * $version was incorrect, returns false */ - function createRevision($version, $content, $metadata, $links) { - $backend = &$GLOBALS['request']->_dbi->_backend; - $cache = &$GLOBALS['request']->_dbi->_cache; + function createRevision($version, &$content, $metadata, $links) { + $backend = &$this->_wikidb->_backend; + $cache = &$this->_wikidb->_cache; $pagename = &$this->_pagename; $backend->lock(array('version','page','recent','link','nonempty')); @@ -873,8 +857,8 @@ class WikiDB_Page $backend->unlock(array('version','page','recent','link','nonempty')); - return new WikiDB_PageRevision(/*$GLOBALS['request']->_dbi,*/ - $pagename, $newversion, $data); + return new WikiDB_PageRevision($this->_wikidb, $pagename, $newversion, + $data); } /** A higher-level interface to createRevision. @@ -898,11 +882,10 @@ class WikiDB_Page $meta['pagetype'] = $type->getName(); $links = $formatted->getWikiPageLinks(); - $backend = &$GLOBALS['request']->_dbi->_backend; + $backend = &$this->_wikidb->_backend; $newrevision = $this->createRevision($version, $wikitext, $meta, $links); - if ($newrevision) - if (!defined('WIKIDB_NOCACHE_MARKUP') or !WIKIDB_NOCACHE_MARKUP) - $this->set('_cached_html', $formatted->pack()); + if ($newrevision and !WIKIDB_NOCACHE_MARKUP) + $this->set('_cached_html', $formatted->pack()); // FIXME: probably should have some global state information // in the backend to control when to optimize. @@ -917,7 +900,7 @@ class WikiDB_Page /* Generate notification emails? */ if (isa($newrevision, 'WikiDB_PageRevision')) { // Save didn't fail because of concurrent updates. - $notify = $GLOBALS['request']->_dbi->get('notify'); + $notify = $this->_wikidb->get('notify'); if (!empty($notify) and is_array($notify)) { list($emails, $userids) = $this->getPageChangeEmails($notify); if (!empty($emails)) { @@ -986,21 +969,22 @@ class WikiDB_Page * Send udiff for a changed page to multiple users. * TODO: for remove, rename also */ - function sendPageChangeNotification($wikitext, $version, $meta, $emails, $userids) { + function sendPageChangeNotification(&$wikitext, $version, $meta, $emails, $userids) { global $request; if (@is_array($request->_deferredPageChangeNotification)) { // collapse multiple changes (loaddir) into one email $request->_deferredPageChangeNotification[] = array($this->_pagename, $emails, $userids); return; } - - $backend = &$request->_dbi->_backend; + $backend = &$this->_wikidb->_backend; + //$backend = &$request->_dbi->_backend; $subject = _("Page change").' '.urlencode($this->_pagename); $previous = $backend->get_previous_version($this->_pagename, $version); if (!isset($meta['mtime'])) $meta['mtime'] = time(); if ($previous) { - $difflink = WikiURL($this->_pagename, array('action'=>'diff'),true); - $cache = &$request->_dbi->_cache; + $difflink = WikiURL($this->_pagename, array('action'=>'diff'), true); + $cache = &$this->_wikidb->_cache; + //$cache = &$request->_dbi->_cache; $this_content = explode("\n", $wikitext); $prevdata = $cache->get_versiondata($this->_pagename, $previous, true); if (empty($prevdata['%content'])) @@ -1035,7 +1019,7 @@ class WikiDB_Page $this->_pagename, join(',',$userids)), E_USER_WARNING); } - /** support mass rename / remove (not yet) + /** support mass rename / remove (not yet tested) */ function sendPageRenameNotification($to, &$meta, $emails, $userids) { global $request; @@ -1068,8 +1052,8 @@ class WikiDB_Page * @return WikiDB_PageRevision The current WikiDB_PageRevision object. */ function getCurrentRevision($need_content = true) { - $backend = &$GLOBALS['request']->_dbi->_backend; - $cache = &$GLOBALS['request']->_dbi->_cache; + $backend = &$this->_wikidb->_backend; + $cache = &$this->_wikidb->_cache; $pagename = &$this->_pagename; // Prevent deadlock in case of memory exhausted errors @@ -1098,17 +1082,17 @@ class WikiDB_Page * Note that version zero of any page always exists. */ function getRevision($version, $need_content=true) { - $cache = &$GLOBALS['request']->_dbi->_cache; + $cache = &$this->_wikidb->_cache; $pagename = &$this->_pagename; if (! $version ) // 0 or false - return new WikiDB_PageRevision(/*$GLOBALS['request']->_dbi,*/ $pagename, 0); + return new WikiDB_PageRevision($this->_wikidb, $pagename, 0); assert($version > 0); $vdata = $cache->get_versiondata($pagename, $version, $need_content); if (!$vdata) return false; - return new WikiDB_PageRevision(/*$GLOBALS['request']->_dbi,*/ $pagename, $version, + return new WikiDB_PageRevision($this->_wikidb, $pagename, $version, $vdata); } @@ -1129,7 +1113,7 @@ class WikiDB_Page * the default revision) will always be found. */ function getRevisionBefore($version, $need_content=true) { - $backend = &$GLOBALS['request']->_dbi->_backend; + $backend = &$this->_wikidb->_backend; $pagename = &$this->_pagename; $version = $this->_coerce_to_version($version); @@ -1155,9 +1139,9 @@ class WikiDB_Page * WikiDB_Page in reverse order by version number. */ function getAllRevisions() { - $backend = &$GLOBALS['request']->_dbi->_backend; + $backend = &$this->_wikidb->_backend; $revs = $backend->get_all_revisions($this->_pagename); - return new WikiDB_PageRevisionIterator(/*$GLOBALS['request']->_dbi,*/ $revs); + return new WikiDB_PageRevisionIterator($this->_wikidb, $revs); } /** @@ -1170,23 +1154,25 @@ class WikiDB_Page * @return WikiDB_PageIterator A WikiDB_PageIterator containing * all matching pages. */ - function getLinks($reversed = true) { - $backend = &$GLOBALS['request']->_dbi->_backend; - $result = $backend->get_links($this->_pagename, $reversed); - return new WikiDB_PageIterator(/*$GLOBALS['request']->_dbi,*/ $result); + function getLinks($reversed = true, $include_empty=false) { + $backend = &$this->_wikidb->_backend; + $result = $backend->get_links($this->_pagename, $reversed, $include_empty=false); + //if (empty($this->_iwpcache) and !$include_empty) + // $this->_iwpcache = $result->asArray(); + return new WikiDB_PageIterator($this->_wikidb, $result, array('include_empty' => $include_empty)); } /** * All Links from other pages to this page. */ - function getBackLinks() { - return $this->getLinks(true); + function getBackLinks($include_empty=false) { + return $this->getLinks(true, $include_empty=false); } /** * Forward Links: All Links from this page to other pages. */ - function getPageLinks() { - return $this->getLinks(false); + function getPageLinks($include_empty=false) { + return $this->getLinks(false, $include_empty=false); } /** @@ -1211,7 +1197,7 @@ class WikiDB_Page * is not set. */ function get($key) { - $cache = &$GLOBALS['request']->_dbi->_cache; + $cache = &$this->_wikidb->_cache; if (!$key || $key[0] == '%') return false; $data = $cache->get_pagedata($this->_pagename); @@ -1224,7 +1210,7 @@ class WikiDB_Page * @return hash The page meta-data. */ function getMetaData() { - $cache = &$GLOBALS['request']->_dbi->_cache; + $cache = &$this->_wikidb->_cache; $data = $cache->get_pagedata($this->_pagename); $meta = array(); foreach ($data as $key => $val) { @@ -1244,7 +1230,7 @@ class WikiDB_Page * @param string $newval New value. */ function set($key, $newval) { - $cache = &$GLOBALS['request']->_dbi->_cache; + $cache = &$this->_wikidb->_cache; $pagename = &$this->_pagename; assert($key && $key[0] != '%'); @@ -1279,8 +1265,12 @@ class WikiDB_Page * @access public */ function increaseHitCount() { - @$newhits = $this->get('hits') + 1; - $this->set('hits', $newhits); + if (method_exists($this->_wikidb->_backend, 'increaseHitCount')) + $this->_backend->increaseHitCount(); + else { + @$newhits = $this->get('hits') + 1; + $this->set('hits', $newhits); + } } /** @@ -1321,12 +1311,7 @@ class WikiDB_Page } function isUserPage ($include_empty = true) { - if ($include_empty) { - $current = $this->getCurrentRevision(false); - if ($current->hasDefaultContents()) { - return false; - } - } + if (!$include_empty and !$this->exists()) return false; return $this->get('pref') ? true : false; } @@ -1335,7 +1320,7 @@ class WikiDB_Page if ($owner = $this->get('owner')) return ($owner == "The PhpWiki programming team") ? ADMIN_USER : $owner; // check all revisions forwards for the first author_id - $backend = &$GLOBALS['request']->_dbi->_backend; + $backend = &$this->_wikidb->_backend; $pagename = &$this->_pagename; $latestversion = $backend->get_latest_version($pagename); for ($v=1; $v <= $latestversion; $v++) { @@ -1373,15 +1358,13 @@ class WikiDB_PageRevision { //var $_transformedContent = false; // set by WikiDB_Page::save() - function WikiDB_PageRevision(/*$wikidb,*/ $pagename, $version, - $versiondata = false) - { - //$GLOBALS['request']->_dbi = &$wikidb; - $this->_pagename = $pagename; - $this->_version = $version; - $this->_data = $versiondata ? $versiondata : array(); - $this->_transformedContent = false; // set by WikiDB_Page::save() - } + function WikiDB_PageRevision(&$wikidb, $pagename, $version, $versiondata = false) { + $this->_wikidb = &$wikidb; + $this->_pagename = $pagename; + $this->_version = $version; + $this->_data = $versiondata ? $versiondata : array(); + $this->_transformedContent = false; // set by WikiDB_Page::save() + } /** * Get the WikiDB_Page which this revision belongs to. @@ -1391,7 +1374,7 @@ class WikiDB_PageRevision * @return WikiDB_Page The WikiDB_Page which this revision belongs to. */ function getPage() { - return new WikiDB_Page(/*$GLOBALS['request']->_dbi,*/ $this->_pagename); + return new WikiDB_Page($this->_wikidb, $this->_pagename); } /** @@ -1421,7 +1404,7 @@ class WikiDB_PageRevision */ function hasDefaultContents() { $data = &$this->_data; - return empty($data['%content']); + return empty($data['%content']); // FIXME: what if it's the number 0? <>'' or === false } /** @@ -1472,7 +1455,7 @@ class WikiDB_PageRevision * contents. */ function getTransformedContent($pagetype_override=false) { - $backend = &$GLOBALS['request']->_dbi->_backend; + $backend = &$this->_wikidb->_backend; if ($pagetype_override) { // Figure out the normal page-type for this page. @@ -1491,7 +1474,7 @@ class WikiDB_PageRevision $possibly_cache_results = true; - if (defined('WIKIDB_NOCACHE_MARKUP') and WIKIDB_NOCACHE_MARKUP) { + if (!USECACHE or WIKIDB_NOCACHE_MARKUP) { if (WIKIDB_NOCACHE_MARKUP == 'purge') { // flush cache for this page. $page = $this->getPage(); @@ -1512,10 +1495,9 @@ class WikiDB_PageRevision } if (!$this->_transformedContent) { - $text = $this->getPackedContent(); $this->_transformedContent = new TransformedText($this->getPage(), - $text, + $this->getPackedContent(), $this->getMetaData()); if ($possibly_cache_results) { @@ -1582,7 +1564,7 @@ class WikiDB_PageRevision } function _get_content() { - $cache = &$GLOBALS['request']->_dbi->_cache; + $cache = &$this->_wikidb->_cache; $pagename = $this->_pagename; $version = $this->_version; @@ -1691,12 +1673,14 @@ class WikiDB_PageRevision */ class WikiDB_PageIterator { - function WikiDB_PageIterator(/*&$wikidb,*/ &$pages) { - $this->_pages = $pages; + function WikiDB_PageIterator(&$wikidb, &$iter, $options=false) { + $this->_iter = $iter; // a WikiDB_backend_iterator + $this->_wikidb = &$wikidb; + $this->_options = $options; } function count () { - return $this->_pages->count(); + return $this->_iter->count(); } /** @@ -1707,7 +1691,7 @@ class WikiDB_PageIterator * @return WikiDB_Page The next WikiDB_Page in the sequence. */ function next () { - if ( ! ($next = $this->_pages->next()) ) + if ( ! ($next = $this->_iter->next()) ) return false; $pagename = &$next['pagename']; @@ -1719,10 +1703,14 @@ class WikiDB_PageIterator // there's always hits, but we cache only if more // (well not with file, cvs and dba) if (isset($next['pagedata']) and count($next['pagedata']) > 1) { - $GLOBALS['request']->_dbi->_cache->cache_data($next); + $this->_wikidb->_cache->cache_data($next); + // cache existing page id's since we iterate over all links in GleanDescription + // and need them later for LinkExistingWord + } elseif ($this->_options and array_key_exists('include_empty', $this->_options) + and !$this->_options['include_empty'] and isset($next['id'])) { + $this->_wikidb->_cache->_id_cache[$next['pagename']] = $next['id']; } - - return new WikiDB_Page(/*$GLOBALS['request']->_dbi,*/ $pagename); + return new WikiDB_Page($this->_wikidb, $pagename); } /** @@ -1738,14 +1726,14 @@ class WikiDB_PageIterator * @access public */ function free() { - $this->_pages->free(); + $this->_iter->free(); } function asArray() { $result = array(); while ($page = $this->next()) $result[] = $page; - $this->free(); + //$this->reset(); return $result; } @@ -1758,9 +1746,10 @@ class WikiDB_PageIterator */ class WikiDB_PageRevisionIterator { - function WikiDB_PageRevisionIterator(/*&$wikidb,*/ $revisions) { + function WikiDB_PageRevisionIterator(&$wikidb, &$revisions, $options=false) { $this->_revisions = $revisions; - //$GLOBALS['request']->_dbi = &$wikidb; + $this->_wikidb = &$wikidb; + $this->_options = $options; } function count () { @@ -1779,7 +1768,7 @@ class WikiDB_PageRevisionIterator if ( ! ($next = $this->_revisions->next()) ) return false; - $GLOBALS['request']->_dbi->_cache->cache_data($next); + $this->_wikidb->_cache->cache_data($next); $pagename = $next['pagename']; $version = $next['version']; @@ -1803,7 +1792,7 @@ class WikiDB_PageRevisionIterator } } else assert($version > 0); - return new WikiDB_PageRevision(/*$GLOBALS['request']->_dbi,*/ $pagename, $version, + return new WikiDB_PageRevision($this->_wikidb, $pagename, $version, $versiondata); } @@ -1905,17 +1894,19 @@ class WikiDB_cache $this->_versiondata_cache = array(); array_push ($this->_versiondata_cache, array()); $this->_glv_cache = array(); + $this->_id_cache = array(); // formerly ->_dbi->_iwpcache (nonempty pages => id) } function close() { $this->_pagedata_cache = array(); $this->_versiondata_cache = array(); $this->_glv_cache = array(); + $this->_id_cache = array(); } function get_pagedata($pagename) { assert(is_string($pagename) && $pagename != ''); - if (defined('USECACHE') and USECACHE) { + if (USECACHE) { $cache = &$this->_pagedata_cache; if (!isset($cache[$pagename]) || !is_array($cache[$pagename])) { $cache[$pagename] = $this->_backend->get_pagedata($pagename); @@ -1938,9 +1929,7 @@ class WikiDB_cache $this->_backend->update_pagedata($pagename, $newdata); - if (defined('USECACHE') and USECACHE - and is_array($this->_pagedata_cache[$pagename])) - { + if (USECACHE and is_array($this->_pagedata_cache[$pagename])) { $cachedata = &$this->_pagedata_cache[$pagename]; foreach($newdata as $key => $val) $cachedata[$key] = $val; @@ -1951,13 +1940,13 @@ class WikiDB_cache unset ($this->_pagedata_cache[$pagename]); unset ($this->_versiondata_cache[$pagename]); unset ($this->_glv_cache[$pagename]); - unset ($this->_backend->_page_data); + unset ($this->_id_cache[$pagename]); + //unset ($this->_backend->_page_data); } function delete_page($pagename) { $this->_backend->delete_page($pagename); - unset ($this->_pagedata_cache[$pagename]); - unset ($this->_glv_cache[$pagename]); + $this->invalidate_cache($pagename); } // FIXME: ugly @@ -1968,7 +1957,7 @@ class WikiDB_cache function get_versiondata($pagename, $version, $need_content = false) { // FIXME: Seriously ugly hackage - if (defined('USECACHE') and USECACHE) { //temporary - for debugging + if (USECACHE) { //temporary - for debugging assert(is_string($pagename) && $pagename != ''); // there is a bug here somewhere which results in an assertion failure at line 105 // of ArchiveCleaner.php It goes away if we use the next line. @@ -1993,7 +1982,7 @@ class WikiDB_cache if ($vdata && !empty($vdata['%pagedata'])) { $this->_pagedata_cache[$pagename] =& $vdata['%pagedata']; // only store _cached_html for the requested page - if (defined('USECACHE') and USECACHE + if (USECACHE and isset($vdata['%pagedata']['_cached_html']) and $pagename != $GLOBALS['request']->getArg('pagename')) { @@ -2037,7 +2026,7 @@ class WikiDB_cache } function get_latest_version($pagename) { - if (defined('USECACHE') and USECACHE) { + if (USECACHE) { assert (is_string($pagename) && $pagename != ''); $cache = &$this->_glv_cache; if (!isset($cache[$pagename])) { @@ -2050,10 +2039,30 @@ class WikiDB_cache return $this->_backend->get_latest_version($pagename); } } - }; +function _sql_debuglog($msg, $newline=true, $shutdown=false) { + static $fp = false; + static $i = 0; + if (!$fp) { + $stamp = strftime("%y%m%d-%H%M%S"); + $fp = fopen("/tmp/sql-$stamp.log", "a"); + register_shutdown_function("_sql_debuglog_shutdown_function"); + } elseif ($shutdown) { + fclose($fp); + return; + } + if ($newline) fputs($fp, "[$i++] $msg"); + else fwrite($fp, $msg); +} +function _sql_debuglog_shutdown_function() { + _sql_debuglog('',false,true); +} + // $Log: not supported by cvs2svn $ +// Revision 1.98 2004/11/07 18:34:29 rurban +// more logging fixes +// // Revision 1.97 2004/11/07 16:02:51 rurban // new sql access log (for spam prevention), and restructured access log class // dbh->quote (generic) diff --git a/lib/WikiDB/ADODB.php b/lib/WikiDB/ADODB.php index 84c6b214c..36d6237aa 100644 --- a/lib/WikiDB/ADODB.php +++ b/lib/WikiDB/ADODB.php @@ -1,5 +1,5 @@ _iwpcache)) - $this->_iwpcache = array_flip($this->_backend->get_all_pagenames()); - return isset($this->_iwpcache[$pagename]); - */ - - if (!isset($this->_iwpcache[$pagename])) - $this->_iwpcache[$pagename] = $this->_backend->is_wiki_page($pagename); - return $this->_iwpcache[$pagename]; - - // Talk to the backend directly for max speed. - /* - $pagedata = $this->_cache->get_pagedata($pagename); - return !empty($pagedata[':non_default']); - */ + $pagename = (string) $pagename; + if ($pagename === '') return false; + if (!array_key_exists($pagename, $this->_cache->_id_cache)) { + $this->_cache->_id_cache[$pagename] = $this->_backend->is_wiki_page($pagename); + } + return $this->_cache->_id_cache[$pagename]; } }; diff --git a/lib/WikiDB/SQL.php b/lib/WikiDB/SQL.php index ce2956a77..a197c3af9 100644 --- a/lib/WikiDB/SQL.php +++ b/lib/WikiDB/SQL.php @@ -1,4 +1,4 @@ -_iwpcache = array(); + $this->WikiDB($backend, $dbparams); } @@ -38,24 +39,16 @@ class WikiDB_SQL extends WikiDB /** * Determine whether page exists (in non-default form). - * @see WikiDB::isWikiPage + * @see WikiDB::isWikiPage for the slow generic version */ function isWikiPage ($pagename) { - /* - if (empty($this->_iwpcache)) - $this->_iwpcache = array_flip($this->_backend->get_all_pagenames()); - return isset($this->_iwpcache[$pagename]); - */ - - if (!isset($this->_iwpcache[$pagename])) + $pagename = (string) $pagename; + if ($pagename === '') return false; + //if (empty($this->_iwpcache)) { $this->_iwpcache = array(); } + if (!array_key_exists($pagename, $this->_iwpcache)) { $this->_iwpcache[$pagename] = $this->_backend->is_wiki_page($pagename); + } return $this->_iwpcache[$pagename]; - - // Talk to the backend directly for max speed. - /* - $pagedata = $this->_cache->get_pagedata($pagename); - return !empty($pagedata[':non_default']); - */ } }; diff --git a/lib/WikiDB/backend/ADODB.php b/lib/WikiDB/backend/ADODB.php index 667ba602f..6edad1164 100644 --- a/lib/WikiDB/backend/ADODB.php +++ b/lib/WikiDB/backend/ADODB.php @@ -1,5 +1,5 @@ _dbparams = $dbparams; $this->_dbh = &ADONewConnection($parsed['phptype']); + if (DEBUG & _DEBUG_SQL) { + $this->_dbh->debug = true; + $GLOBALS['ADODB_OUTP'] = '_sql_debuglog'; + } $this->_dsn = $parsed; if (!empty($parsed['persistent'])) $conn = $this->_dbh->PConnect($parsed['hostspec'],$parsed['username'], - $parsed['password'], $parsed['database']); + $parsed['password'], $parsed['database']); else $conn = $this->_dbh->Connect($parsed['hostspec'],$parsed['username'], $parsed['password'], $parsed['database']); - - //$this->_dbh->debug = true; // Since 1.3.10 we use the faster ADODB_FETCH_NUM, // with some ASSOC based recordsets. $GLOBALS['ADODB_FETCH_MODE'] = ADODB_FETCH_NUM; $this->_dbh->SetFetchMode(ADODB_FETCH_NUM); - - // Old comment: - // With ADODB_COUNTRECS false it should speed up queries, but: - // 1) It only works with PHP >= 4.0.6; and - // 2) At the moment, I haven't figured out why the wrong results are returned' $GLOBALS['ADODB_COUNTRECS'] = false; $prefix = isset($dbparams['prefix']) ? $dbparams['prefix'] : ''; @@ -234,6 +231,11 @@ extends WikiDB_backend } function _get_pageid($pagename, $create_if_missing = false) { + + // check id_cache + global $request; + $cache =& $request->_dbi->_cache->_id_cache; + if ($cache[$pagename]) return $cache[$pagename]; $dbh = &$this->_dbh; $page_tbl = $this->_table_names['page_tbl']; @@ -507,8 +509,12 @@ extends WikiDB_backend /** * Find pages which link to or are linked from a page. + * + * 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. */ - function get_links($pagename, $reversed = true) { + function get_links($pagename, $reversed=true, $include_empty=false) { $dbh = &$this->_dbh; extract($this->_table_names); @@ -522,21 +528,23 @@ extends WikiDB_backend $result = $dbh->Execute("SELECT $want.id AS id, $want.pagename AS pagename," . " $want.hits AS hits" . " FROM $link_tbl, $page_tbl linker, $page_tbl linkee" + . (!$include_empty ? ", $nonempty_tbl" : '') . " WHERE linkfrom=linker.id AND linkto=linkee.id" . " AND $have.pagename=$qpagename" + . (!$include_empty ? " AND $nonempty_tbl.id=$want.id" : "") //. " GROUP BY $want.id" . " ORDER BY $want.pagename"); return new WikiDB_backend_ADODB_iter($this, $result, $this->page_tbl_field_list); } - function get_all_pages($include_deleted=false, $sortby=false, $limit=false) { + function get_all_pages($include_empty=false, $sortby=false, $limit=false) { $dbh = &$this->_dbh; extract($this->_table_names); $orderby = $this->sortby($sortby, 'db'); if ($orderby) $orderby = 'ORDER BY ' . $orderby; //$dbh->SetFetchMode(ADODB_FETCH_ASSOC); if (strstr($orderby, 'mtime ')) { // was ' mtime' - if ($include_deleted) { + if ($include_empty) { $sql = "SELECT " . $this->page_tbl_fields ." FROM $page_tbl, $recent_tbl, $version_tbl" @@ -554,7 +562,7 @@ extends WikiDB_backend . " $orderby"; } } else { - if ($include_deleted) { + if ($include_empty) { $sql = "SELECT " . $this->page_tbl_fields . " FROM $page_tbl $orderby"; @@ -605,7 +613,7 @@ extends WikiDB_backend $search_clause = $search->makeSqlClause($callback); $result = $dbh->Execute("SELECT $fields FROM $table" . " WHERE $join_clause" - . " AND ($search_clause)" + . " AND ($search_clause)" . " ORDER BY pagename"); return new WikiDB_backend_ADODB_iter($this, $result, $field_list); @@ -932,7 +940,7 @@ extends WikiDB_backend_iterator if (is_null($field_list)) { // No field list passed, retrieve from DB - // WikiLiens is using the iterator behind the scene + // WikiLens is using the iterator behind the scene $field_list = array(); $fields = $query_result->FieldCount(); for ($i = 0; $i < $fields ; $i++) { @@ -949,7 +957,7 @@ extends WikiDB_backend_iterator return false; } $count = $this->_result->numRows(); - $this->_result->Close(); + //$this->_result->Close(); return $count; } @@ -967,6 +975,7 @@ extends WikiDB_backend_iterator foreach ($this->_fields as $field) { $rec_assoc[$field] = $rec_num[$i++]; } + // check if the cache can be populated here? $result->MoveNext(); return $rec_assoc; @@ -1001,16 +1010,11 @@ extends WikiDB_backend_ADODB_generic_iter $result->MoveNext(); if (isset($rec_assoc['pagedata'])) - $pagedata = $backend->_extract_page_data($rec_assoc['pagedata'], $rec_assoc['hits']); - else - $pagedata = false; - $rec = array('pagename' => $rec_assoc['pagename'], - 'pagedata' => $pagedata); + $rec_assoc['pagedata'] = $backend->_extract_page_data($rec_assoc['pagedata'], $rec_assoc['hits']); if (!empty($rec_assoc['version'])) { - $rec['versiondata'] = $backend->_extract_version_data_assoc($rec_assoc); - $rec['version'] = $rec_assoc['version']; + $rec_assoc['versiondata'] = $backend->_extract_version_data_assoc($rec_assoc); } - return $rec; + return $rec_assoc; } } @@ -1174,6 +1178,9 @@ extends WikiDB_backend_ADODB_generic_iter } // $Log: not supported by cvs2svn $ +// Revision 1.47 2004/11/06 17:11:42 rurban +// The optimized version doesn't query for pagedata anymore. +// // Revision 1.46 2004/11/01 10:43:58 rurban // seperate PassUser methods into seperate dir (memory usage) // fix WikiUser (old) overlarge data session diff --git a/lib/WikiDB/backend/PearDB.php b/lib/WikiDB/backend/PearDB.php index 6d050a407..14f3bde39 100644 --- a/lib/WikiDB/backend/PearDB.php +++ b/lib/WikiDB/backend/PearDB.php @@ -1,5 +1,5 @@ _dbi->_cache->_id_cache; + if ($cache[$pagename]) return $cache[$pagename]; + $dbh = &$this->_dbh; $page_tbl = $this->_table_names['page_tbl']; @@ -446,7 +451,7 @@ extends WikiDB_backend /** * Find pages which link to or are linked from a page. */ - function get_links($pagename, $reversed = true) { + function get_links($pagename, $reversed=true, $include_empty=false) { $dbh = &$this->_dbh; extract($this->_table_names); @@ -456,21 +461,22 @@ extends WikiDB_backend list($have,$want) = array('linker', 'linkee'); $qpagename = $dbh->quoteString($pagename); - $result = $dbh->query("SELECT $want.id as id, $want.pagename as pagename, $want.hits as hits" // Looks like 'AS' in column alias is a MySQL thing, Oracle does not like it // and the PostgresSQL manual does not have it either // Since it is optional in mySQL, just remove it... . " FROM $link_tbl, $page_tbl linker, $page_tbl linkee" + . (!$include_empty ? ", $nonempty_tbl" : '') . " WHERE linkfrom=linker.id AND linkto=linkee.id" . " AND $have.pagename='$qpagename'" + . (!$include_empty ? " AND $nonempty_tbl.id=$want.id" : "") //. " GROUP BY $want.id" . " ORDER BY $want.pagename"); return new WikiDB_backend_PearDB_iter($this, $result); } - function get_all_pages($include_deleted=false, $sortby=false, $limit=false) { + function get_all_pages($include_empty=false, $sortby=false, $limit=false) { $dbh = &$this->_dbh; extract($this->_table_names); // Limit clause is NOT portable! @@ -479,7 +485,7 @@ extends WikiDB_backend $orderby = $this->sortby($sortby, 'db'); if ($orderby) $orderby = 'ORDER BY ' . $orderby; if (strstr($orderby, 'mtime ')) { // multiple columns possible - if ($include_deleted) { + if ($include_empty) { $sql = "SELECT " . $this->page_tbl_fields . " FROM $page_tbl, $recent_tbl, $version_tbl" @@ -497,7 +503,7 @@ extends WikiDB_backend . " $orderby"; } } else { - if ($include_deleted) { + if ($include_empty) { $sql = "SELECT " . $this->page_tbl_fields ." FROM $page_tbl $orderby"; @@ -1018,7 +1024,13 @@ extends WikiDB_backend_PearDB_generic_iter return $rec; } } + // $Log: not supported by cvs2svn $ +// Revision 1.64 2004/11/07 16:02:52 rurban +// new sql access log (for spam prevention), and restructured access log class +// dbh->quote (generic) +// pear_db: mysql specific parts seperated (using replace) +// // Revision 1.63 2004/11/01 10:43:58 rurban // seperate PassUser methods into seperate dir (memory usage) // fix WikiUser (old) overlarge data session diff --git a/lib/WikiDB/backend/PearDB_mysql.php b/lib/WikiDB/backend/PearDB_mysql.php index 96d5bf64a..e9c18272a 100644 --- a/lib/WikiDB/backend/PearDB_mysql.php +++ b/lib/WikiDB/backend/PearDB_mysql.php @@ -1,8 +1,10 @@ _pagedb; $pages = array(); for ($page = $pagedb->firstkey(); $page!== false; $page = $pagedb->nextkey()) { @@ -222,7 +222,7 @@ extends WikiDB_backend continue; } - if (!$include_deleted) { + if (!$include_empty) { if (!($data = $pagedb->get($page))) continue; list($latestversion,$flags,) = explode(':', $data, 3); unset($data); diff --git a/lib/WikiDB/backend/file.php b/lib/WikiDB/backend/file.php index 2934f4337..3c70c15ad 100644 --- a/lib/WikiDB/backend/file.php +++ b/lib/WikiDB/backend/file.php @@ -1,5 +1,5 @@ _loadLatestVersions(); $a = array_keys($this->_latest_versions); @@ -724,6 +724,9 @@ class WikiDB_backend_file_iter extends WikiDB_backend_iterator } // $Log: not supported by cvs2svn $ +// Revision 1.17 2004/07/09 13:05:34 rurban +// just aesthetics +// // Revision 1.16 2004/07/09 12:47:45 rurban // dont cache _ cached_html and pagename in flatfile page iterators // diff --git a/lib/config.php b/lib/config.php index a2d3e772c..76e45603c 100644 --- a/lib/config.php +++ b/lib/config.php @@ -1,5 +1,5 @@ false if unable * to set the requested locale. * @see setlocale + * [56ms] */ function guessing_setlocale ($category, $locale) { if ($res = setlocale($category, $locale)) @@ -161,10 +163,10 @@ function guessing_setlocale ($category, $locale) { // and codeset is a character set or encoding identifier like // ISO-8859-1 or UTF-8. } - +// [99ms] function update_locale($loc) { //require_once(dirname(__FILE__)."/FileFinder.php"); - $newlocale = guessing_setlocale(LC_ALL, $loc); + $newlocale = guessing_setlocale(LC_ALL, $loc); // [56ms] if (!$newlocale) { //trigger_error(sprintf(_("Can't setlocale(LC_ALL,'%s')"), $loc), E_USER_NOTICE); // => LC_COLLATE=C;LC_CTYPE=German_Austria.1252;LC_MONETARY=C;LC_NUMERIC=C;LC_TIME=C @@ -191,6 +193,7 @@ function update_locale($loc) { global $locale; $locale = array(); // do reinit to purge PHP's static cache + // [43ms] if ( ($lcfile = FindLocalizedFile("LC_MESSAGES/phpwiki.php", 'missing_ok', 'reinit')) ) { include($lcfile); } @@ -407,6 +410,10 @@ function getUploadDataPath() { } // $Log: not supported by cvs2svn $ +// Revision 1.123 2004/11/05 21:03:27 rurban +// new DEBUG flag: _DEBUG_LOGIN (64) +// verbose login debug-msg (settings and reason for failure) +// // Revision 1.122 2004/10/14 17:49:58 rurban // fix warning in safe_wordwrap // diff --git a/lib/display.php b/lib/display.php index 0728cb5ca..52b1f14d9 100644 --- a/lib/display.php +++ b/lib/display.php @@ -1,6 +1,6 @@ getLinks(false); - + $links = $page->getPageLinks(); $keywords[] = SplitPagename($page->getName()); - - while ($link = $links->next()) + while ($link = $links->next()) { if (preg_match("/${KeywordLinkRegexp}/x", $link->getName(), $m)) $keywords[] = SplitPagename($m[0]); - + } $keywords[] = WIKI_NAME; - return join(', ', $keywords); } @@ -218,6 +215,12 @@ function displayPage(&$request, $template=false) { } // $Log: not supported by cvs2svn $ +// Revision 1.57 2004/11/01 10:43:57 rurban +// seperate PassUser methods into seperate dir (memory usage) +// fix WikiUser (old) overlarge data session +// remove wikidb arg from various page class methods, use global ->_dbi instead +// ... +// // Revision 1.56 2004/10/14 13:44:14 rurban // fix lib/display.php:159: Warning[2]: Argument to array_reverse() should be an array // diff --git a/lib/main.php b/lib/main.php index 38b84a2a8..15ec5fea2 100644 --- a/lib/main.php +++ b/lib/main.php @@ -1,5 +1,5 @@ _dbi = WikiDB::open($GLOBALS['DBParams']); + $this->_dbi = WikiDB::open($GLOBALS['DBParams']); // first mysql request costs [958ms]! [670ms] is mysql_connect() //if ((DEBUG & _DEBUG_TRACE) or (time() % 50 == 0)) // $this->_dbi->_backend->optimize(); if (in_array('File', $this->_dbi->getAuthParam('USER_AUTH_ORDER'))) { @@ -47,7 +47,7 @@ class WikiRequest extends Request { // Fixme: Does pear reset the error mask to 1? We have to find the culprit //$x = error_reporting(); $this->version = phpwiki_version(); - $this->Request(); + $this->Request(); // [90ms] // Normalize args... $this->setArg('pagename', $this->_deducePagename()); @@ -150,6 +150,7 @@ $this->version = phpwiki_version(); // This really maybe should be part of the constructor, but since it // may involve HTML/template output, the global $request really needs // to be initialized before we do this stuff. + // [50ms]: 36ms is wikidb_page::exists function updateAuthAndPrefs () { if (isset($this->_user) and (!isa($this->_user,WikiUserClassname()))) { @@ -208,7 +209,7 @@ $this->version = phpwiki_version(); return WikiGroup::getGroup(); } - function getPrefs () { + function & getPrefs () { return $this->_prefs; } @@ -218,7 +219,7 @@ $this->version = phpwiki_version(); return $this->_prefs->get($key); } } - function getDbh () { + function & getDbh () { return $this->_dbi; } @@ -335,25 +336,6 @@ $this->version = phpwiki_version(); $this->_prefs =& $this->_user->_prefs; } $this->_user->_group = $this->getGroup(); - // avoid recursive objects and session resource handles - // avoid overlarge session data (max 4000 byte!) - if (isset($user->_group)) { - unset($user->_group->_request); - unset($user->_group->_user); - } - if (ENABLE_USER_NEW) { - unset($user->_HomePagehandle); - unset($user->_auth_dbi); - } else { - unset($user->_dbi); - unset($user->_authdbi); - unset($user->_homepage); - unset($user->_request); - } - if (empty($user->page)) - $user->page = $this->getArg('pagename'); - if (empty($user->action)) - $user->action = $this->getArg('action'); $this->setSessionVar('wiki_user', $user); $this->_prefs->set('userid', $user->isSignedIn() ? $user->getId() : ''); @@ -614,7 +596,8 @@ TODO: check against these cases: SetupWiki($this); $this->finish(); // NORETURN } - + + // [574ms] mainly template:printexpansion: 393ms and template::expandsubtemplate [100+70+60ms] function handleAction () { $action = $this->getArg('action'); $method = "action_$action"; @@ -1141,6 +1124,11 @@ if (!defined('PHPWIKI_NOMAIN') or !PHPWIKI_NOMAIN) // $Log: not supported by cvs2svn $ +// Revision 1.188 2004/11/07 16:02:52 rurban +// new sql access log (for spam prevention), and restructured access log class +// dbh->quote (generic) +// pear_db: mysql specific parts seperated (using replace) +// // Revision 1.187 2004/11/05 22:08:52 rurban // Ok: Fix loading all required userclasses beforehand. This is much slower than before but safes a few bytes RAM // diff --git a/lib/plugin/WikiAdminRemove.php b/lib/plugin/WikiAdminRemove.php index 3dc8a3a32..818ea3963 100644 --- a/lib/plugin/WikiAdminRemove.php +++ b/lib/plugin/WikiAdminRemove.php @@ -1,5 +1,5 @@ getAllPages('include_deleted',$sortby,$limit); + $allPages = $dbi->getAllPages('include_empty',$sortby,$limit); while ($pagehandle = $allPages->next()) { $pagename = $pagehandle->getName(); $current = $pagehandle->getCurrentRevision(); @@ -237,6 +237,12 @@ class _PageList_Column_remove extends _PageList_Column { // $Log: not supported by cvs2svn $ +// Revision 1.28 2004/11/01 10:43:59 rurban +// seperate PassUser methods into seperate dir (memory usage) +// fix WikiUser (old) overlarge data session +// remove wikidb arg from various page class methods, use global ->_dbi instead +// ... +// // Revision 1.27 2004/06/16 10:38:59 rurban // Disallow refernces in calls if the declaration is a reference // ("allow_call_time_pass_reference clean"). -- 2.45.0