diff options
-rw-r--r-- | phpBB/config/passwords.yml | 4 | ||||
-rw-r--r-- | phpBB/phpbb/passwords/helper.php | 9 | ||||
-rw-r--r-- | phpBB/phpbb/passwords/manager.php | 12 | ||||
-rw-r--r-- | tests/passwords/manager_test.php | 5 |
4 files changed, 21 insertions, 9 deletions
diff --git a/phpBB/config/passwords.yml b/phpBB/config/passwords.yml index 26f604c2e2..efd23d814c 100644 --- a/phpBB/config/passwords.yml +++ b/phpBB/config/passwords.yml @@ -50,4 +50,8 @@ services: arguments: - @config - @passwords.driver_collection + - @passwords.helper - %passwords.algorithm% + + passwords.helper: + class: phpbb_passwords_helper diff --git a/phpBB/phpbb/passwords/helper.php b/phpBB/phpbb/passwords/helper.php index d91edb90a1..0ce1d3be45 100644 --- a/phpBB/phpbb/passwords/helper.php +++ b/phpBB/phpbb/passwords/helper.php @@ -26,13 +26,16 @@ class phpbb_passwords_helper protected $manager; /** - * Construct a phpbb_passwords_helper object + * Set the passwords manager instance * * @param phpbb_passwords_manager $manager Crypto manager object */ - public function __construct($manager) + public function set_manager(phpbb_passwords_manager $manager) { - $this->manager = $manager; + if ($this->manager === null) + { + $this->manager = $manager; + } } /** diff --git a/phpBB/phpbb/passwords/manager.php b/phpBB/phpbb/passwords/manager.php index cf6eddd135..6cc3510f8e 100644 --- a/phpBB/phpbb/passwords/manager.php +++ b/phpBB/phpbb/passwords/manager.php @@ -60,15 +60,16 @@ class phpbb_passwords_manager * @param phpbb_config $config phpBB configuration * @param phpbb_di_service_collection $hashing_algorithms Hashing driver * service collection + * @param phpbb_passwords_helper $helper Passwords helper object * @param string $default Default driver name */ - public function __construct($config, $hashing_algorithms, $default) + public function __construct($config, $hashing_algorithms, $helper, $default) { $this->config = $config; $this->type = $default; $this->fill_type_map($hashing_algorithms); - $this->load_passwords_helper(); + $this->load_passwords_helper($helper); } /** @@ -94,12 +95,15 @@ class phpbb_passwords_manager /** * Load passwords helper class + * + * @param phpbb_passwords_helper $helper Passwords helper object */ - protected function load_passwords_helper() + protected function load_passwords_helper($helper) { if ($this->helper === null) { - $this->helper = new phpbb_passwords_helper($this); + $this->helper = $helper; + $this->helper->set_manager($this); } } diff --git a/tests/passwords/manager_test.php b/tests/passwords/manager_test.php index 1ec7c40878..c695735aa6 100644 --- a/tests/passwords/manager_test.php +++ b/tests/passwords/manager_test.php @@ -40,8 +40,9 @@ class phpbb_passwords_manager_test extends PHPUnit_Framework_TestCase $this->phpbb_container->set($key, $driver); } - // Set up avatar manager - $this->manager = new phpbb_passwords_manager($config, $this->passwords_drivers, 'passwords.driver.bcrypt_2y'); + $this->helper = new phpbb_passwords_helper; + // Set up passwords manager + $this->manager = new phpbb_passwords_manager($config, $this->passwords_drivers, $this->helper, 'passwords.driver.bcrypt_2y'); } public function hash_password_data() |