diff options
author | Marc Alexander <admin@m-a-styles.de> | 2013-09-28 12:42:11 +0200 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2013-09-28 12:42:11 +0200 |
commit | 3ebff0a96042ba366e316727cbb83b063bc0700d (patch) | |
tree | 6b5e62802b6a1e5d8b8d041c18adc663041cbfaa | |
parent | de087d537e781741a0137e8ba9162d5baf3f37bb (diff) | |
download | forums-3ebff0a96042ba366e316727cbb83b063bc0700d.tar forums-3ebff0a96042ba366e316727cbb83b063bc0700d.tar.gz forums-3ebff0a96042ba366e316727cbb83b063bc0700d.tar.bz2 forums-3ebff0a96042ba366e316727cbb83b063bc0700d.tar.xz forums-3ebff0a96042ba366e316727cbb83b063bc0700d.zip |
[feature/passwords] Pass config via service container to driver helper
This will get rid of the global $config in the driver helper
PHPBB3-11610
-rw-r--r-- | phpBB/config/passwords.yml | 2 | ||||
-rw-r--r-- | phpBB/phpbb/passwords/driver/helper.php | 26 | ||||
-rw-r--r-- | tests/passwords/manager_test.php | 2 |
3 files changed, 23 insertions, 7 deletions
diff --git a/phpBB/config/passwords.yml b/phpBB/config/passwords.yml index 9e83bbd918..511f10c31c 100644 --- a/phpBB/config/passwords.yml +++ b/phpBB/config/passwords.yml @@ -51,6 +51,8 @@ services: passwords.driver_helper: class: phpbb\passwords\driver\helper + arguments: + - @config passwords.manager: class: phpbb\passwords\manager diff --git a/phpBB/phpbb/passwords/driver/helper.php b/phpBB/phpbb/passwords/driver/helper.php index fbb6f9bb2b..da66347ac3 100644 --- a/phpBB/phpbb/passwords/driver/helper.php +++ b/phpBB/phpbb/passwords/driver/helper.php @@ -23,12 +23,27 @@ if (!defined('IN_PHPBB')) class helper { /** + * @var phpbb\config\config + */ + protected $config; + + /** * base64 alphabet * @var string */ public $itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; /** + * Construct a driver helper object + * + * @param phpbb\config\config $config phpBB configuration + */ + public function __construct(\phpbb\config\config $config) + { + $this->config = $config; + } + + /** * Base64 encode hash * * @param string $input Input string @@ -86,16 +101,15 @@ class helper public function unique_id($extra = 'c') { static $dss_seeded = false; - global $config; - $val = $config['rand_seed'] . microtime(); + $val = $this->config['rand_seed'] . microtime(); $val = md5($val); - $config['rand_seed'] = md5($config['rand_seed'] . $val . $extra); + $this->config['rand_seed'] = md5($this->config['rand_seed'] . $val . $extra); - if ($dss_seeded !== true && ($config['rand_seed_last_update'] < time() - rand(1,10))) + if ($dss_seeded !== true && ($this->config['rand_seed_last_update'] < time() - rand(1,10))) { - set_config('rand_seed_last_update', time(), true); - set_config('rand_seed', $config['rand_seed'], true); + $this->config->set('rand_seed_last_update', time(), true); + $this->config->set('rand_seed', $this->config['rand_seed'], true); $dss_seeded = true; } diff --git a/tests/passwords/manager_test.php b/tests/passwords/manager_test.php index c6ab731d7b..082b309501 100644 --- a/tests/passwords/manager_test.php +++ b/tests/passwords/manager_test.php @@ -26,7 +26,7 @@ class phpbb_passwords_manager_test extends PHPUnit_Framework_TestCase // Prepare dependencies for manager and driver $config = new \phpbb\config\config(array()); - $driver_helper = new phpbb\passwords\driver\helper; + $driver_helper = new phpbb\passwords\driver\helper($config); $this->passwords_drivers = array( 'passwords.driver.bcrypt' => new phpbb\passwords\driver\bcrypt($config, $driver_helper), |