From 6c2824c4ba3b50e801142a760031ef3969b222e0 Mon Sep 17 00:00:00 2001 From: dairiki Date: Wed, 6 Feb 2002 23:02:45 +0000 Subject: [PATCH] Hide PHP error messages from failed include of plugins. (These seemed to screw up LawrenceAkka's browser.) The failure is still reported, since the plugin expansion will read 'Include of 'lib/plugin/Foo.php' failed.'. (I suppose that message could be cleaned up a bit, too...) git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@1871 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- lib/WikiPlugin.php | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/lib/WikiPlugin.php b/lib/WikiPlugin.php index 785c0ddb3..d4c46d493 100644 --- a/lib/WikiPlugin.php +++ b/lib/WikiPlugin.php @@ -1,5 +1,5 @@ _error($GLOBALS['php_errormsg']); - // If the plugin source has already been included, the - // include_once() will fail, so we don't want to crap out - // just yet. - $include_failed = true; - } else { - // this avoids: - // lib/WikiPlugin.php:265: Notice[8]: Undefined variable: include_failed - $include_failed = false; - } + + $ErrorManager->pushErrorHandler(new WikiMethodCb($this, '_plugin_error_filter')); + $include_failed = !include_once("lib/plugin/$plugin_name.php"); + $ErrorManager->popErrorHandler(); $plugin_class = "WikiPlugin_$plugin_name"; if (!class_exists($plugin_class)) { @@ -277,7 +269,6 @@ class WikiPluginLoader { $plugin_source)); return $this->_error(sprintf("%s: no such class", $plugin_class)); } - $plugin = new $plugin_class; if (!is_subclass_of($plugin, "WikiPlugin")) @@ -287,6 +278,12 @@ class WikiPluginLoader { return $plugin; } + function _plugin_error_filter ($err) { + if (preg_match("/Failed opening '.*' for inclusion/", $err->errstr)) + return true; // Ignore this error --- it's expected. + return false; + } + function getErrorDetail() { return $this->_errors; } -- 2.45.0