Additional error checking for scratchpads
This commit is contained in:
@@ -88,8 +88,22 @@ class syntax_plugin_luxtools_scratchpad extends SyntaxPlugin
|
||||
}
|
||||
|
||||
$text = '';
|
||||
if (@is_file($filePath) && @is_readable($filePath)) {
|
||||
$text = (string)io_readFile($filePath, false);
|
||||
$exists = @is_file($filePath);
|
||||
|
||||
// If the scratchpad file is missing, render empty content. This allows
|
||||
// creating the file via the inline editor without showing an error.
|
||||
if ($exists) {
|
||||
if (!@is_readable($filePath)) {
|
||||
$this->renderError($renderer, 'scratchpad_err_unreadable');
|
||||
return true;
|
||||
}
|
||||
|
||||
$read = io_readFile($filePath, false);
|
||||
if ($read === false) {
|
||||
$this->renderError($renderer, 'scratchpad_err_unreadable');
|
||||
return true;
|
||||
}
|
||||
$text = (string)$read;
|
||||
}
|
||||
|
||||
if ($format === 'odt') {
|
||||
|
||||
Reference in New Issue
Block a user