Skip to content

Commit

Permalink
Informs the admin if Unicode files are not writable
Browse files Browse the repository at this point in the history
Signed-off-by: Jon Stovell <[email protected]>
  • Loading branch information
Sesquipedalian committed Sep 21, 2023
1 parent 9a89607 commit 3a5db74
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
21 changes: 14 additions & 7 deletions Sources/tasks/UpdateUnicode.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 2 additions & 0 deletions Themes/default/languages/Errors.english.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.';

?>

0 comments on commit 3a5db74

Please sign in to comment.