SourceForge logo
SourceForge logo
Menu

phpwiki-checkins

From: Geoffrey T. D. <da...@us...> - 2001年09月19日 19:20:33
Update of /cvsroot/phpwiki/phpwiki/lib/WikiDB/backend
In directory usw-pr-cvs1:/tmp/cvs-serv12091/lib/WikiDB/backend
Modified Files:
	PearDB.php 
Log Message:
Search some standard locations for PEAR library code if DB.php is
not found in PHP's include_path.
Added some workarounds for a bug in the PEAR DB code which ships
with PHP 4.0.6.
(I have now tested the MySQL backend with PEAR code from PHP 4.0.4pl1,
PHP 4.0.5 and PHP 4.0.6. Only the 4.0.6 code is buggy. With the new
fixes, all three versions seem to work fine. The bug is reported
to be fixed in the CVS version of the PHP source code.)
Index: PearDB.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/WikiDB/backend/PearDB.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** PearDB.php	2001年09月19日 02:58:24	1.2
--- PearDB.php	2001年09月19日 19:20:30	1.3
***************
*** 2,7 ****
 rcs_id('$Id$');
 
! require_once('DB.php');
 require_once('lib/WikiDB/backend.php');
 
 class WikiDB_backend_PearDB
--- 2,9 ----
 rcs_id('$Id$');
 
! //require_once('DB.php');
 require_once('lib/WikiDB/backend.php');
+ require_once('lib/FileFinder.php');
+ require_once('lib/ErrorManager.php');
 
 class WikiDB_backend_PearDB
***************
*** 9,12 ****
--- 11,22 ----
 {
 function WikiDB_backend_PearDB ($dbparams) {
+ // Find and include PEAR's DB.php.
+ $pearFinder = new PearFileFinder;
+ $pearFinder->includeOnce('DB.php');
+ 
+ // Install filter to handle bogus error notices from buggy DB.php's.
+ global $ErrorManager;
+ $ErrorManager->pushErrorHandler(array($this, '_pear_notice_filter'));
+ 
 // Open connection to database
 $dsn = $dbparams['dsn'];
***************
*** 634,643 ****
 */
 function _pear_error_callback($error) {
 $this->_dbh->setErrorHandling(PEAR_ERROR_PRINT);	// prevent recursive loops.
 $this->close();
! //trigger_error($this->_pear_error_message($error), E_USER_WARNING);
! ExitWiki($this->_pear_error_message($error));
 }
 
 function _pear_error_message($error) {
 $class = get_class($this);
--- 644,674 ----
 */
 function _pear_error_callback($error) {
+ if ($this->_is_false_error($error))
+ return;
+ 
 $this->_dbh->setErrorHandling(PEAR_ERROR_PRINT);	// prevent recursive loops.
 $this->close();
! trigger_error($this->_pear_error_message($error), E_USER_ERROR);
 }
 
+ /**
+ * Detect false errors messages from PEAR DB.
+ *
+ * The version of PEAR DB which ships with PHP 4.0.6 has a bug in that
+ * it doesn't recognize "LOCK" and "UNLOCK" as SQL commands which don't
+ * return any data. (So when a "LOCK" command doesn't return any data,
+ * DB reports it as an error, when in fact, it's not.)
+ *
+ * @access private
+ * @return bool True iff error is not really an error.
+ */
+ function _is_false_error($error) {
+ $code = $error->getCode();
+ $query = $this->_dbh->last_query;
+ return ($code == DB_ERROR
+ && ! DB::isManip($query)
+ && preg_match('/^\s*"?(LOCK|UNLOCK)\s/', $query));
+ }
+ 
 function _pear_error_message($error) {
 $class = get_class($this);
***************
*** 647,650 ****
--- 678,697 ----
 
 return $message;
+ }
+ 
+ /**
+ * Filter PHP errors notices from PEAR DB code.
+ *
+ * The PEAR DB code which ships with PHP 4.0.6 produces spurious
+ * errors and notices. This is an error callback (for use with
+ * ErrorManager which will filter out those spurious messages.)
+ * @see _is_false_error, ErrorManager
+ * @access private
+ */
+ function _pear_notice_filter($err) {
+ return ( $err->isNotice()
+ && $err->errfile == 'DB/common.php' 
+ && $err->errline == 126
+ && preg_match('/Undefined offset: +0\b/', $err->errstr) );
 }
 };
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /