From ebd958c728b6bfe2992e7399c286d05d876454f8 Mon Sep 17 00:00:00 2001 From: 3D-I Date: Sun, 11 Aug 2019 23:19:06 +0200 Subject: [PATCH 1/5] [ticket/16080] Provide a back-trace for deleted installed style That's a very edge case, I am using the same approach done in user.php PHPBB3-16080 --- phpBB/includes/functions.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index c9f589c174..1af919b8a6 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2734,6 +2734,11 @@ function build_hidden_fields($field_ary, $specialchar = false, $stripslashes = f */ function parse_cfg_file($filename, $lines = false) { + if (!file_exists($filename)) + { + trigger_error('NO_STYLE_DATA', E_USER_ERROR); + } + $parsed_items = array(); if ($lines === false) From 1de4a65e581b43a69c7d40ad705dbf752782fcff Mon Sep 17 00:00:00 2001 From: 3D-I Date: Mon, 12 Aug 2019 00:48:04 +0200 Subject: [PATCH 2/5] [ticket/16080] Change location as it should have been. PHPBB3-16080 --- phpBB/includes/acp/acp_styles.php | 6 ++++++ phpBB/includes/functions.php | 5 ----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php index 1bf5a3c6a8..b5507005b0 100644 --- a/phpBB/includes/acp/acp_styles.php +++ b/phpBB/includes/acp/acp_styles.php @@ -1123,7 +1123,13 @@ class acp_styles */ protected function read_style_cfg($dir) { + if (!file_exists($this->styles_path . $dir . '/style.cfg')) + { + trigger_error('NO_STYLE_DATA', E_USER_ERROR); + } + static $required = array('name', 'phpbb_version', 'copyright'); + $cfg = parse_cfg_file($this->styles_path . $dir . '/style.cfg'); // Check if it is a valid file diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 1af919b8a6..c9f589c174 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2734,11 +2734,6 @@ function build_hidden_fields($field_ary, $specialchar = false, $stripslashes = f */ function parse_cfg_file($filename, $lines = false) { - if (!file_exists($filename)) - { - trigger_error('NO_STYLE_DATA', E_USER_ERROR); - } - $parsed_items = array(); if ($lines === false) From 964c212f031ef7fcbd2e95d28218007830b5d184 Mon Sep 17 00:00:00 2001 From: 3D-I Date: Mon, 12 Aug 2019 01:19:30 +0200 Subject: [PATCH 3/5] [ticket/16080] Provide a meaningful error message for deleted installed style PHPBB3-16080 --- phpBB/includes/acp/acp_styles.php | 2 +- phpBB/language/en/common.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php index b5507005b0..04cb1f15ef 100644 --- a/phpBB/includes/acp/acp_styles.php +++ b/phpBB/includes/acp/acp_styles.php @@ -1125,7 +1125,7 @@ class acp_styles { if (!file_exists($this->styles_path . $dir . '/style.cfg')) { - trigger_error('NO_STYLE_DATA', E_USER_ERROR); + trigger_error($this->user->lang['NO_STYLE_CFG'] . $dir, E_USER_WARNING); } static $required = array('name', 'phpbb_version', 'copyright'); diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 835030762c..7d8f2589e2 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -519,6 +519,7 @@ $lang = array_merge($lang, array( 'NO_FEED_ENABLED' => 'Feeds are not available on this board.', 'NO_FEED' => 'The requested feed is not available.', 'NO_STYLE_DATA' => 'Could not get style data', + 'NO_STYLE_CFG' => 'Could not get the style configuration file for: ', 'NO_SUBJECT' => 'No subject specified', // Used for posts having no subject defined but displayed within management pages. 'NO_SUCH_SEARCH_MODULE' => 'The specified search backend doesn’t exist.', 'NO_SUPPORTED_AUTH_METHODS' => 'No supported authentication methods.', From 37de0f96d1c2f52fe8702aa3638cc0f02f577a78 Mon Sep 17 00:00:00 2001 From: 3D-I Date: Mon, 12 Aug 2019 21:14:58 +0200 Subject: [PATCH 4/5] [ticket/16080] Use placeholder PHPBB3-16080 --- phpBB/includes/acp/acp_styles.php | 3 ++- phpBB/language/en/common.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php index 04cb1f15ef..123c8f0ad4 100644 --- a/phpBB/includes/acp/acp_styles.php +++ b/phpBB/includes/acp/acp_styles.php @@ -1123,9 +1123,10 @@ class acp_styles */ protected function read_style_cfg($dir) { + // This should never happen, we give them a red warning because of its relevance. if (!file_exists($this->styles_path . $dir . '/style.cfg')) { - trigger_error($this->user->lang['NO_STYLE_CFG'] . $dir, E_USER_WARNING); + trigger_error(sprintf($this->user->lang['NO_STYLE_CFG'], $dir), E_USER_WARNING); } static $required = array('name', 'phpbb_version', 'copyright'); diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 7d8f2589e2..26692c7b25 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -519,7 +519,7 @@ $lang = array_merge($lang, array( 'NO_FEED_ENABLED' => 'Feeds are not available on this board.', 'NO_FEED' => 'The requested feed is not available.', 'NO_STYLE_DATA' => 'Could not get style data', - 'NO_STYLE_CFG' => 'Could not get the style configuration file for: ', + 'NO_STYLE_CFG' => 'Could not get the style configuration file for: %s', 'NO_SUBJECT' => 'No subject specified', // Used for posts having no subject defined but displayed within management pages. 'NO_SUCH_SEARCH_MODULE' => 'The specified search backend doesn’t exist.', 'NO_SUPPORTED_AUTH_METHODS' => 'No supported authentication methods.', From 78f0ec8ea75504f53192612ba4f904bc00fd32d2 Mon Sep 17 00:00:00 2001 From: 3D-I Date: Tue, 13 Aug 2019 20:54:49 +0200 Subject: [PATCH 5/5] [ticket/16080] Remove sprintf() PHPBB3-16080 --- phpBB/includes/acp/acp_styles.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php index 123c8f0ad4..5029510839 100644 --- a/phpBB/includes/acp/acp_styles.php +++ b/phpBB/includes/acp/acp_styles.php @@ -1126,7 +1126,7 @@ class acp_styles // This should never happen, we give them a red warning because of its relevance. if (!file_exists($this->styles_path . $dir . '/style.cfg')) { - trigger_error(sprintf($this->user->lang['NO_STYLE_CFG'], $dir), E_USER_WARNING); + trigger_error($this->user->lang('NO_STYLE_CFG', $dir), E_USER_WARNING); } static $required = array('name', 'phpbb_version', 'copyright');