From: <var...@us...> - 2014-11-28 14:27:46
|
Revision: 9387 http://sourceforge.net/p/phpwiki/code/9387 Author: vargenau Date: 2014-11-28 14:27:41 +0000 (Fri, 28 Nov 2014) Log Message: ----------- global $request Modified Paths: -------------- trunk/lib/CachedMarkup.php trunk/lib/Captcha.php trunk/lib/DbSession/ADODB.php trunk/lib/DbSession/PDO.php trunk/lib/DbSession/SQL.php trunk/lib/DbSession/dba.php trunk/lib/DbaDatabase.php trunk/lib/EditToolbar.php trunk/lib/InlineParser.php trunk/lib/MailNotify.php trunk/lib/PageList.php trunk/lib/PagePerm.php trunk/lib/PageType.php trunk/lib/Request.php trunk/lib/WikiDB/backend/ADODB.php trunk/lib/WikiDB/backend/PDO.php trunk/lib/WikiDB/backend/dbaBase.php trunk/lib/WikiDB/backend/dumb/LinkSearchIter.php trunk/lib/WikiDB/backend.php trunk/lib/WikiDB.php trunk/lib/WikiGroup.php trunk/lib/WikiPlugin.php trunk/lib/WikiPluginCached.php trunk/lib/WikiTheme.php trunk/lib/WikiUser/AdoDb.php trunk/lib/WikiUser/Db.php trunk/lib/WikiUser/PdoDb.php trunk/lib/WikiUser/PearDb.php trunk/lib/WikiUser.php trunk/lib/WysiwygEdit/Wikiwyg.php trunk/lib/WysiwygEdit.php trunk/lib/diff.php trunk/lib/editpage.php trunk/lib/plugin/GraphViz.php trunk/lib/plugin/InterWikiSearch.php trunk/lib/plugin/JabberPresence.php trunk/lib/plugin/RecentChanges.php trunk/lib/plugin/SpellCheck.php trunk/lib/plugin/UpLoad.php trunk/lib/plugin/VisualWiki.php trunk/lib/plugin/WikiAdminSelect.php trunk/lib/plugin/WikiAdminSetAcl.php trunk/lib/plugin/WikiFormRich.php trunk/lib/plugin/WikiPoll.php trunk/lib/plugin/WikiTranslation.php trunk/lib/spam_babycart.php trunk/lib/stdlib.php trunk/lib/wikilens/PageListColumns.php trunk/lib/wikilens/RatingsDb.php Modified: trunk/lib/CachedMarkup.php =================================================================== --- trunk/lib/CachedMarkup.php 2014-11-28 09:51:10 UTC (rev 9386) +++ trunk/lib/CachedMarkup.php 2014-11-28 14:27:41 UTC (rev 9387) @@ -558,11 +558,16 @@ */ function getWikiPageLinks($basepage) { + /** + * @var WikiRequest $request + */ + global $request; + if ($basepage == '') return false; if (!isset($this->_page) and isset($this->_attribute)) { // An attribute: we store it in the basepage now, to fill the cache for page->save // TODO: side-effect free query - $page = $GLOBALS['request']->getPage($basepage); + $page = $request->getPage($basepage); $page->setAttribute($this->_relation, $this->_attribute); $this->_page = $basepage; return array(array('linkto' => '', 'relation' => $this->_relation)); @@ -750,11 +755,16 @@ function getWikiPageLinks($basepage) { + /** + * @var WikiRequest $request + */ + global $request; + if ($basepage == '') return false; /* ":DontStoreLink" */ if (substr($this->_link, 0, 1) == ':') return false; /* store only links to valid pagenames */ - $dbi = $GLOBALS['request']->getDbh(); + $dbi = $request->getDbh(); if ($link = $this->getPagename($basepage) and $dbi->isWikiPage($link)) { return array(array('linkto' => $link)); } else { @@ -845,8 +855,13 @@ function expand($basepage, &$markup) { + /** + * @var WikiRequest $request + */ + global $request; + $loader = $this->_getLoader(); - $xml = $loader->expandPI($this->_pi, $GLOBALS['request'], $markup, $basepage); + $xml = $loader->expandPI($this->_pi, $request, $markup, $basepage); return $xml; } Modified: trunk/lib/Captcha.php =================================================================== --- trunk/lib/Captcha.php 2014-11-28 09:51:10 UTC (rev 9386) +++ trunk/lib/Captcha.php 2014-11-28 14:27:41 UTC (rev 9387) @@ -30,18 +30,23 @@ public $length; public $failed_msg; /** - * @var WikiRequest + * @var WikiRequest $request */ public $request; function Captcha($meta = array(), $width = 250, $height = 80) { + /** + * @var WikiRequest $request + */ + global $request; + $this->meta =& $meta; $this->width = $width; $this->height = $height; $this->length = 8; $this->failed_msg = _("Typed in verification word mismatch ... are you a bot?"); - $this->request =& $GLOBALS['request']; + $this->request =& $request; } function captchaword() Modified: trunk/lib/DbSession/ADODB.php =================================================================== --- trunk/lib/DbSession/ADODB.php 2014-11-28 09:51:10 UTC (rev 9386) +++ trunk/lib/DbSession/ADODB.php 2014-11-28 14:27:41 UTC (rev 9387) @@ -150,12 +150,17 @@ */ public function write($id, $sess_data) { + /** + * @var WikiRequest $request + */ + global $request; + if (defined("WIKI_XMLRPC") or defined("WIKI_SOAP")) return false; $dbh = $this->_connect(); $table = $this->_table; $qid = $dbh->qstr($id); - $qip = $dbh->qstr($GLOBALS['request']->get('REMOTE_ADDR')); + $qip = $dbh->qstr($request->get('REMOTE_ADDR')); $time = $dbh->qstr(time()); // postgres can't handle binary data in a TEXT field. Modified: trunk/lib/DbSession/PDO.php =================================================================== --- trunk/lib/DbSession/PDO.php 2014-11-28 09:51:10 UTC (rev 9386) +++ trunk/lib/DbSession/PDO.php 2014-11-28 14:27:41 UTC (rev 9387) @@ -133,6 +133,11 @@ */ public function write($id, $sess_data) { + /** + * @var WikiRequest $request + */ + global $request; + if (defined("WIKI_XMLRPC") or defined("WIKI_SOAP")) return false; $dbh = $this->_connect(); @@ -156,7 +161,7 @@ $sth->bindParam(1, $id, PDO::PARAM_STR, 32); $sth->bindParam(2, $sess_data, PDO::PARAM_LOB); $sth->bindParam(3, $time, PDO::PARAM_INT); - $sth->bindParam(4, $GLOBALS['request']->get('REMOTE_ADDR'), PDO::PARAM_STR, 15); + $sth->bindParam(4, $request->get('REMOTE_ADDR'), PDO::PARAM_STR, 15); if ($result = $sth->execute()) { $this->_backend->commit(); } else { @@ -168,7 +173,7 @@ . " WHERE sess_id=?"); $sth->bindParam(1, $sess_data, PDO::PARAM_LOB); $sth->bindParam(2, $time, PDO::PARAM_INT); - $sth->bindParam(3, $GLOBALS['request']->get('REMOTE_ADDR'), PDO::PARAM_STR, 15); + $sth->bindParam(3, $request->get('REMOTE_ADDR'), PDO::PARAM_STR, 15); $sth->bindParam(4, $id, PDO::PARAM_STR, 32); $result = $sth->execute(); // implicit affected rows if ($result === false or $result < 1) { // false or int > 0 @@ -178,7 +183,7 @@ $sth->bindParam(1, $id, PDO::PARAM_STR, 32); $sth->bindParam(2, $sess_data, PDO::PARAM_LOB); $sth->bindParam(3, $time, PDO::PARAM_INT); - $sth->bindParam(4, $GLOBALS['request']->get('REMOTE_ADDR'), PDO::PARAM_STR, 15); + $sth->bindParam(4, $request->get('REMOTE_ADDR'), PDO::PARAM_STR, 15); $result = $sth->execute(); } } Modified: trunk/lib/DbSession/SQL.php =================================================================== --- trunk/lib/DbSession/SQL.php 2014-11-28 09:51:10 UTC (rev 9386) +++ trunk/lib/DbSession/SQL.php 2014-11-28 14:27:41 UTC (rev 9387) @@ -137,13 +137,18 @@ */ public function write($id, $sess_data) { + /** + * @var WikiRequest $request + */ + global $request; + if (defined("WIKI_XMLRPC") or defined("WIKI_SOAP")) return false; $dbh = $this->_connect(); //$dbh->unlock(false,1); $table = $this->_table; $qid = $dbh->quote($id); - $qip = $dbh->quote($GLOBALS['request']->get('REMOTE_ADDR')); + $qip = $dbh->quote($request->get('REMOTE_ADDR')); $time = $dbh->quote(time()); if (DEBUG and $sess_data == 'wiki_user|N;') { trigger_error("delete empty session $qid", E_USER_WARNING); Modified: trunk/lib/DbSession/dba.php =================================================================== --- trunk/lib/DbSession/dba.php 2014-11-28 09:51:10 UTC (rev 9386) +++ trunk/lib/DbSession/dba.php 2014-11-28 14:27:41 UTC (rev 9387) @@ -93,11 +93,16 @@ function write($id, $sess_data) { + /** + * @var WikiRequest $request + */ + global $request; + if (defined("WIKI_XMLRPC") or defined("WIKI_SOAP")) return false; $dbh = $this->_connect(); $time = time(); - $ip = $GLOBALS['request']->get('REMOTE_ADDR'); + $ip = $request->get('REMOTE_ADDR'); if (strlen($sess_data) > 4000) { trigger_error("Overlarge session data!", E_USER_WARNING); $sess_data = ''; Modified: trunk/lib/DbaDatabase.php =================================================================== --- trunk/lib/DbaDatabase.php 2014-11-28 09:51:10 UTC (rev 9386) +++ trunk/lib/DbaDatabase.php 2014-11-28 14:27:41 UTC (rev 9387) @@ -13,7 +13,7 @@ public $_handler; public $_timeout; /** - * @var resource + * @var resource $_dbh */ public $_dbh; public $readonly; @@ -48,6 +48,11 @@ function open($mode = 'w') { + /** + * @var WikiRequest $request + */ + global $request; + if ($this->_dbh) return true; // already open. @@ -85,7 +90,7 @@ // try to continue with read-only if (!defined("READONLY")) define("READONLY", true); - $GLOBALS['request']->_dbi->readonly = true; + $request->_dbi->readonly = true; $this->readonly = true; $mode = "r"; } @@ -108,7 +113,7 @@ // try to continue with read-only if (!defined("READONLY")) define("READONLY", true); - $GLOBALS['request']->_dbi->readonly = true; + $request->_dbi->readonly = true; $this->readonly = true; if (!file_exists($this->_file)) { $ErrorManager->handleError($error); Modified: trunk/lib/EditToolbar.php =================================================================== --- trunk/lib/EditToolbar.php 2014-11-28 09:51:10 UTC (rev 9386) +++ trunk/lib/EditToolbar.php 2014-11-28 14:27:41 UTC (rev 9387) @@ -35,6 +35,10 @@ function __construct() { global $WikiTheme; + /** + * @var WikiRequest $request + */ + global $request; $this->tokens = array(); @@ -83,7 +87,7 @@ require_once 'lib/WikiPluginCached.php'; $cache = WikiPluginCached::newCache(); - $dbi = $GLOBALS['request']->getDbh(); + $dbi = $request->getDbh(); // regenerate if number of pages changes (categories, pages, templates, images uploaded) $key = $dbi->numPages(); $key .= '+categories+plugin' . (isBrowserSafari() ? '+safari' : ''); @@ -302,10 +306,14 @@ //result is cached private function categoriesPulldown() { + /** + * @var WikiRequest $request + */ + global $request; global $WikiTheme; require_once 'lib/TextSearchQuery.php'; - $dbi =& $GLOBALS['request']->_dbi; + $dbi =& $request->_dbi; // KEYWORDS formerly known as $KeywordLinkRegexp $pages = $dbi->titleSearch(new TextSearchQuery(KEYWORDS, true)); if ($pages) { @@ -391,8 +399,13 @@ // result is cached. Esp. the args are expensive private function pagesPulldown($query, $case_exact = false, $regex = 'auto') { + /** + * @var WikiRequest $request + */ + global $request; + require_once 'lib/TextSearchQuery.php'; - $dbi =& $GLOBALS['request']->_dbi; + $dbi =& $request->_dbi; $page_iter = $dbi->titleSearch(new TextSearchQuery($query, $case_exact, $regex)); if ($page_iter->count() > 0) { global $WikiTheme; Modified: trunk/lib/InlineParser.php =================================================================== --- trunk/lib/InlineParser.php 2014-11-28 09:51:10 UTC (rev 9386) +++ trunk/lib/InlineParser.php 2014-11-28 14:27:41 UTC (rev 9387) @@ -475,7 +475,12 @@ { function __construct() { - $this->suggestions = $GLOBALS['request']->getArg('suggestions'); + /** + * @var WikiRequest $request + */ + global $request; + + $this->suggestions = $request->getArg('suggestions'); } function getMatchRegexp() @@ -498,7 +503,12 @@ { function __construct() { - $result = $GLOBALS['request']->_searchhighlight; + /** + * @var WikiRequest $request + */ + global $request; + + $result = $request->_searchhighlight; require_once 'lib/TextSearchQuery.php'; $query = new TextSearchQuery($result['query']); $this->hilight_re = $query->getHighlightRegexp(); @@ -1360,8 +1370,13 @@ function TransformInline($text, $basepage = false) { + /** + * @var WikiRequest $request + */ + global $request; + static $trfm; - $action = $GLOBALS['request']->getArg('action'); + $action = $request->getArg('action'); if (empty($trfm) or $action == 'SpellCheck') { $trfm = new InlineTransformer; } Modified: trunk/lib/MailNotify.php =================================================================== --- trunk/lib/MailNotify.php 2014-11-28 09:51:10 UTC (rev 9386) +++ trunk/lib/MailNotify.php 2014-11-28 14:27:41 UTC (rev 9387) @@ -323,7 +323,12 @@ */ function onChangePage(&$wikidb, &$wikitext, $version, &$meta) { - if (!is_a($GLOBALS['request'], 'MockRequest')) { + /** + * @var WikiRequest $request + */ + global $request; + + if (!is_a($request, 'MockRequest')) { $notify = $wikidb->get('notify'); /* Generate notification emails? */ if (!empty($notify) and is_array($notify)) { @@ -340,9 +345,14 @@ function onDeletePage(&$wikidb, $pagename) { + /** + * @var WikiRequest $request + */ + global $request; + $result = true; /* Generate notification emails? */ - if (!$wikidb->isWikiPage($pagename) and !is_a($GLOBALS['request'], 'MockRequest')) { + if (!$wikidb->isWikiPage($pagename) and !is_a($request, 'MockRequest')) { $notify = $wikidb->get('notify'); if (!empty($notify) and is_array($notify)) { //TODO: deferr it (quite a massive load if you remove some pages). @@ -358,7 +368,12 @@ function onRenamePage(&$wikidb, $oldpage, $new_pagename) { - if (!is_a($GLOBALS['request'], 'MockRequest')) { + /** + * @var WikiRequest $request + */ + global $request; + + if (!is_a($request, 'MockRequest')) { $notify = $wikidb->get('notify'); if (!empty($notify) and is_array($notify)) { $this->getPageChangeEmails($notify); Modified: trunk/lib/PageList.php =================================================================== --- trunk/lib/PageList.php 2014-11-28 09:51:10 UTC (rev 9386) +++ trunk/lib/PageList.php 2014-11-28 14:27:41 UTC (rev 9387) @@ -51,6 +51,7 @@ class _PageList_Column_base { public $_tdattr = array(); + public $_field; function __construct($default_heading, $align = false) { @@ -471,8 +472,13 @@ { function __construct($field, $default_heading, $align = false) { + /** + * @var WikiRequest $request + */ + global $request; + parent::__construct($field, $default_heading, $align); - $this->dbi =& $GLOBALS['request']->getDbh(); + $this->dbi =& $request->getDbh(); } function _getValue($page_handle, &$revision_handle) @@ -607,14 +613,19 @@ function __construct($columns = array(), $exclude = array(), $options = array()) { + /** + * @var WikiRequest $request + */ + global $request; + // unique id per pagelist on each page. - if (!isset($GLOBALS['request']->_pagelist)) - $GLOBALS['request']->_pagelist = 0; + if (!isset($request->_pagelist)) + $request->_pagelist = 0; else - $GLOBALS['request']->_pagelist++; - $this->id = $GLOBALS['request']->_pagelist; - if ($GLOBALS['request']->getArg('count')) - $options['count'] = $GLOBALS['request']->getArg('count'); + $request->_pagelist++; + $this->id = $request->_pagelist; + if ($request->getArg('count')) + $options['count'] = $request->getArg('count'); if ($options) $this->_options = $options; @@ -849,9 +860,14 @@ function _getPageFromHandle($page_handle) { + /** + * @var WikiRequest $request + */ + global $request; + if (is_string($page_handle)) { if (empty($page_handle)) return $page_handle; - $page_handle = $GLOBALS['request']->_dbi->getPage($page_handle); + $page_handle = $request->_dbi->getPage($page_handle); } return $page_handle; } @@ -1116,6 +1132,11 @@ static function explodePageList($input, $include_empty = false, $sortby = '', $limit = '', $exclude = '') { + /** + * @var WikiRequest $request + */ + global $request; + if (empty($input)) { return array(); } @@ -1127,7 +1148,7 @@ include_once 'lib/TextSearchQuery.php'; $search = new TextSearchQuery(str_replace(",", " or ", $input), true, (substr($input, 0, 1) == "^") ? 'posix' : 'glob'); - $dbi = $GLOBALS['request']->getDbh(); + $dbi = $request->getDbh(); $iter = $dbi->titleSearch($search, $sortby, $limit, $exclude); $pages = array(); while ($pagehandle = $iter->next()) { @@ -1144,11 +1165,16 @@ static function allPagesByAuthor($wildcard, $include_empty = false, $sortby = '', $limit = '', $exclude = '') { - $dbi = $GLOBALS['request']->getDbh(); + /** + * @var WikiRequest $request + */ + global $request; + + $dbi = $request->getDbh(); $allPagehandles = $dbi->getAllPages($include_empty, $sortby, $limit, $exclude); $allPages = array(); if ($wildcard === '[]') { - $wildcard = $GLOBALS['request']->_user->getAuthenticatedId(); + $wildcard = $request->_user->getAuthenticatedId(); if (!$wildcard) return $allPages; } $do_glob = preg_match('/[\?\*]/', $wildcard); @@ -1171,11 +1197,16 @@ static function allPagesByOwner($wildcard, $include_empty = false, $sortby = '', $limit = '', $exclude = '') { - $dbi = $GLOBALS['request']->getDbh(); + /** + * @var WikiRequest $request + */ + global $request; + + $dbi = $request->getDbh(); $allPagehandles = $dbi->getAllPages($include_empty, $sortby, $limit, $exclude); $allPages = array(); if ($wildcard === '[]') { - $wildcard = $GLOBALS['request']->_user->getAuthenticatedId(); + $wildcard = $request->_user->getAuthenticatedId(); if (!$wildcard) return $allPages; } $do_glob = preg_match('/[\?\*]/', $wildcard); @@ -1197,11 +1228,16 @@ static function allPagesByCreator($wildcard, $include_empty = false, $sortby = '', $limit = '', $exclude = '') { - $dbi = $GLOBALS['request']->getDbh(); + /** + * @var WikiRequest $request + */ + global $request; + + $dbi = $request->getDbh(); $allPagehandles = $dbi->getAllPages($include_empty, $sortby, $limit, $exclude); $allPages = array(); if ($wildcard === '[]') { - $wildcard = $GLOBALS['request']->_user->getAuthenticatedId(); + $wildcard = $request->_user->getAuthenticatedId(); if (!$wildcard) return $allPages; } $do_glob = preg_match('/[\?\*]/', $wildcard); @@ -1224,7 +1260,12 @@ static function allUserPages($include_empty = false, $sortby = '', $limit = '', $exclude = '') { - $dbi = $GLOBALS['request']->getDbh(); + /** + * @var WikiRequest $request + */ + global $request; + + $dbi = $request->getDbh(); $allPagehandles = $dbi->getAllPages($include_empty, $sortby, $limit, $exclude); $allPages = array(); while ($pagehandle = $allPagehandles->next()) { @@ -1372,7 +1413,7 @@ if (!(defined('FUSIONFORGE') and FUSIONFORGE)) { // FIXME: anon users might rate and see ratings also. // Defer this logic to the plugin. - if ($column == 'rating' and !$GLOBALS['request']->_user->isSignedIn()) { + if ($column == 'rating' and !$request->_user->isSignedIn()) { return false; } } @@ -1491,6 +1532,11 @@ function pagingTokens($numrows = false, $ncolumns = false, $limit = false) { + /** + * @var WikiRequest $request + */ + global $request; + if ($numrows === false) $numrows = $this->getTotal(); if ($limit === false) @@ -1505,7 +1551,6 @@ ) return false; - $request = &$GLOBALS['request']; $pagename = $request->getArg('pagename'); $defargs = array_merge(array('id' => $this->id), $request->args); if (USE_PATH_INFO) unset($defargs['pagename']); Modified: trunk/lib/PagePerm.php =================================================================== --- trunk/lib/PagePerm.php 2014-11-28 09:51:10 UTC (rev 9386) +++ trunk/lib/PagePerm.php 2014-11-28 14:27:41 UTC (rev 9387) @@ -359,7 +359,12 @@ function PagePermission($hash = array()) { - $this->_group = &$GLOBALS['request']->getGroup(); + /** + * @var WikiRequest $request + */ + global $request; + + $this->_group = &$request->getGroup(); if (is_array($hash) and !empty($hash)) { $accessTypes = $this->accessTypes(); foreach ($hash as $access => $requires) { @@ -597,8 +602,13 @@ function asEditableTable($type) { global $WikiTheme; + /** + * @var WikiRequest $request + */ + global $request; + if (!isset($this->_group)) { - $this->_group =& $GLOBALS['request']->getGroup(); + $this->_group =& $request->getGroup(); } $table = HTML::table(); $table->pushContent(HTML::tr( Modified: trunk/lib/PageType.php =================================================================== --- trunk/lib/PageType.php 2014-11-28 09:51:10 UTC (rev 9386) +++ trunk/lib/PageType.php 2014-11-28 14:27:41 UTC (rev 9387) @@ -153,8 +153,13 @@ { function __construct($pagetext = false) { + /** + * @var WikiRequest $request + */ + global $request; + if (!$pagetext) { - $dbi = $GLOBALS['request']->getDbh(); + $dbi = $request->getDbh(); $page = $dbi->getPage(__("InterWikiMap")); if ($page->get('locked')) { $current = $page->getCurrentRevision(); @@ -258,6 +263,11 @@ private function _parseMap($text) { + /** + * @var WikiRequest $request + */ + global $request; + if (!preg_match_all("/^\s*(\S+)\s+(.+)$/m", $text, $matches, PREG_SET_ORDER) ) @@ -284,7 +294,7 @@ // Talk:UserName => UserName/Discussion // Talk:PageName => PageName/Discussion as default, which might be overridden if (empty($map["Talk"])) { - $pagename = $GLOBALS['request']->getArg('pagename'); + $pagename = $request->getArg('pagename'); // against PageName/Discussion/Discussion if (string_ends_with($pagename, '/' . _("Discussion"))) $map["Talk"] = "%s"; @@ -301,7 +311,7 @@ if (strstr($map[$special], '%u')) $map[$special] = str_replace($map[$special], '%u', - $GLOBALS['request']->_user->_userid); + $request->_user->_userid); if (strstr($map[$special], '%b')) $map[$special] = str_replace($map[$special], '%b', Modified: trunk/lib/Request.php =================================================================== --- trunk/lib/Request.php 2014-11-28 09:51:10 UTC (rev 9386) +++ trunk/lib/Request.php 2014-11-28 14:27:41 UTC (rev 9387) @@ -32,6 +32,8 @@ function __construct() { + global $request; + $this->_fix_multipart_form_data(); switch ($this->get('REQUEST_METHOD')) { @@ -54,7 +56,7 @@ $this->_accesslog = new Request_AccessLog(ACCESS_LOG, ACCESS_LOG_SQL); } - $GLOBALS['request'] = $this; + $request = $this; } function get($key) Modified: trunk/lib/WikiDB/backend/ADODB.php =================================================================== --- trunk/lib/WikiDB/backend/ADODB.php 2014-11-28 09:51:10 UTC (rev 9386) +++ trunk/lib/WikiDB/backend/ADODB.php 2014-11-28 14:27:41 UTC (rev 9387) @@ -367,9 +367,9 @@ /** * Get version data. * - * @param $version int Which version to get. + * @param int $version Which version to get. * - * @return hash The version data, or false if specified version does not + * @return array hash The version data, or false if specified version does not * exist. */ function get_versiondata($pagename, $version, $want_content = false) @@ -513,6 +513,11 @@ */ function delete_page($pagename) { + /** + * @var WikiRequest $request + */ + global $request; + $dbh = &$this->_dbh; extract($this->_table_names); @@ -523,7 +528,7 @@ return false; } $mtime = time(); - $user =& $GLOBALS['request']->_user; + $user =& $request->_user; $meta = array('author' => $user->getId(), 'author_id' => $user->getAuthenticatedId(), 'mtime' => $mtime); Modified: trunk/lib/WikiDB/backend/PDO.php =================================================================== --- trunk/lib/WikiDB/backend/PDO.php 2014-11-28 09:51:10 UTC (rev 9386) +++ trunk/lib/WikiDB/backend/PDO.php 2014-11-28 14:27:41 UTC (rev 9387) @@ -32,6 +32,11 @@ function __construct($dbparams) { + /** + * @var WikiRequest $request + */ + global $request; + $this->_dbparams = $dbparams; if (strstr($dbparams['dsn'], "://")) { // pear DB syntax $parsed = parseDSN($dbparams['dsn']); @@ -616,6 +621,11 @@ */ function delete_page($pagename) { + /** + * @var WikiRequest $request + */ + global $request; + $dbh = &$this->_dbh; extract($this->_table_names); @@ -626,7 +636,7 @@ return false; } $mtime = time(); - $user =& $GLOBALS['request']->_user; + $user =& $request->_user; $meta = array('author' => $user->getId(), 'author_id' => $user->getAuthenticatedId(), 'mtime' => $mtime); Modified: trunk/lib/WikiDB/backend/dbaBase.php =================================================================== --- trunk/lib/WikiDB/backend/dbaBase.php 2014-11-28 09:51:10 UTC (rev 9386) +++ trunk/lib/WikiDB/backend/dbaBase.php 2014-11-28 14:27:41 UTC (rev 9387) @@ -193,6 +193,11 @@ */ function delete_page($pagename) { + /** + * @var WikiRequest $request + */ + global $request; + $version = $this->get_latest_version($pagename); $data = $this->_versiondb->get((int)$version . ":$pagename"); // returns serialized string @@ -206,9 +211,9 @@ assert(is_array($data) and !empty($data)); // mtime $data['%content'] = ''; $data['mtime'] = time(); - $data['summary'] = "removed by " . $GLOBALS["request"]->_deduceUsername(); + $data['summary'] = "removed by " . $request->_deduceUsername(); $this->set_versiondata($pagename, $version + 1, $data); - $this->set_links($pagename, false); + $this->set_links($pagename, array()); } /** @@ -225,11 +230,16 @@ } $pagedb->set($pagename, false); - $this->set_links($pagename, false); + $this->set_links($pagename, array()); } function rename_page($pagename, $to) { + /** + * @var WikiRequest $request + */ + global $request; + $result = $this->_pagedb->get($pagename); if ($result) { list($version, $flags, $data) = explode(':', $result, 3); @@ -247,7 +257,7 @@ $pvdata = $this->get_versiondata($pagename, $version, true); $data['mtime'] = time(); $data['summary'] = "renamed from " . $pagename - . " by " . $GLOBALS["request"]->_deduceUsername(); + . " by " . $request->_deduceUsername(); $this->set_versiondata($to, $version, $pvdata); // update links and backlinks @@ -455,6 +465,11 @@ function link_search($pages, $query, $linktype, $relation = false, $options = array()) { + /** + * @var WikiRequest $request + */ + global $request; + $linkdb = &$this->_linkdb; $links = array(); $reverse = false; @@ -479,7 +494,7 @@ $pagename = substr($link, 1); if (!$pages->match($pagename)) continue; if ($linktype == 'attribute') { - $page = $GLOBALS['request']->_dbi->getPage($pagename); + $page = $request->_dbi->getPage($pagename); $attribs = $page->get('attributes'); if ($attribs) { /* Optimization on expressive searches: @@ -557,6 +572,11 @@ */ function relation_search($pages, $query, $options = array()) { + /** + * @var WikiRequest $request + */ + global $request; + $linkdb = &$this->_linkdb; $links = array(); // We need to detect which attributes and relation names we should look for. NYI @@ -576,7 +596,7 @@ if (!$pages->match($pagename)) continue; $pagelinks = array(); if ($want_attributes) { - $page = $GLOBALS['request']->_dbi->getPage($pagename); + $page = $request->_dbi->getPage($pagename); $attribs = $page->get('attributes'); $pagelinks = $attribs; } @@ -658,7 +678,7 @@ extends WikiDB_backend_iterator { // fixed for linkrelations - function __construct(&$backend, &$pages, $options = false) + function __construct(&$backend, &$pages, $options = array()) { $this->_backend = $backend; $this->_options = $options; Modified: trunk/lib/WikiDB/backend/dumb/LinkSearchIter.php =================================================================== --- trunk/lib/WikiDB/backend/dumb/LinkSearchIter.php 2014-11-28 09:51:10 UTC (rev 9386) +++ trunk/lib/WikiDB/backend/dumb/LinkSearchIter.php 2014-11-28 14:27:41 UTC (rev 9387) @@ -41,6 +41,11 @@ function __construct(&$backend, &$pageiter, $search, $linktype, $relation = false, $options = array()) { + /** + * @var WikiRequest $request + */ + global $request; + $this->_backend = &$backend; $this->_pages = $pageiter; $this->search = $search; // search the linkvalue. it should be the value or pagename @@ -52,7 +57,7 @@ $this->limit = isset($options['limit']) ? $options['limit'] : ''; $this->exclude = isset($options['exclude']) ? $options['exclude'] : ''; $this->_field = 'pagename'; // the name of the linkvalue field to apply the search - $this->_dbi =& $GLOBALS['request']->_dbi; + $this->_dbi =& $request->_dbi; if ($linktype == 'relation') { $this->_want_relations = true; $this->_field = 'linkrelation'; Modified: trunk/lib/WikiDB/backend.php =================================================================== --- trunk/lib/WikiDB/backend.php 2014-11-28 09:51:10 UTC (rev 9386) +++ trunk/lib/WikiDB/backend.php 2014-11-28 14:27:41 UTC (rev 9387) @@ -580,7 +580,7 @@ * Duplicate the PageList function here to avoid loading the whole * PageList.php, and it forces the backend specific sortable_columns() */ - function sortby($column, $action, $sortable_columns = false) + function sortby($column, $action, $sortable_columns = array()) { /** * @var WikiRequest $request Modified: trunk/lib/WikiDB.php =================================================================== --- trunk/lib/WikiDB.php 2014-11-28 09:51:10 UTC (rev 9386) +++ trunk/lib/WikiDB.php 2014-11-28 14:27:41 UTC (rev 9387) @@ -110,12 +110,17 @@ */ function __construct(&$backend, $dbparams) { + /** + * @var WikiRequest $request + */ + global $request; + $this->_backend =& $backend; // don't do the following with the auth_dsn! if (isset($dbparams['auth_dsn'])) return; $this->_cache = new WikiDB_cache($backend); - if (!empty($GLOBALS['request'])) $GLOBALS['request']->_dbi = $this; + if (!empty($request)) $request->_dbi = $this; // If the database doesn't yet have a timestamp, initialize it now. if ($this->get('_timestamp') === false) @@ -506,6 +511,11 @@ */ public function renamePage($from, $to, $updateWikiLinks = false) { + /** + * @var WikiRequest $request + */ + global $request; + if (!empty($this->readonly)) { trigger_error("readonly database", E_USER_WARNING); return false; @@ -563,7 +573,7 @@ E_USER_WARNING); } /* Generate notification emails? */ - if ($result and ENABLE_MAILNOTIFY and !is_a($GLOBALS['request'], 'MockRequest')) { + if ($result and ENABLE_MAILNOTIFY and !is_a($request, 'MockRequest')) { $notify = $this->get('notify'); if (!empty($notify) and is_array($notify)) { include_once 'lib/MailNotify.php'; @@ -721,15 +731,25 @@ function getParam($param) { global $DBParams; - if (isset($DBParams[$param])) return $DBParams[$param]; - elseif ($param == 'prefix') return ''; else return false; + if (isset($DBParams[$param])) + return $DBParams[$param]; + elseif ($param == 'prefix') + return ''; + else + return false; } function getAuthParam($param) { global $DBAuthParams; - if (isset($DBAuthParams[$param])) return $DBAuthParams[$param]; - elseif ($param == 'USER_AUTH_ORDER') return $GLOBALS['USER_AUTH_ORDER']; elseif ($param == 'USER_AUTH_POLICY') return $GLOBALS['USER_AUTH_POLICY']; else return false; + if (isset($DBAuthParams[$param])) + return $DBAuthParams[$param]; + elseif ($param == 'USER_AUTH_ORDER') + return $GLOBALS['USER_AUTH_ORDER']; + elseif ($param == 'USER_AUTH_POLICY') + return $GLOBALS['USER_AUTH_POLICY']; + else + return false; } } @@ -1003,6 +1023,11 @@ */ function save($wikitext, $version, $meta, $formatted = null) { + /** + * @var WikiRequest $request + */ + global $request; + if ($this->_wikidb->readonly) { trigger_error("readonly database", E_USER_WARNING); return false; @@ -1047,7 +1072,7 @@ $notify = $this->_wikidb->get('notify'); if (!empty($notify) and is_array($notify) - and !is_a($GLOBALS['request'], 'MockRequest') + and !is_a($request, 'MockRequest') ) { include_once 'lib/MailNotify.php'; $MailNotify = new MailNotify($newrevision->getName()); @@ -1058,13 +1083,13 @@ // more pagechange callbacks: (in a hackish manner for now) if (ENABLE_RECENTCHANGESBOX and empty($meta['is_minor_edit']) - and !in_array($GLOBALS['request']->getArg('action'), + and !in_array($request->getArg('action'), array('loadfile', 'upgrade')) ) { require_once 'lib/WikiPlugin.php'; $w = new WikiPluginLoader(); $p = $w->getPlugin("RecentChangesCached", false); - $p->box_update(false, $GLOBALS['request'], $this->_pagename); + $p->box_update(false, $request, $this->_pagename); } return $newrevision; } @@ -1674,6 +1699,11 @@ */ public function getPackedContent() { + /** + * @var WikiRequest $request + */ + global $request; + $data = &$this->_data; if (empty($data['%content']) @@ -1686,7 +1716,7 @@ // Lib from http://www.aasted.org/quote/ if (defined('FORTUNE_DIR') and is_dir(FORTUNE_DIR) - and in_array($GLOBALS['request']->getArg('action'), + and in_array($request->getArg('action'), array('create', 'edit')) ) { include_once 'lib/fortune.php'; @@ -2155,6 +2185,11 @@ function WikiDB_cache(&$backend) { + /** + * @var WikiRequest $request + */ + global $request; + $this->_backend = &$backend; $this->_pagedata_cache = array(); @@ -2163,8 +2198,8 @@ $this->_glv_cache = array(); $this->_id_cache = array(); // formerly ->_dbi->_iwpcache (nonempty pages => id) - if (isset($GLOBALS['request']->_dbi)) - $this->readonly = $GLOBALS['request']->_dbi->readonly; + if (isset($request->_dbi)) + $this->readonly = $request->_dbi->readonly; } function close() Modified: trunk/lib/WikiGroup.php =================================================================== --- trunk/lib/WikiGroup.php 2014-11-28 09:51:10 UTC (rev 9386) +++ trunk/lib/WikiGroup.php 2014-11-28 14:27:41 UTC (rev 9387) @@ -77,7 +77,6 @@ function WikiGroup($not_current = false) { $this->not_current = $not_current; - //$this->request =& $GLOBALS['request']; } /** @@ -481,9 +480,7 @@ */ function __construct() { - //$this->request = &$GLOBALS['request']; $this->username = $this->_getUserName(); - //$this->username = null; $this->membership = array(); } @@ -581,10 +578,15 @@ */ function getMembersOf($group) { + /** + * @var WikiRequest $request + */ + global $request; + if ($this->specialGroup($group)) return $this->getSpecialMembersOf($group); - $group_page = $GLOBALS['request']->getPage($group); + $group_page = $request->getPage($group); $group_revision = $group_page->getCurrentRevision(); if ($group_revision->hasDefaultContents()) { trigger_error(sprintf(_("Group %s does not exist"), $group), E_USER_WARNING); @@ -842,9 +844,7 @@ { function __construct() { - //$this->request = &$GLOBALS['request']; $this->username = $this->_getUserName(); - //$this->username = null; $this->membership = array(); if (!defined('AUTH_GROUP_FILE')) { @@ -952,7 +952,6 @@ { function __construct() { - //$this->request = &$GLOBALS['request']; $this->username = $this->_getUserName(); $this->membership = array(); Modified: trunk/lib/WikiPlugin.php =================================================================== --- trunk/lib/WikiPlugin.php 2014-11-28 09:51:10 UTC (rev 9386) +++ trunk/lib/WikiPlugin.php 2014-11-28 14:27:41 UTC (rev 9387) @@ -171,6 +171,11 @@ function parseArgStr($argstr) { + /** + * @var WikiRequest $request + */ + global $request; + $args = array(); $defaults = array(); if (empty($argstr)) @@ -195,7 +200,7 @@ $markup = null; $basepage = null; $plugin_val = preg_replace(array("/^<!/", "/!>$/"), array("<?", "?>"), $plugin_val); - $val = $loader->expandPI($plugin_val, $GLOBALS['request'], $markup, $basepage); + $val = $loader->expandPI($plugin_val, $request, $markup, $basepage); if ($op == '=') { $args[$arg] = $val; // comma delimited pagenames or array()? } else { Modified: trunk/lib/WikiPluginCached.php =================================================================== --- trunk/lib/WikiPluginCached.php 2014-11-28 09:51:10 UTC (rev 9386) +++ trunk/lib/WikiPluginCached.php 2014-11-28 14:27:41 UTC (rev 9387) @@ -1075,13 +1075,18 @@ */ function execute($cmd, $until = '') { + /** + * @var WikiRequest $request + */ + global $request; + // cmd must redirect stderr to stdout though! $errstr = exec($cmd); //, $outarr, $returnval); // normally 127 //$errstr = join('',$outarr); $ok = empty($errstr); if (!$ok) { trigger_error("\n" . $cmd . " failed: $errstr", E_USER_WARNING); - } elseif ($GLOBALS['request']->getArg('debug')) + } elseif ($request->getArg('debug')) trigger_error("\n" . $cmd . ": success\n", E_USER_NOTICE); if (!isWindows()) { if ($until) { Modified: trunk/lib/WikiTheme.php =================================================================== --- trunk/lib/WikiTheme.php 2014-11-28 09:51:10 UTC (rev 9386) +++ trunk/lib/WikiTheme.php 2014-11-28 14:27:41 UTC (rev 9387) @@ -230,8 +230,8 @@ $this->addMoreHeaders(JavaScript('', array('src' => $this->_findData("jquery.tablesorter.min.js")))); } // by pixels - if ((is_object($GLOBALS['request']) // guard against unittests - and $GLOBALS['request']->getPref('doubleClickEdit')) + if ((is_object($request) // guard against unittests + and $request->getPref('doubleClickEdit')) or ENABLE_DOUBLECLICKEDIT ) $this->initDoubleClickEdit(); @@ -525,9 +525,14 @@ */ function getOwnerMessage($page) { + /** + * @var WikiRequest $request + */ + global $request; + if (!ENABLE_PAGEPERM or !class_exists("PagePermission")) return ''; - $dbi =& $GLOBALS['request']->_dbi; + $dbi =& $request->_dbi; $owner = $page->getOwner(); if ($owner) { /* @@ -548,9 +553,14 @@ Prefer author (name) over internal author_id (IP) */ function getAuthorMessage($revision) { + /** + * @var WikiRequest $request + */ + global $request; + if (!$revision) return ''; - $dbi =& $GLOBALS['request']->_dbi; + $dbi =& $request->_dbi; $author = $revision->get('author'); if (!$author) $author = $revision->get('author_id'); @@ -1262,10 +1272,14 @@ * TODO: first css, then js. Maybe separate it into addJSHeaders/addCSSHeaders * or use an optional type argument, and separate it within _MoreHeaders[] */ - //$GLOBALS['request']->_MoreHeaders = array(); function addMoreHeaders($element) { - $GLOBALS['request']->_MoreHeaders[] = $element; + /** + * @var WikiRequest $request + */ + global $request; + + $request->_MoreHeaders[] = $element; if (!empty($this->_headers_printed) and $this->_headers_printed) { trigger_error(_("Some action(page) wanted to add more headers, but they were already printed.") . "\n" . $element->asXML(), @@ -1310,7 +1324,6 @@ return $out; } - //$GLOBALS['request']->_MoreAttr = array(); // new arg: named elements to be able to remove them. such as DoubleClickEdit for htmldumps function addMoreAttr($tag, $name, $element) { @@ -1583,7 +1596,12 @@ function calendarInit($force = false) { - $dbi = $GLOBALS['request']->getDbh(); + /** + * @var WikiRequest $request + */ + global $request; + + $dbi = $request->getDbh(); // display flat calender dhtml in the sidebar if ($force or $dbi->isWikiPage($this->calendarBase())) { $jslang = @$GLOBALS['LANG']; @@ -1747,7 +1765,7 @@ $this->setAttr('class', $class); // Google honors this if (in_array(strtolower($text), array('edit', 'create', 'diff', 'pdf')) - and !$GLOBALS['request']->_user->isAuthenticated() + and !$request->_user->isAuthenticated() ) $this->setAttr('rel', 'nofollow'); @@ -1870,8 +1888,13 @@ function format($args = array()) { + /** + * @var WikiRequest $request + */ + global $request; + return $this->_plugin->box($args ? array_merge($this->_args, $args) : $this->_args, - $GLOBALS['request'], + $request, $this->_basepage); } } Modified: trunk/lib/WikiUser/AdoDb.php =================================================================== --- trunk/lib/WikiUser/AdoDb.php 2014-11-28 09:51:10 UTC (rev 9386) +++ trunk/lib/WikiUser/AdoDb.php 2014-11-28 14:27:41 UTC (rev 9387) @@ -40,6 +40,11 @@ function _AdoDbPassUser($UserName = '', $prefs = false) { + /** + * @var WikiRequest $request + */ + global $request; + if (!$this->_prefs and is_a($this, "_AdoDbPassUser")) { if ($prefs) $this->_prefs = $prefs; if (!isset($this->_prefs->_method)) @@ -51,7 +56,7 @@ } $this->_userid = $UserName; $this->getAuthDbh(); - $this->_auth_crypt_method = $GLOBALS['request']->_dbi->getAuthParam('auth_crypt_method'); + $this->_auth_crypt_method = $request->_dbi->getAuthParam('auth_crypt_method'); // Don't prepare the configured auth statements anymore return $this; } @@ -135,6 +140,11 @@ function userExists() { + /** + * @var WikiRequest $request + */ + global $request; + $this->getAuthDbh(); $dbh = &$this->_auth_dbi; if (!$dbh) { // needed? @@ -143,7 +153,7 @@ if (!$this->isValidName()) { return $this->_tryNextUser(); } - $dbi =& $GLOBALS['request']->_dbi; + $dbi =& $request->_dbi; // Prepare the configured auth statements if ($dbi->getAuthParam('auth_check') and empty($this->_authselect)) { $this->_authselect = $this->prepare($dbi->getAuthParam('auth_check'), @@ -199,7 +209,11 @@ function checkPass($submitted_password) { - //global $DBAuthParams; + /** + * @var WikiRequest $request + */ + global $request; + $this->getAuthDbh(); if (!$this->_auth_dbi) { // needed? return $this->_tryNextPass($submitted_password); @@ -212,7 +226,7 @@ return WIKIAUTH_FORBIDDEN; } $dbh =& $this->_auth_dbi; - $dbi =& $GLOBALS['request']->_dbi; + $dbi =& $request->_dbi; if (empty($this->_authselect) and $dbi->getAuthParam('auth_check')) { $this->_authselect = $this->prepare($dbi->getAuthParam('auth_check'), array("password", "userid")); @@ -265,14 +279,24 @@ function mayChangePass() { - return $GLOBALS['request']->_dbi->getAuthParam('auth_update'); + /** + * @var WikiRequest $request + */ + global $request; + + return $request->_dbi->getAuthParam('auth_update'); } function storePass($submitted_password) { + /** + * @var WikiRequest $request + */ + global $request; + $this->getAuthDbh(); $dbh = &$this->_auth_dbi; - $dbi =& $GLOBALS['request']->_dbi; + $dbi =& $request->_dbi; if ($dbi->getAuthParam('auth_update') and empty($this->_authupdate)) { $this->_authupdate = $this->prepare($dbi->getAuthParam('auth_update'), array("password", "userid")); Modified: trunk/lib/WikiUser/Db.php =================================================================== --- trunk/lib/WikiUser/Db.php 2014-11-28 09:51:10 UTC (rev 9386) +++ trunk/lib/WikiUser/Db.php 2014-11-28 14:27:41 UTC (rev 9387) @@ -51,6 +51,11 @@ // sets the auth_dbi and pref methods, before this class is initialized. function _DbPassUser($UserName = '', $prefs = false) { + /** + * @var WikiRequest $request + */ + global $request; + if (!$this->_prefs) { if ($prefs) $this->_prefs = $prefs; } @@ -63,7 +68,7 @@ $this->_authmethod = 'Db'; //$this->getAuthDbh(); //$this->_auth_crypt_method = @$GLOBALS['DBAuthParams']['auth_crypt_method']; - $dbi =& $GLOBALS['request']->_dbi; + $dbi =& $request->_dbi; $dbtype = $dbi->getParam('dbtype'); if ($dbtype == 'ADODB') { include_once 'lib/WikiUser/AdoDb.php'; Modified: trunk/lib/WikiUser/PdoDb.php =================================================================== --- trunk/lib/WikiUser/PdoDb.php 2014-11-28 09:51:10 UTC (rev 9386) +++ trunk/lib/WikiUser/PdoDb.php 2014-11-28 14:27:41 UTC (rev 9387) @@ -37,6 +37,10 @@ function _PdoDbPassUser($UserName = '', $prefs = false) { + /** + * @var WikiRequest $request + */ + global $request; if (!$this->_prefs and is_a($this, "_PdoDbPassUser")) { if ($prefs) $this->_prefs = $prefs; @@ -50,7 +54,7 @@ $this->_userid = $UserName; // make use of session data. generally we only initialize this every time, // but do auth checks only once - $this->_auth_crypt_method = $GLOBALS['request']->_dbi->getAuthParam('auth_crypt_method'); + $this->_auth_crypt_method = $request->_dbi->getAuthParam('auth_crypt_method'); return $this; } @@ -114,6 +118,11 @@ function userExists() { + /** + * @var WikiRequest $request + */ + global $request; + $this->getAuthDbh(); $dbh = &$this->_auth_dbi; if (!$dbh) { // needed? @@ -123,7 +132,7 @@ trigger_error(_("Invalid username."), E_USER_WARNING); return $this->_tryNextUser(); } - $dbi =& $GLOBALS['request']->_dbi; + $dbi =& $request->_dbi; if ($dbi->getAuthParam('auth_check') and empty($this->_authselect)) { try { $this->_authselect = $dbh->prepare($dbi->getAuthParam('auth_check')); @@ -246,17 +255,27 @@ function mayChangePass() { - return $GLOBALS['request']->_dbi->getAuthParam('auth_update'); + /** + * @var WikiRequest $request + */ + global $request; + + return $request->_dbi->getAuthParam('auth_update'); } function storePass($submitted_password) { + /** + * @var WikiRequest $request + */ + global $request; + if (!$this->isValidName()) { return false; } $this->getAuthDbh(); $dbh = &$this->_auth_dbi; - $dbi =& $GLOBALS['request']->_dbi; + $dbi =& $request->_dbi; if ($dbi->getAuthParam('auth_update') and empty($this->_authupdate)) { try { $this->_authupdate = $dbh->prepare($dbi->getAuthParam('auth_update')); Modified: trunk/lib/WikiUser/PearDb.php =================================================================== --- trunk/lib/WikiUser/PearDb.php 2014-11-28 09:51:10 UTC (rev 9386) +++ trunk/lib/WikiUser/PearDb.php 2014-11-28 14:27:41 UTC (rev 9387) @@ -35,7 +35,11 @@ function _PearDbPassUser($UserName = '', $prefs = false) { - //global $DBAuthParams; + /** + * @var WikiRequest $request + */ + global $request; + if (!$this->_prefs and is_a($this, "_PearDbPassUser")) { if ($prefs) { $this->_prefs = $prefs; @@ -50,7 +54,7 @@ $this->_userid = $UserName; // make use of session data. generally we only initialize this every time, // but do auth checks only once - $this->_auth_crypt_method = $GLOBALS['request']->_dbi->getAuthParam('auth_crypt_method'); + $this->_auth_crypt_method = $request->_dbi->getAuthParam('auth_crypt_method'); return $this; } @@ -84,6 +88,11 @@ function setPreferences($prefs, $id_only = false) { + /** + * @var WikiRequest $request + */ + global $request; + // if the prefs are changed if ($count = _AnonUser::setPreferences($prefs, 1)) { //global $request; @@ -108,7 +117,7 @@ } else { // Otherwise, insert a record for them and set it to the defaults. // jo...@de... - $dbi = $GLOBALS['request']->getDbh(); + $dbi = $request->getDbh(); $this->_prefs->_insert = $this->prepare($dbi->getAuthParam('pref_insert'), array("pref_blob", "userid")); $dbh->simpleQuery(sprintf($this->_prefs->_insert, @@ -129,7 +138,11 @@ function userExists() { - //global $DBAuthParams; + /** + * @var WikiRequest $request + */ + global $request; + $this->getAuthDbh(); $dbh = &$this->_auth_dbi; if (!$dbh) { // needed? @@ -139,7 +152,7 @@ trigger_error(_("Invalid username."), E_USER_WARNING); return $this->_tryNextUser(); } - $dbi =& $GLOBALS['request']->_dbi; + $dbi =& $request->_dbi; // Prepare the configured auth statements if ($dbi->getAuthParam('auth_check') and empty($this->_authselect)) { $this->_authselect = $this->prepare($dbi->getAuthParam('auth_check'), @@ -229,17 +242,27 @@ function mayChangePass() { - return $GLOBALS['request']->_dbi->getAuthParam('auth_update'); + /** + * @var WikiRequest $request + */ + global $request; + + return $request->_dbi->getAuthParam('auth_update'); } function storePass($submitted_password) { + /** + * @var WikiRequest $request + */ + global $request; + if (!$this->isValidName()) { return false; } $this->getAuthDbh(); $dbh = &$this->_auth_dbi; - $dbi =& $GLOBALS['request']->_dbi; + $dbi =& $request->_dbi; if ($dbi->getAuthParam('auth_update') and empty($this->_authupdate)) { $this->_authupdate = $this->prepare($dbi->getAuthParam('auth_update'), array("password", "userid")); Modified: trunk/lib/WikiUser.php =================================================================== --- trunk/lib/WikiUser.php 2014-11-28 09:51:10 UTC (rev 9386) +++ trunk/lib/WikiUser.php 2014-11-28 14:27:41 UTC (rev 9387) @@ -185,13 +185,8 @@ return $GLOBALS['ForbiddenUser']; //FIXME: check admin membership later at checkPass. Now we cannot raise the level. - //$group = &WikiGroup::getGroup($GLOBALS['request']); if ($UserName == ADMIN_USER) return new _AdminUser($UserName); - /* elseif ($group->isMember(GROUP_ADMIN)) { // unneeded code - return _determineBogoUserOrPassUser($UserName); - } - */ else return _determineBogoUserOrPassUser($UserName); } @@ -199,6 +194,10 @@ function _determineBogoUserOrPassUser($UserName) { global $ForbiddenUser; + /** + * @var WikiRequest $request + */ + global $request; // Sanity check. User name is a condition of the definition of // _BogoUser and _PassUser. @@ -210,7 +209,7 @@ if (_isBogoUserAllowed() and isWikiWord($UserName)) { include_once 'lib/WikiUser/BogoLogin.php'; $_BogoUser = new _BogoLoginPassUser($UserName); - if ($_BogoUser->userExists() or $GLOBALS['request']->getArg('auth')) + if ($_BogoUser->userExists() or $request->getArg('auth')) return $_BogoUser; } if (_isUserPasswordsAllowed()) { @@ -222,9 +221,9 @@ else { $_PassUser = new _PassUser($UserName, isset($_BogoUser) ? $_BogoUser->_prefs : false); - if ($_PassUser->userExists() or $GLOBALS['request']->getArg('auth')) { - if (isset($GLOBALS['request']->_user_class)) - $class = $GLOBALS['request']->_user_class; + if ($_PassUser->userExists() or $request->getArg('auth')) { + if (isset($request->_user_class)) + $class = $request->_user_class; elseif (strtolower(get_class($_PassUser)) == "_passuser") $class = $_PassUser->nextClass(); else $class = get_class($_PassUser); @@ -320,14 +319,14 @@ } if (!empty($user->_authmethod)) $newuser->_authmethod = $user->_authmethod; - $GLOBALS['request']->_user_class = get_class($newuser); + $request->_user_class = get_class($newuser); /* foreach (get_object_vars($user) as $k => $v) { if (!empty($v)) $olduser->$k = $v; } */ $newuser->hasHomePage(); // revive db handle, because these don't survive sessions - //$GLOBALS['request']->_user = $olduser; + //$request->_user = $olduser; return $newuser; } else { return false; @@ -555,7 +554,7 @@ if (!$this->isSignedIn()) return false; if (!$this->isAuthenticated()) return false; - if (!$group) $group = &$GLOBALS['request']->getGroup(); + if (!$group) $group = &$request->getGroup(); return ($this->_level > WIKIAUTH_BOGO and $group->isMember(GROUP_ADMIN)); } @@ -563,9 +562,14 @@ */ function getId() { + /** + * @var WikiRequest $request + */ + global $request; + return ($this->UserName() ? $this->UserName() - : $GLOBALS['request']->get('REMOTE_ADDR')); + : $request->get('REMOTE_ADDR')); } /** Name for an authenticated user. No IP here. @@ -574,7 +578,7 @@ { return ($this->isAuthenticated() ? $this->_userid - : ''); //$GLOBALS['request']->get('REMOTE_ADDR') ); + : ''); // $request->get('REMOTE_ADDR') ); } function hasAuthority($require_level) @@ -631,8 +635,8 @@ } //error_log("$entry\n", 3, LOGIN_LOG); } - if (method_exists($GLOBALS['request']->_user, "logout")) { //_HttpAuthPassUser - $GLOBALS['request']->_user->logout(); + if (method_exists($request->_user, "logout")) { //_HttpAuthPassUser + $request->... [truncated message content] |