mirror of
https://github.com/processwire/processwire.git
synced 2025-08-09 00:06:55 +02:00
Add an additional check to WireDatabaseBackup so that a non-readable DB file doesn't cause a fatal exception
This commit is contained in:
@@ -49,7 +49,7 @@
|
||||
* ~~~~~
|
||||
* #pw-body
|
||||
*
|
||||
* ProcessWire 3.x, Copyright 2016 by Ryan Cramer
|
||||
* ProcessWire 3.x, Copyright 2023 by Ryan Cramer
|
||||
* https://processwire.com
|
||||
*
|
||||
*
|
||||
@@ -534,7 +534,13 @@ class WireDatabaseBackup {
|
||||
$filename = $this->sanitizeFilename($filename);
|
||||
if(!file_exists($filename)) return array();
|
||||
|
||||
$fp = fopen($filename, "r+");
|
||||
$fp = fopen($filename, 'r');
|
||||
|
||||
if($fp === false) {
|
||||
$this->error('Unable to open file for reading: ' . basename($filename));
|
||||
return array();
|
||||
}
|
||||
|
||||
$line = fgets($fp);
|
||||
if(strpos($line, self::fileHeader) === 0 || strpos($line, "# " . self::fileHeader) === 0) {
|
||||
$pos = strpos($line, '{');
|
||||
|
Reference in New Issue
Block a user