From 3a5db74076b759b66d7d8c77d0fa9b697cd1b6f7 Mon Sep 17 00:00:00 2001 From: Jon Stovell Date: Wed, 20 Sep 2023 19:31:31 -0600 Subject: [PATCH] Informs the admin if Unicode files are not writable Signed-off-by: Jon Stovell --- Sources/tasks/UpdateUnicode.php | 21 ++++++++++++++------- Themes/default/languages/Errors.english.php | 2 ++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Sources/tasks/UpdateUnicode.php b/Sources/tasks/UpdateUnicode.php index 62602e5ec9b..516a57a9ce5 100644 --- a/Sources/tasks/UpdateUnicode.php +++ b/Sources/tasks/UpdateUnicode.php @@ -433,20 +433,27 @@ public function execute() foreach ($this->funcs as $func_name => &$func_info) { - $file_paths['temp'] = implode(DIRECTORY_SEPARATOR, array($this->temp_dir, $func_info['file'])); + $file_paths['final'] = implode(DIRECTORY_SEPARATOR, array($this->unicodedir, $func_info['file'])); - if (!file_exists($file_paths['temp'])) - touch($file_paths['temp']); + if (!file_exists($file_paths['final'])) + touch($file_paths['final']); - if (!is_file($file_paths['temp'])) + if (!is_file($file_paths['final']) || !smf_chmod($file_paths['final'])) { - log_error($file_paths['temp'] . ' is not a file.'); + loadLanguage('Errors'); + log_error(sprintf($txt['unicode_update_failed'], $this->unicodedir)); return true; } - if (!smf_chmod($file_paths['temp'])) + $file_paths['temp'] = implode(DIRECTORY_SEPARATOR, array($this->temp_dir, $func_info['file'])); + + if (!file_exists($file_paths['temp'])) + touch($file_paths['temp']); + + if (!is_file($file_paths['temp']) || !smf_chmod($file_paths['temp'])) { - log_error($file_paths['temp'] . ' is not writable.'); + loadLanguage('Errors'); + log_error(sprintf($txt['unicode_update_failed'], $this->temp_dir)); return true; } diff --git a/Themes/default/languages/Errors.english.php b/Themes/default/languages/Errors.english.php index 6745a1b0d95..174c214ebaa 100644 --- a/Themes/default/languages/Errors.english.php +++ b/Themes/default/languages/Errors.english.php @@ -522,4 +522,6 @@ $txt['fetch_web_data_bad_url'] = 'fetch_web_data(): Bad URL'; +$txt['unicode_update_failed'] = 'A new version of Unicode is available, but SMF could not update to it. Please make sure %1$s is writable. SMF will try to update its Unicode data files again automatically.'; + ?> \ No newline at end of file