From: Gunnar Wrobel Date: Tue, 21 Dec 2010 06:24:47 +0000 (+0100) Subject: Supress errors for problematic backends. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=bacae3bcc12155e707100b437a547007f24d2d8e;p=horde.git Supress errors for problematic backends. --- diff --git a/framework/Kolab_Cli/lib/Horde/Kolab/Cli.php b/framework/Kolab_Cli/lib/Horde/Kolab/Cli.php index c9c64736b..0df5b8de7 100644 --- a/framework/Kolab_Cli/lib/Horde/Kolab/Cli.php +++ b/framework/Kolab_Cli/lib/Horde/Kolab/Cli.php @@ -55,6 +55,11 @@ class Horde_Kolab_Cli $parser->printHelp(); } else { try { + foreach ($modular->getModules() as $module) { + $modular->getProvider() + ->getModule($module) + ->handleArguments($options, $arguments); + } if (!empty($options['timed']) && class_exists('Horde_Support_Timer')) { $timer = new Horde_Support_Timer(); diff --git a/framework/Kolab_Cli/lib/Horde/Kolab/Cli/Module.php b/framework/Kolab_Cli/lib/Horde/Kolab/Cli/Module.php new file mode 100644 index 000000000..531762a7d --- /dev/null +++ b/framework/Kolab_Cli/lib/Horde/Kolab/Cli/Module.php @@ -0,0 +1,42 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Cli_Modular + */ + +/** + * The Horde_Kolab_Cli_Module:: interface describes the module structure for + * Kolab_Cli. + * + * Copyright 2010 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Horde + * @package Cli_Modular + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Cli_Modular + */ +interface Horde_Kolab_Cli_Module +extends Horde_Cli_Modular_Module +{ + /** + * Handle the options and arguments. + * + * @param mixed $options An array of options. + * @param mixed $arguments An array of arguments. + * + * @return NULL + */ + public function handleArguments($options, $arguments); +} \ No newline at end of file diff --git a/framework/Kolab_Cli/lib/Horde/Kolab/Cli/Module/Base.php b/framework/Kolab_Cli/lib/Horde/Kolab/Cli/Module/Base.php index 8142999cb..702b710da 100644 --- a/framework/Kolab_Cli/lib/Horde/Kolab/Cli/Module/Base.php +++ b/framework/Kolab_Cli/lib/Horde/Kolab/Cli/Module/Base.php @@ -28,7 +28,7 @@ * @link http://pear.horde.org/index.php?package=Cli_Modular */ class Horde_Kolab_Cli_Module_Base -implements Horde_Cli_Modular_Module +implements Horde_Kolab_Cli_Module { /** * Get the usage description for this module. @@ -142,4 +142,23 @@ Choices are: { return array(); } + + /** + * Handle the options and arguments. + * + * @param mixed $options An array of options. + * @param mixed $arguments An array of arguments. + * + * @return NULL + */ + public function handleArguments($options, $arguments) + { + if (in_array($options['driver'], array('roundcube', 'php', 'pear'))) { + if (defined('E_DEPRECATED')) { + error_reporting(E_ALL & ~E_STRICT & ~E_DEPRECATED & ~E_NOTICE); + } else { + error_reporting(E_ALL & ~E_STRICT & ~E_NOTICE); + } + } + } } \ No newline at end of file diff --git a/framework/Kolab_Cli/lib/Horde/Kolab/Cli/Module/Folder.php b/framework/Kolab_Cli/lib/Horde/Kolab/Cli/Module/Folder.php index ded4f61f1..d74516039 100644 --- a/framework/Kolab_Cli/lib/Horde/Kolab/Cli/Module/Folder.php +++ b/framework/Kolab_Cli/lib/Horde/Kolab/Cli/Module/Folder.php @@ -28,7 +28,7 @@ * @link http://pear.horde.org/index.php?package=Cli_Modular */ class Horde_Kolab_Cli_Module_Folder -implements Horde_Cli_Modular_Module +implements Horde_Kolab_Cli_Module { /** * Get the usage description for this module. @@ -94,6 +94,18 @@ implements Horde_Cli_Modular_Module } /** + * Handle the options and arguments. + * + * @param mixed $options An array of options. + * @param mixed $arguments An array of arguments. + * + * @return NULL + */ + public function handleArguments($options, $arguments) + { + } + + /** * Run the module. * * @param Horde_Cli $cli The CLI handler. diff --git a/framework/Kolab_Cli/package.xml b/framework/Kolab_Cli/package.xml index 5dbd06d6b..1ff398e70 100644 --- a/framework/Kolab_Cli/package.xml +++ b/framework/Kolab_Cli/package.xml @@ -22,8 +22,8 @@ jan@horde.org yes - 2010-12-16 - + 2010-12-21 + 0.0.1 0.0.1 @@ -49,6 +49,7 @@ + @@ -61,6 +62,9 @@ + + + @@ -105,6 +109,7 @@ + @@ -115,6 +120,7 @@ + @@ -128,7 +134,7 @@ alpha alpha - 2010-12-16 + 2010-12-21 GPL * Initial release. diff --git a/framework/Kolab_Cli/test/Horde/Kolab/Cli/Unit/Cli/Module/BaseTest.php b/framework/Kolab_Cli/test/Horde/Kolab/Cli/Unit/Cli/Module/BaseTest.php new file mode 100644 index 000000000..3d94a8c71 --- /dev/null +++ b/framework/Kolab_Cli/test/Horde/Kolab/Cli/Unit/Cli/Module/BaseTest.php @@ -0,0 +1,76 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Cli + */ + +/** + * Prepare the test setup. + */ +require_once dirname(__FILE__) . '/../../../Autoload.php'; + +/** + * Test the base modules. + * + * Copyright 2010 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Kolab + * @package Kolab_Cli + * @subpackage UnitTests + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Cli + */ +class Horde_Kolab_Cli_Unit_Cli_Module_BaseTest +extends Horde_Kolab_Cli_TestCase +{ + public function setUp() + { + $this->_storeErrorHandling(); + } + + public function tearDown() + { + $this->_restoreErrorHandling(); + } + + public function testNotice() + { + $this->assertTrue((bool) (error_reporting() & E_NOTICE)); + } + + public function testMissingNoticeWithRoundcubeDriver() + { + $base = new Horde_Kolab_Cli_Module_Base(); + $base->handleArguments(array('driver' => 'roundcube'), array()); + $this->assertFalse((bool) (error_reporting() & E_NOTICE)); + } + + public function testMissingNoticeWithHordeDriver() + { + $base = new Horde_Kolab_Cli_Module_Base(); + $base->handleArguments(array('driver' => 'horde'), array()); + $this->assertTrue((bool) (error_reporting() & E_NOTICE)); + } + + private function _storeErrorHandling() + { + $this->_error_handling = error_reporting(); + } + + private function _restoreErrorHandling() + { + error_reporting($this->_error_handling); + } +}