aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Schramm <oliver.schramm97@gmail.com>2017-09-22 13:03:14 +0200
committerOliver Schramm <oliver.schramm97@gmail.com>2017-09-22 13:03:14 +0200
commit27ae01c27a99b0f0674ad4f0e82f1b018365926d (patch)
tree9505bed6715467abc184f4c2f541d1844e066633
parentd095e620c1b36d68206139c082881b32a5f6a6e6 (diff)
downloadforums-27ae01c27a99b0f0674ad4f0e82f1b018365926d.tar
forums-27ae01c27a99b0f0674ad4f0e82f1b018365926d.tar.gz
forums-27ae01c27a99b0f0674ad4f0e82f1b018365926d.tar.bz2
forums-27ae01c27a99b0f0674ad4f0e82f1b018365926d.tar.xz
forums-27ae01c27a99b0f0674ad4f0e82f1b018365926d.zip
[ticket/15245] Fix images in feeds when accessing via app.php
PHPBB3-15245
-rw-r--r--phpBB/config/default/container/services_feed.yml1
-rw-r--r--phpBB/phpbb/feed/helper.php19
-rw-r--r--tests/feed/attachments_base_test.php11
3 files changed, 23 insertions, 8 deletions
diff --git a/phpBB/config/default/container/services_feed.yml b/phpBB/config/default/container/services_feed.yml
index d3e7924f2f..b7ef1f9b6d 100644
--- a/phpBB/config/default/container/services_feed.yml
+++ b/phpBB/config/default/container/services_feed.yml
@@ -18,6 +18,7 @@ services:
class: phpbb\feed\helper
arguments:
- '@config'
+ - '@path_helper'
- '@user'
- '%core.root_path%'
- '%core.php_ext%'
diff --git a/phpBB/phpbb/feed/helper.php b/phpBB/phpbb/feed/helper.php
index e15d1e131e..2d9a623895 100644
--- a/phpBB/phpbb/feed/helper.php
+++ b/phpBB/phpbb/feed/helper.php
@@ -21,6 +21,9 @@ class helper
/** @var \phpbb\config\config */
protected $config;
+ /** @var \phpbb\path_helper */
+ protected $path_helper;
+
/** @var \phpbb\user */
protected $user;
@@ -33,14 +36,16 @@ class helper
/**
* Constructor
*
- * @param \phpbb\config\config $config Config object
- * @param \phpbb\user $user User object
- * @param string $phpbb_root_path Root path
- * @param string $phpEx PHP file extension
+ * @param \phpbb\config\config $config Config object
+ * @param \phpbb\path_helper $path_helper Path helper object
+ * @param \phpbb\user $user User object
+ * @param string $phpbb_root_path Root path
+ * @param string $phpEx PHP file extension
*/
- public function __construct(\phpbb\config\config $config, \phpbb\user $user, $phpbb_root_path, $phpEx)
+ public function __construct(\phpbb\config\config $config, \phpbb\path_helper $path_helper, \phpbb\user $user, $phpbb_root_path, $phpEx)
{
$this->config = $config;
+ $this->path_helper = $path_helper;
$this->user = $user;
$this->phpbb_root_path = $phpbb_root_path;
$this->phpEx = $phpEx;
@@ -113,7 +118,7 @@ class helper
$content = str_replace('<br />', '<br />' . "\n", $content);
// Convert smiley Relative paths to Absolute path, Windows style
- $content = str_replace($this->phpbb_root_path . $this->config['smilies_path'], $this->get_board_url() . '/' . $this->config['smilies_path'], $content);
+ $content = str_replace($this->path_helper->get_web_root_path() . $this->config['smilies_path'], $this->get_board_url() . '/' . $this->config['smilies_path'], $content);
// Remove "Select all" link and mouse events
$content = str_replace('<a href="#" onclick="selectCode(this); return false;">' . $this->user->lang['SELECT_ALL_CODE'] . '</a>', '', $content);
@@ -152,7 +157,7 @@ class helper
$content .= implode('<br />', $post_attachments);
// Convert attachments' relative path to absolute path
- $content = str_replace($this->phpbb_root_path . 'download/file.' . $this->phpEx, $this->get_board_url() . '/download/file.' . $this->phpEx, $content);
+ $content = str_replace($this->path_helper->get_web_root_path() . 'download/file.' . $this->phpEx, $this->get_board_url() . '/download/file.' . $this->phpEx, $content);
}
// Remove Comments from inline attachments [ia]
diff --git a/tests/feed/attachments_base_test.php b/tests/feed/attachments_base_test.php
index dd432d13f5..f5c79bd6b4 100644
--- a/tests/feed/attachments_base_test.php
+++ b/tests/feed/attachments_base_test.php
@@ -31,13 +31,22 @@ class phpbb_feed_attachments_base_test extends phpbb_database_test_case
$this->filesystem = new \phpbb\filesystem();
$config = new \phpbb\config\config(array());
+ $path_helper = new \phpbb\path_helper(
+ new \phpbb\symfony_request(
+ new phpbb_mock_request()
+ ),
+ new \phpbb\filesystem\filesystem(),
+ $this->getMock('\phpbb\request\request'),
+ $phpbb_root_path,
+ 'php'
+ );
$user = new \phpbb\user(
new \phpbb\language\language(
new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)
),
'\phpbb\datetime'
);
- $feed_helper = new \phpbb\feed\helper($config, $user, $phpbb_root_path, $phpEx);
+ $feed_helper = new \phpbb\feed\helper($config, $path_helper, $user, $phpbb_root_path, $phpEx);
$db = $this->new_dbal();
$cache = new \phpbb_mock_cache();
$auth = new \phpbb\auth\auth();