diff options
author | Marc Alexander <admin@m-a-styles.de> | 2015-08-27 10:51:10 +0200 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2015-09-09 08:29:05 +0200 |
commit | 16f3b8c2b9de388223cbe8ace9e1d9bcf0ba5e11 (patch) | |
tree | e4f44b05770bebca7b39ee07561268ea1e0ecbd9 | |
parent | b2957b9d6543737076d96209ba0f12e2fc145a9a (diff) | |
download | forums-16f3b8c2b9de388223cbe8ace9e1d9bcf0ba5e11.tar forums-16f3b8c2b9de388223cbe8ace9e1d9bcf0ba5e11.tar.gz forums-16f3b8c2b9de388223cbe8ace9e1d9bcf0ba5e11.tar.bz2 forums-16f3b8c2b9de388223cbe8ace9e1d9bcf0ba5e11.tar.xz forums-16f3b8c2b9de388223cbe8ace9e1d9bcf0ba5e11.zip |
[ticket/13904] Modify files for changes in ini wrapper
PHPBB3-13904
-rw-r--r-- | phpBB/config/default/container/services_php.yml | 2 | ||||
-rw-r--r-- | phpBB/install/database_update.php | 4 | ||||
-rw-r--r-- | phpBB/phpbb/files/filespec.php | 8 | ||||
-rw-r--r-- | phpBB/phpbb/files/upload.php | 8 | ||||
-rw-r--r-- | phpBB/phpbb/install/helper/config.php | 8 | ||||
-rw-r--r-- | phpBB/phpbb/plupload/plupload.php | 12 | ||||
-rw-r--r-- | tests/cache/apc_driver_test.php | 6 | ||||
-rw-r--r-- | tests/files/upload_test.php | 4 | ||||
-rw-r--r-- | tests/functional/fileupload_remote_test.php | 4 | ||||
-rw-r--r-- | tests/installer/installer_config_test.php | 6 | ||||
-rw-r--r-- | tests/installer/module_base_test.php | 2 | ||||
-rw-r--r-- | tests/plupload/plupload_test.php | 2 | ||||
-rw-r--r-- | tests/upload/filespec_test.php | 8 | ||||
-rw-r--r-- | tests/upload/fileupload_test.php | 4 | ||||
-rw-r--r-- | tests/wrapper/phpbb_php_ini_fake.php | 2 | ||||
-rw-r--r-- | tests/wrapper/phpbb_php_ini_test.php | 46 |
16 files changed, 60 insertions, 66 deletions
diff --git a/phpBB/config/default/container/services_php.yml b/phpBB/config/default/container/services_php.yml index 8aabc7341f..29349960f3 100644 --- a/phpBB/config/default/container/services_php.yml +++ b/phpBB/config/default/container/services_php.yml @@ -1,3 +1,3 @@ services: php_ini: - class: phpbb\php\ini + class: bantu\IniGetWrapper\IniGetWrapper diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 853848d637..299467b5f3 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -205,8 +205,8 @@ $migrator->set_migrations($migrations); // What is a safe limit of execution time? Half the max execution time should be safe. // No more than 15 seconds so the user isn't sitting and waiting for a very long time -$phpbb_ini = new \phpbb\php\ini(); -$safe_time_limit = min(15, ($phpbb_ini->get_int('max_execution_time') / 2)); +$phpbb_ini = new \bantu\IniGetWrapper\IniGetWrapper(); +$safe_time_limit = min(15, ($phpbb_ini->getNumeric('max_execution_time') / 2)); // While we're going to try limit this to half the max execution time, // we want to try and take additional measures to prevent hitting the diff --git a/phpBB/phpbb/files/filespec.php b/phpBB/phpbb/files/filespec.php index 48e12f23ef..580016b281 100644 --- a/phpBB/phpbb/files/filespec.php +++ b/phpBB/phpbb/files/filespec.php @@ -72,7 +72,7 @@ class filespec /** @var \phpbb\filesystem\filesystem_interface */ protected $filesystem; - /** @var \phpbb\php\ini ini_get() wrapper class */ + /** @var \bantu\IniGetWrapper\IniGetWrapper ini_get() wrapper class */ protected $php_ini; /** @var language Language class */ @@ -92,12 +92,12 @@ class filespec * * @param \phpbb\filesystem\filesystem_interface $phpbb_filesystem Filesystem * @param language $language Language - * @param \phpbb\php\ini $php_ini ini_get() wrapper + * @param \bantu\IniGetWrapper\IniGetWrapper $php_ini ini_get() wrapper * @param string $phpbb_root_path phpBB root path * @param \phpbb\mimetype\guesser $mimetype_guesser Mime type guesser * @param \phpbb\plupload\plupload $plupload Plupload */ - public function __construct(\phpbb\filesystem\filesystem_interface $phpbb_filesystem, language $language, \phpbb\php\ini $php_ini, $phpbb_root_path, \phpbb\mimetype\guesser $mimetype_guesser = null, \phpbb\plupload\plupload $plupload = null) + public function __construct(\phpbb\filesystem\filesystem_interface $phpbb_filesystem, language $language, \bantu\IniGetWrapper\IniGetWrapper $php_ini, $phpbb_root_path, \phpbb\mimetype\guesser $mimetype_guesser = null, \phpbb\plupload\plupload $plupload = null) { $this->filesystem = $phpbb_filesystem; $this->language = $language; @@ -417,7 +417,7 @@ class filespec return false; } - $upload_mode = ($this->php_ini->get_bool('open_basedir') || $this->php_ini->get_bool('safe_mode')) ? 'move' : 'copy'; + $upload_mode = ($this->php_ini->getBool('open_basedir') || $this->php_ini->getBool('safe_mode')) ? 'move' : 'copy'; $upload_mode = ($this->local) ? 'local' : $upload_mode; $this->destination_file = $this->destination_path . '/' . utf8_basename($this->realname); diff --git a/phpBB/phpbb/files/upload.php b/phpBB/phpbb/files/upload.php index 036f216d22..328dd49a06 100644 --- a/phpBB/phpbb/files/upload.php +++ b/phpBB/phpbb/files/upload.php @@ -56,7 +56,7 @@ class upload /** @var \phpbb\files\factory Files factory */ protected $factory; - /** @var \phpbb\php\ini ini_get() wrapper */ + /** @var \bantu\IniGetWrapper\IniGetWrapper ini_get() wrapper */ protected $php_ini; /** @var \phpbb\language\language Language class */ @@ -74,11 +74,11 @@ class upload * @param filesystem_interface $filesystem * @param factory $factory Files factory * @param language $language Language class - * @param \phpbb\php\ini $php_ini ini_get() wrapper + * @param \bantu\IniGetWrapper\IniGetWrapper $php_ini ini_get() wrapper * @param request_interface $request Request class * @param string $phpbb_root_path phpBB root path */ - public function __construct(filesystem_interface $filesystem, factory $factory, language $language, \phpbb\php\ini $php_ini, request_interface $request, $phpbb_root_path) + public function __construct(filesystem_interface $filesystem, factory $factory, language $language, \bantu\IniGetWrapper\IniGetWrapper $php_ini, request_interface $request, $phpbb_root_path) { $this->filesystem = $filesystem; $this->factory = $factory; @@ -216,7 +216,7 @@ class upload switch ($errorcode) { case UPLOAD_ERR_INI_SIZE: - $max_filesize = $this->php_ini->get_string('upload_max_filesize'); + $max_filesize = $this->php_ini->getString('upload_max_filesize'); $unit = 'MB'; if (!empty($max_filesize)) diff --git a/phpBB/phpbb/install/helper/config.php b/phpBB/phpbb/install/helper/config.php index b0480e7e5b..d5653f1924 100644 --- a/phpBB/phpbb/install/helper/config.php +++ b/phpBB/phpbb/install/helper/config.php @@ -41,7 +41,7 @@ class config protected $install_config_file; /** - * @var \phpbb\php\ini + * @var \bantu\IniGetWrapper\IniGetWrapper */ protected $php_ini; @@ -83,7 +83,7 @@ class config /** * Constructor */ - public function __construct(\phpbb\filesystem\filesystem_interface $filesystem, \phpbb\php\ini $php_ini, $phpbb_root_path) + public function __construct(\phpbb\filesystem\filesystem_interface $filesystem, \bantu\IniGetWrapper\IniGetWrapper $php_ini, $phpbb_root_path) { $this->filesystem = $filesystem; $this->php_ini = $php_ini; @@ -373,7 +373,7 @@ class config protected function setup_system_data() { // Query maximum runtime from php.ini - $execution_time = $this->php_ini->get_int('max_execution_time'); + $execution_time = $this->php_ini->getNumeric('max_execution_time'); $execution_time = min(15, $execution_time / 2); $this->system_data['max_execution_time'] = $execution_time; @@ -381,6 +381,6 @@ class config $this->system_data['start_time'] = time(); // Get memory limit - $this->system_data['memory_limit'] = $this->php_ini->get_bytes('memory_limit'); + $this->system_data['memory_limit'] = $this->php_ini->getBytes('memory_limit'); } } diff --git a/phpBB/phpbb/plupload/plupload.php b/phpBB/phpbb/plupload/plupload.php index 35f3a0071e..0e67ee209b 100644 --- a/phpBB/phpbb/plupload/plupload.php +++ b/phpBB/phpbb/plupload/plupload.php @@ -39,7 +39,7 @@ class plupload protected $user; /** - * @var \phpbb\php\ini + * @var \bantu\IniGetWrapper\IniGetWrapper */ protected $php_ini; @@ -67,10 +67,10 @@ class plupload * @param \phpbb\config\config $config * @param \phpbb\request\request_interface $request * @param \phpbb\user $user - * @param \phpbb\php\ini $php_ini + * @param \bantu\IniGetWrapper\IniGetWrapper $php_ini * @param \phpbb\mimetype\guesser $mimetype_guesser */ - public function __construct($phpbb_root_path, \phpbb\config\config $config, \phpbb\request\request_interface $request, \phpbb\user $user, \phpbb\php\ini $php_ini, \phpbb\mimetype\guesser $mimetype_guesser) + public function __construct($phpbb_root_path, \phpbb\config\config $config, \phpbb\request\request_interface $request, \phpbb\user $user, \bantu\IniGetWrapper\IniGetWrapper $php_ini, \phpbb\mimetype\guesser $mimetype_guesser) { $this->phpbb_root_path = $phpbb_root_path; $this->config = $config; @@ -284,9 +284,9 @@ class plupload public function get_chunk_size() { $max = min( - $this->php_ini->get_bytes('upload_max_filesize'), - $this->php_ini->get_bytes('post_max_size'), - max(1, $this->php_ini->get_bytes('memory_limit')), + $this->php_ini->getBytes('upload_max_filesize'), + $this->php_ini->getBytes('post_max_size'), + max(1, $this->php_ini->getBytes('memory_limit')), $this->config['max_filesize'] ); diff --git a/tests/cache/apc_driver_test.php b/tests/cache/apc_driver_test.php index 10130b465b..706f274448 100644 --- a/tests/cache/apc_driver_test.php +++ b/tests/cache/apc_driver_test.php @@ -34,14 +34,14 @@ class phpbb_cache_apc_driver_test extends phpbb_cache_common_test_case self::markTestSkipped('APC extension is not loaded'); } - $php_ini = new \phpbb\php\ini; + $php_ini = new \bantu\IniGetWrapper\IniGetWrapper; - if (!$php_ini->get_bool('apc.enabled')) + if (!$php_ini->getBool('apc.enabled')) { self::markTestSkipped('APC is not enabled. Make sure apc.enabled=1 in php.ini'); } - if (PHP_SAPI == 'cli' && !$php_ini->get_bool('apc.enable_cli')) + if (PHP_SAPI == 'cli' && !$php_ini->getBool('apc.enable_cli')) { self::markTestSkipped('APC is not enabled for CLI. Set apc.enable_cli=1 in php.ini'); } diff --git a/tests/files/upload_test.php b/tests/files/upload_test.php index 6f4a10e6aa..da9d78afbc 100644 --- a/tests/files/upload_test.php +++ b/tests/files/upload_test.php @@ -23,7 +23,7 @@ class phpbb_files_upload_test extends phpbb_test_case /** @var \phpbb\files\factory */ protected $factory; - /** @var \phpbb\php\ini */ + /** @var \bantu\IniGetWrapper\IniGetWrapper */ protected $php_ini; /** @var \phpbb\language\language */ @@ -52,7 +52,7 @@ class phpbb_files_upload_test extends phpbb_test_case $this->filesystem = new \phpbb\filesystem\filesystem(); $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); - $this->php_ini = new \phpbb\php\ini; + $this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper; $this->container = new phpbb_mock_container_builder($phpbb_root_path, $phpEx); $this->container->set('files.filespec', new \phpbb\files\filespec( diff --git a/tests/functional/fileupload_remote_test.php b/tests/functional/fileupload_remote_test.php index 4fd8ae1f19..6752ff01f4 100644 --- a/tests/functional/fileupload_remote_test.php +++ b/tests/functional/fileupload_remote_test.php @@ -22,7 +22,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case /** @var \phpbb\files\factory */ protected $factory; - /** @var \phpbb\php\ini */ + /** @var \bantu\IniGetWrapper\IniGetWrapper */ protected $php_ini; /** @var \phpbb\language\language */ @@ -54,7 +54,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case $this->filesystem = new \phpbb\filesystem\filesystem(); $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); $this->request = $this->getMock('\phpbb\request\request'); - $this->php_ini = new \phpbb\php\ini; + $this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper; $container = new phpbb_mock_container_builder(); $container->set('files.filespec', new \phpbb\files\filespec($this->filesystem, $this->language, $this->php_ini, $this->phpbb_root_path)); diff --git a/tests/installer/installer_config_test.php b/tests/installer/installer_config_test.php index c7334ebd93..7de23aea36 100644 --- a/tests/installer/installer_config_test.php +++ b/tests/installer/installer_config_test.php @@ -24,11 +24,11 @@ class phpbb_installer_config_test extends phpbb_test_case { $phpbb_root_path = __DIR__ . './../../phpBB/'; $filesystem = $this->getMock('\phpbb\filesystem\filesystem'); - $php_ini = $this->getMockBuilder('\phpbb\php\ini') + $php_ini = $this->getMockBuilder('\bantu\IniGetWrapper\IniGetWrapper') ->getMock(); - $php_ini->method('get_int') + $php_ini->method('getInt') ->willReturn(-1); - $php_ini->method('get_bytes') + $php_ini->method('getBytes') ->willReturn(-1); $this->config = new config($filesystem, $php_ini, $phpbb_root_path); diff --git a/tests/installer/module_base_test.php b/tests/installer/module_base_test.php index fd92c9b674..9578010047 100644 --- a/tests/installer/module_base_test.php +++ b/tests/installer/module_base_test.php @@ -43,7 +43,7 @@ class module_base_test extends phpbb_test_case $this->module = new test_installer_module($module_collection, true, false); $iohandler = $this->getMock('\phpbb\install\helper\iohandler\iohandler_interface'); - $config = new \phpbb\install\helper\config(new \phpbb\filesystem\filesystem(), new \phpbb\php\ini(), '', 'php'); + $config = new \phpbb\install\helper\config(new \phpbb\filesystem\filesystem(), new \bantu\IniGetWrapper\IniGetWrapper(), '', 'php'); $this->module->setup($config, $iohandler); } diff --git a/tests/plupload/plupload_test.php b/tests/plupload/plupload_test.php index aa7793567d..3312f4d0a0 100644 --- a/tests/plupload/plupload_test.php +++ b/tests/plupload/plupload_test.php @@ -48,7 +48,7 @@ class phpbb_plupload_test extends phpbb_test_case $config, new phpbb_mock_request, new \phpbb\user($lang, '\phpbb\datetime'), - new \phpbb\php\ini, + new \bantu\IniGetWrapper\IniGetWrapper, new \phpbb\mimetype\guesser(array(new \phpbb\mimetype\extension_guesser)) ); diff --git a/tests/upload/filespec_test.php b/tests/upload/filespec_test.php index 595439c917..a53c27f045 100644 --- a/tests/upload/filespec_test.php +++ b/tests/upload/filespec_test.php @@ -93,7 +93,7 @@ class phpbb_filespec_test extends phpbb_test_case 'error' => '', ); - $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \phpbb\php\ini, $this->phpbb_root_path, $this->mimetype_guesser); + $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \bantu\IniGetWrapper\IniGetWrapper, $this->phpbb_root_path, $this->mimetype_guesser); return $filespec->set_upload_ary(array_merge($upload_ary, $override)); } @@ -114,7 +114,7 @@ class phpbb_filespec_test extends phpbb_test_case public function test_empty_upload_ary() { - $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \phpbb\php\ini, $this->phpbb_root_path, $this->mimetype_guesser); + $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \bantu\IniGetWrapper\IniGetWrapper, $this->phpbb_root_path, $this->mimetype_guesser); $this->assertInstanceOf('\phpbb\files\filespec', $filespec->set_upload_ary(array())); $this->assertTrue($filespec->init_error()); } @@ -262,7 +262,7 @@ class phpbb_filespec_test extends phpbb_test_case */ public function test_clean_filename_avatar($filename, $expected, $mode, $prefix = '', $user_id = '') { - $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \phpbb\php\ini, $this->phpbb_root_path, $this->mimetype_guesser); + $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \bantu\IniGetWrapper\IniGetWrapper, $this->phpbb_root_path, $this->mimetype_guesser); if ($filename) { @@ -419,7 +419,7 @@ class phpbb_filespec_test extends phpbb_test_case public function test_is_uploaded() { - $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \phpbb\php\ini, $this->phpbb_root_path, null); + $filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \bantu\IniGetWrapper\IniGetWrapper, $this->phpbb_root_path, null); $reflection_filespec = new ReflectionClass($filespec); $plupload_property = $reflection_filespec->getProperty('plupload'); $plupload_property->setAccessible(true); diff --git a/tests/upload/fileupload_test.php b/tests/upload/fileupload_test.php index 40f8704271..43106599e4 100644 --- a/tests/upload/fileupload_test.php +++ b/tests/upload/fileupload_test.php @@ -27,7 +27,7 @@ class phpbb_fileupload_test extends phpbb_test_case /** @var \phpbb\files\factory */ protected $factory; - /** @var \phpbb\php\ini */ + /** @var \bantu\IniGetWrapper\IniGetWrapper */ protected $php_ini; /** @var \phpbb\language\language */ @@ -53,7 +53,7 @@ class phpbb_fileupload_test extends phpbb_test_case $config['rand_seed_last_update'] = time() + 600; $this->request = $this->getMock('\phpbb\request\request'); - $this->php_ini = new \phpbb\php\ini; + $this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper; $this->filesystem = new \phpbb\filesystem\filesystem(); $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); diff --git a/tests/wrapper/phpbb_php_ini_fake.php b/tests/wrapper/phpbb_php_ini_fake.php index f218ff6d03..300ce30cfe 100644 --- a/tests/wrapper/phpbb_php_ini_fake.php +++ b/tests/wrapper/phpbb_php_ini_fake.php @@ -11,7 +11,7 @@ * */ -class phpbb_php_ini_fake extends \phpbb\php\ini +class phpbb_php_ini_fake extends \bantu\IniGetWrapper\IniGetWrapper { function get($varname) { diff --git a/tests/wrapper/phpbb_php_ini_test.php b/tests/wrapper/phpbb_php_ini_test.php index 27c2487f0a..8ef63757a5 100644 --- a/tests/wrapper/phpbb_php_ini_test.php +++ b/tests/wrapper/phpbb_php_ini_test.php @@ -16,6 +16,7 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; class phpbb_wrapper_phpbb_php_ini_test extends phpbb_test_case { + /** @var \phpbb_php_ini_fake php_ini */ protected $php_ini; public function setUp() @@ -25,44 +26,37 @@ class phpbb_wrapper_phpbb_php_ini_test extends phpbb_test_case public function test_get_string() { - $this->assertSame(false, $this->php_ini->get_string(false)); - $this->assertSame('phpbb', $this->php_ini->get_string(' phpbb ')); + $this->assertSame('', $this->php_ini->getString(false)); + $this->assertSame('phpbb', $this->php_ini->getString(' phpbb ')); } public function test_get_bool() { - $this->assertSame(true, $this->php_ini->get_bool('ON')); - $this->assertSame(true, $this->php_ini->get_bool('on')); - $this->assertSame(true, $this->php_ini->get_bool('1')); + $this->assertSame(true, $this->php_ini->getBool('ON')); + $this->assertSame(true, $this->php_ini->getBool('on')); + $this->assertSame(true, $this->php_ini->getBool('1')); - $this->assertSame(false, $this->php_ini->get_bool('OFF')); - $this->assertSame(false, $this->php_ini->get_bool('off')); - $this->assertSame(false, $this->php_ini->get_bool('0')); - $this->assertSame(false, $this->php_ini->get_bool('')); + $this->assertSame(false, $this->php_ini->getBool('OFF')); + $this->assertSame(false, $this->php_ini->getBool('off')); + $this->assertSame(false, $this->php_ini->getBool('0')); + $this->assertSame(false, $this->php_ini->getBool('')); } public function test_get_int() { - $this->assertSame(1234, $this->php_ini->get_int('1234')); - $this->assertSame(-12345, $this->php_ini->get_int('-12345')); - $this->assertSame(false, $this->php_ini->get_int('phpBB')); - } - - public function test_get_float() - { - $this->assertSame(1234.0, $this->php_ini->get_float('1234')); - $this->assertSame(-12345.0, $this->php_ini->get_float('-12345')); - $this->assertSame(false, $this->php_ini->get_float('phpBB')); + $this->assertSame(1234, $this->php_ini->getNumeric('1234')); + $this->assertSame(-12345, $this->php_ini->getNumeric('-12345')); + $this->assertSame(null, $this->php_ini->getNumeric('phpBB')); } public function test_get_bytes_invalid() { - $this->assertSame(false, $this->php_ini->get_bytes(false)); - $this->assertSame(false, $this->php_ini->get_bytes('phpBB')); - $this->assertSame(false, $this->php_ini->get_bytes('k')); - $this->assertSame(false, $this->php_ini->get_bytes('-k')); - $this->assertSame(false, $this->php_ini->get_bytes('M')); - $this->assertSame(false, $this->php_ini->get_bytes('-M')); + $this->assertSame(null, $this->php_ini->getBytes(false)); + $this->assertSame(null, $this->php_ini->getBytes('phpBB')); + $this->assertSame(null, $this->php_ini->getBytes('k')); + $this->assertSame(null, $this->php_ini->getBytes('-k')); + $this->assertSame(null, $this->php_ini->getBytes('M')); + $this->assertSame(null, $this->php_ini->getBytes('-M')); } /** @@ -70,7 +64,7 @@ class phpbb_wrapper_phpbb_php_ini_test extends phpbb_test_case */ public function test_get_bytes($expected, $value) { - $actual = $this->php_ini->get_bytes($value); + $actual = $this->php_ini->getBytes($value); $this->assertTrue(is_float($actual) || is_int($actual)); $this->assertEquals($expected, $actual); |