diff --git a/phpBB/config/avatars.yml b/phpBB/config/avatars.yml index 31ae1ecef9..d22a5db2ae 100644 --- a/phpBB/config/avatars.yml +++ b/phpBB/config/avatars.yml @@ -5,6 +5,7 @@ services: - @config - %core.root_path% - %core.php_ext% + - @path_helper - @cache.driver calls: - [set_name, [avatar.driver.gravatar]] @@ -17,6 +18,7 @@ services: - @config - %core.root_path% - %core.php_ext% + - @path_helper - @cache.driver calls: - [set_name, [avatar.driver.local]] @@ -29,6 +31,7 @@ services: - @config - %core.root_path% - %core.php_ext% + - @path_helper - @cache.driver calls: - [set_name, [avatar.driver.remote]] @@ -41,6 +44,7 @@ services: - @config - %core.root_path% - %core.php_ext% + - @path_helper - @cache.driver calls: - [set_name, [avatar.driver.upload]] diff --git a/phpBB/phpbb/avatar/driver/driver.php b/phpBB/phpbb/avatar/driver/driver.php index 0c54951cbd..206df86543 100644 --- a/phpBB/phpbb/avatar/driver/driver.php +++ b/phpBB/phpbb/avatar/driver/driver.php @@ -47,6 +47,12 @@ abstract class driver implements \phpbb\avatar\driver\driver_interface */ protected $php_ext; + /** + * Path Helper + * @var \phpbb\path_helper + */ + protected $path_helper; + /** * Cache driver * @var \phpbb\cache\driver\driver_interface @@ -75,13 +81,15 @@ abstract class driver implements \phpbb\avatar\driver\driver_interface * @param \phpbb\request\request $request Request object * @param string $phpbb_root_path Path to the phpBB root * @param string $php_ext PHP file extension + * @param \phpbb_path_helper $path_helper phpBB path helper * @param \phpbb\cache\driver\driver_interface $cache Cache driver */ - public function __construct(\phpbb\config\config $config, $phpbb_root_path, $php_ext, \phpbb\cache\driver\driver_interface $cache = null) + public function __construct(\phpbb\config\config $config, $phpbb_root_path, $php_ext, \phpbb\path_helper $path_helper, \phpbb\cache\driver\driver_interface $cache = null) { $this->config = $config; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; + $this->path_helper = $path_helper; $this->cache = $cache; } diff --git a/phpBB/phpbb/avatar/driver/local.php b/phpBB/phpbb/avatar/driver/local.php index d779099c46..0686ffe79a 100644 --- a/phpBB/phpbb/avatar/driver/local.php +++ b/phpBB/phpbb/avatar/driver/local.php @@ -29,7 +29,7 @@ class local extends \phpbb\avatar\driver\driver public function get_data($row) { return array( - 'src' => $this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $row['avatar'], + 'src' => $this->path_helper->get_web_root_path() . $this->config['avatar_gallery_path'] . '/' . $row['avatar'], 'width' => $row['avatar_width'], 'height' => $row['avatar_height'], ); diff --git a/phpBB/phpbb/avatar/driver/upload.php b/phpBB/phpbb/avatar/driver/upload.php index 377c9a0b04..bda872df7a 100644 --- a/phpBB/phpbb/avatar/driver/upload.php +++ b/phpBB/phpbb/avatar/driver/upload.php @@ -29,7 +29,7 @@ class upload extends \phpbb\avatar\driver\driver public function get_data($row, $ignore_config = false) { return array( - 'src' => $this->phpbb_root_path . 'download/file.' . $this->php_ext . '?avatar=' . $row['avatar'], + 'src' => $this->path_helper->get_web_root_path() . 'download/file.' . $this->php_ext . '?avatar=' . $row['avatar'], 'width' => $row['avatar_width'], 'height' => $row['avatar_height'], ); diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php index ba1fb04b33..4afa594beb 100644 --- a/tests/avatar/manager_test.php +++ b/tests/avatar/manager_test.php @@ -25,9 +25,17 @@ class phpbb_avatar_manager_test extends PHPUnit_Framework_TestCase $config = new \phpbb\config\config(array()); $request = $this->getMock('\phpbb\request\request'); $cache = $this->getMock('\phpbb\cache\driver\driver_interface'); + $path_helper = new \phpbb\path_helper( + new \phpbb\symfony_request( + new phpbb_mock_request() + ), + new \phpbb\filesystem(), + $this->phpbb_root_path, + $this->phpEx + ); // $this->avatar_foobar will be needed later on - $this->avatar_foobar = $this->getMock('\phpbb\avatar\driver\foobar', array('get_name'), array($config, $phpbb_root_path, $phpEx, $cache)); + $this->avatar_foobar = $this->getMock('\phpbb\avatar\driver\foobar', array('get_name'), array($config, $phpbb_root_path, $phpEx, $path_helper, $cache)); $this->avatar_foobar->expects($this->any()) ->method('get_name') ->will($this->returnValue('avatar.driver.foobar')); @@ -40,7 +48,7 @@ class phpbb_avatar_manager_test extends PHPUnit_Framework_TestCase foreach ($this->avatar_drivers() as $driver) { - $cur_avatar = $this->getMock('\phpbb\avatar\driver\\' . $driver, array('get_name'), array($config, $phpbb_root_path, $phpEx, $cache)); + $cur_avatar = $this->getMock('\phpbb\avatar\driver\\' . $driver, array('get_name'), array($config, $phpbb_root_path, $phpEx, $path_helper, $cache)); $cur_avatar->expects($this->any()) ->method('get_name') ->will($this->returnValue('avatar.driver.' . $driver));