Merge branch 'ticket/13276' into ticket/13276-master

This commit is contained in:
Marc Alexander 2023-06-30 16:45:37 +02:00
commit 6049fb8fdf
No known key found for this signature in database
GPG key ID: 50E0D2423696F995
9 changed files with 17 additions and 24 deletions

View file

@ -3616,15 +3616,11 @@ function phpbb_get_avatar($row, $alt, $ignore_config = false, $lazy = false)
{ {
if ($lazy) if ($lazy)
{ {
// Determine board url - we may need it later
$board_url = generate_board_url() . '/';
// This path is sent with the base template paths in the assign_vars() // This path is sent with the base template paths in the assign_vars()
// call below. We need to correct it in case we are accessing from a // call below. We need to correct it in case we are accessing from a
// controller because the web paths will be incorrect otherwise. // controller because the web paths will be incorrect otherwise.
$phpbb_path_helper = $phpbb_container->get('path_helper'); $phpbb_path_helper = $phpbb_container->get('path_helper');
$corrected_path = $phpbb_path_helper->get_web_root_path(); $web_path = $phpbb_path_helper->get_web_root_path();
$web_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? $board_url : $corrected_path;
$theme = "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme'; $theme = "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme';
@ -3812,15 +3808,12 @@ function page_header($page_title = '', $display_online_list = false, $item_id =
$db->sql_freeresult($result); $db->sql_freeresult($result);
} }
// Determine board url - we may need it later
$board_url = generate_board_url() . '/';
// This path is sent with the base template paths in the assign_vars() // This path is sent with the base template paths in the assign_vars()
// call below. We need to correct it in case we are accessing from a // call below. We need to correct it in case we are accessing from a
// controller because the web paths will be incorrect otherwise. // controller because the web paths will be incorrect otherwise.
/* @var $phpbb_path_helper \phpbb\path_helper */ /* @var $phpbb_path_helper \phpbb\path_helper */
$phpbb_path_helper = $phpbb_container->get('path_helper'); $phpbb_path_helper = $phpbb_container->get('path_helper');
$corrected_path = $phpbb_path_helper->get_web_root_path(); $web_path = $phpbb_path_helper->get_web_root_path();
$web_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? $board_url : $corrected_path;
// Send a proper content-language to the output // Send a proper content-language to the output
$user_lang = $user->lang['USER_LANG']; $user_lang = $user->lang['USER_LANG'];
@ -3921,7 +3914,7 @@ function page_header($page_title = '', $display_online_list = false, $item_id =
'_SID' => $_SID, '_SID' => $_SID,
'SESSION_ID' => $user->session_id, 'SESSION_ID' => $user->session_id,
'ROOT_PATH' => $web_path, 'ROOT_PATH' => $web_path,
'BOARD_URL' => $board_url, 'BOARD_URL' => generate_board_url() . '/',
'PHPBB_VERSION' => PHPBB_VERSION, 'PHPBB_VERSION' => PHPBB_VERSION,
'PHPBB_MAJOR' => $phpbb_major, 'PHPBB_MAJOR' => $phpbb_major,

View file

@ -1085,7 +1085,7 @@ function smiley_text($text, $force_option = false)
} }
else else
{ {
$root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_path_helper->get_web_root_path(); $root_path = $phpbb_path_helper->get_web_root_path();
/** /**
* Event to override the root_path for smilies * Event to override the root_path for smilies

View file

@ -189,7 +189,7 @@ function generate_smilies($mode, $forum_id)
if (count($smilies)) if (count($smilies))
{ {
$root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_path_helper->get_web_root_path(); $root_path = $phpbb_path_helper->get_web_root_path();
foreach ($smilies as $row) foreach ($smilies as $row)
{ {
@ -421,7 +421,7 @@ function update_post_information($type, $ids, $return_update_sql = false)
*/ */
function posting_gen_topic_icons($mode, $icon_id) function posting_gen_topic_icons($mode, $icon_id)
{ {
global $phpbb_root_path, $config, $template, $cache; global $phpbb_root_path, $phpbb_path_helper, $config, $template, $cache;
// Grab icons // Grab icons
$icons = $cache->obtain_icons(); $icons = $cache->obtain_icons();
@ -433,7 +433,7 @@ function posting_gen_topic_icons($mode, $icon_id)
if (count($icons)) if (count($icons))
{ {
$root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_root_path; $root_path = $phpbb_path_helper->get_web_root_path();
foreach ($icons as $id => $data) foreach ($icons as $id => $data)
{ {

View file

@ -23,7 +23,7 @@ class local extends \phpbb\avatar\driver\driver
*/ */
public function get_data($row) public function get_data($row)
{ {
$root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $this->path_helper->get_web_root_path(); $root_path = $this->path_helper->get_web_root_path();
return array( return array(
'src' => $root_path . $this->config['avatar_gallery_path'] . '/' . $row['avatar'], 'src' => $root_path . $this->config['avatar_gallery_path'] . '/' . $row['avatar'],

View file

@ -100,8 +100,7 @@ class upload extends \phpbb\avatar\driver\driver
return false; return false;
} }
$use_board = defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH; $web_path = $this->path_helper->get_web_root_path();
$web_path = $use_board ? generate_board_url() . '/' : $this->path_helper->get_web_root_path();
$template->assign_vars([ $template->assign_vars([
'AVATAR_ALLOWED_EXTENSIONS' => implode(',', preg_replace('/^/', '.', $this->allowed_extensions)), 'AVATAR_ALLOWED_EXTENSIONS' => implode(',', preg_replace('/^/', '.', $this->allowed_extensions)),

View file

@ -231,8 +231,7 @@ class helper
* We need to correct the phpBB root path in case this is called from a controller, * We need to correct the phpBB root path in case this is called from a controller,
* because the web path will be incorrect otherwise. * because the web path will be incorrect otherwise.
*/ */
$board_url = defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH; $web_path = $this->path_helper->get_web_root_path();
$web_path = $board_url ? generate_board_url() . '/' : $this->path_helper->get_web_root_path();
$style_path = rawurlencode($this->user->style['style_path']); $style_path = rawurlencode($this->user->style['style_path']);
return "{$web_path}styles/{$style_path}/theme/images/no_avatar.gif"; return "{$web_path}styles/{$style_path}/theme/images/no_avatar.gif";

View file

@ -153,6 +153,11 @@ class path_helper
return $this->web_root_path; return $this->web_root_path;
} }
if (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH)
{
return $this->web_root_path = generate_board_url() . '/';
}
// We do not need to escape $path_info, $request_uri and $script_name because we can not find their content in the result. // We do not need to escape $path_info, $request_uri and $script_name because we can not find their content in the result.
// Path info (e.g. /foo/bar) // Path info (e.g. /foo/bar)
$path_info = filesystem_helper::clean_path($this->symfony_request->getPathInfo()); $path_info = filesystem_helper::clean_path($this->symfony_request->getPathInfo());

View file

@ -95,15 +95,12 @@ class icon extends AbstractExtension
$filesystem = $environment->get_filesystem(); $filesystem = $environment->get_filesystem();
$root_path = $environment->get_web_root_path(); $root_path = $environment->get_web_root_path();
$board_url = defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH;
$base_path = $board_url ? generate_board_url() . '/' : $root_path;
// Iterate over the user's styles and check for icon existance // Iterate over the user's styles and check for icon existance
foreach ($this->get_style_list() as $style_path) foreach ($this->get_style_list() as $style_path)
{ {
if ($filesystem->exists("{$root_path}styles/{$style_path}/theme/png/{$icon}.png")) if ($filesystem->exists("{$root_path}styles/{$style_path}/theme/png/{$icon}.png"))
{ {
$source = "{$base_path}styles/{$style_path}/theme/png/{$icon}.png"; $source = "{$root_path}styles/{$style_path}/theme/png/{$icon}.png";
break; break;
} }

View file

@ -155,7 +155,7 @@ class renderer implements \phpbb\textformatter\renderer_interface
/** /**
* @see smiley_text() * @see smiley_text()
*/ */
$root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $path_helper->get_web_root_path(); $root_path = $path_helper->get_web_root_path();
$this->set_smilies_path($root_path . $config['smilies_path']); $this->set_smilies_path($root_path . $config['smilies_path']);
} }