From: Geoffrey T. D. <da...@us...> - 2001-11-21 19:46:53
|
Update of /cvsroot/phpwiki/phpwiki/lib In directory usw-pr-cvs1:/tmp/cvs-serv19032/lib Modified Files: ErrorManager.php DbaDatabase.php Template.php prepend.php Log Message: Change calling conventions for ErrorManager::pushErrorHandler() and ErrorManager::setFatalHandler(). Now these take a WikiCallback instead of the Pear style callback specification. Index: ErrorManager.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/ErrorManager.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** ErrorManager.php 2001/11/06 17:13:22 1.2 --- ErrorManager.php 2001/11/21 19:46:50 1.3 *************** *** 96,103 **** * * @access public ! * @param $handler string or array ! * To register a global function as a handler, just pass the functions name ! * (as a string). To register an object method as a handler, pass a array: ! * the first element is the object, the second is the name of the method. */ function pushErrorHandler($handler) { --- 96,100 ---- * * @access public ! * @param $handler WikiCallback Handler to call. */ function pushErrorHandler($handler) { *************** *** 120,127 **** * * @access public ! * @param $handler string or array ! * To register a global function as a handler, just pass the functions name ! * (as a string). To register an object method as a handler, pass a array: ! * the first element is the object, the second is the name of the method. */ function setFatalHandler($handler) { --- 117,121 ---- * * @access public ! * @param $handler WikiCallback Callback to call on fatal errors. */ function setFatalHandler($handler) { *************** *** 129,145 **** } - function _callHandler($handler, $error) { - if (is_string($handler)) { - return call_user_func($handler, $error); - } - else if (is_array($handler)) { - list($object, $method) = $handler; - if (method_exists($object, $method)) - return call_user_method($method, $object, $error); - } - echo "<div>ErrorManager::_callHandler: BAD HANDLER<br></div>\n"; - return false; - } - /** * Handle an error. --- 123,126 ---- *************** *** 162,166 **** foreach ($this->_handlers as $handler) { ! $result = $this->_callHandler($handler, $error); if (!$result) { continue; // Handler did not handle error. --- 143,147 ---- foreach ($this->_handlers as $handler) { ! $result = $handler->call($error); if (!$result) { continue; // Handler did not handle error. *************** *** 208,212 **** $this->_flush_errors(); if ($this->_fatal_handler) ! $this->_callHandler($this->_fatal_handler, $error); exit -1; } --- 189,193 ---- $this->_flush_errors(); if ($this->_fatal_handler) ! $this->_fatal_hander->call($error); exit -1; } Index: DbaDatabase.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/DbaDatabase.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** DbaDatabase.php 2001/09/18 19:16:23 1.1 --- DbaDatabase.php 2001/11/21 19:46:50 1.2 *************** *** 29,33 **** global $ErrorManager; $this->_dba_open_error = false; ! $ErrorManager->pushErrorHandler(array($this, '_dba_open_error_handler')); while (($dbh = dba_open($this->_file, $mode, $this->_handler)) < 1) { if (--$watchdog <= 0) --- 29,33 ---- global $ErrorManager; $this->_dba_open_error = false; ! $ErrorManager->pushErrorHandler(new WikiMethodCb($this, '_dba_open_error_handler')); while (($dbh = dba_open($this->_file, $mode, $this->_handler)) < 1) { if (--$watchdog <= 0) Index: Template.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/Template.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** Template.php 2001/09/19 03:24:36 1.2 --- Template.php 2001/11/21 19:46:50 1.3 *************** *** 113,117 **** global $ErrorManager; ! $ErrorManager->pushErrorHandler(array($this, '_errorHandler')); eval('?>' . $this->_munge_input($this->_tmpl)); $ErrorManager->popErrorHandler(); --- 113,117 ---- global $ErrorManager; ! $ErrorManager->pushErrorHandler(new WikiMethodCb($this, '_errorHandler')); eval('?>' . $this->_munge_input($this->_tmpl)); $ErrorManager->popErrorHandler(); Index: prepend.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/prepend.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** prepend.php 2001/09/18 19:16:23 1.4 --- prepend.php 2001/11/21 19:46:50 1.5 *************** *** 10,13 **** --- 10,14 ---- error_reporting(E_ALL); require_once('lib/ErrorManager.php'); + require_once('lib/WikiCallback.php'); // FIXME: make this part of Request? *************** *** 43,47 **** $ErrorManager->setPostponedErrorMask(E_ALL); ! $ErrorManager->setFatalHandler('ExitWiki'); --- 44,48 ---- $ErrorManager->setPostponedErrorMask(E_ALL); ! $ErrorManager->setFatalHandler(new WikiFunctionCb('ExitWiki')); |