mirror of
https://github.com/processwire/processwire.git
synced 2025-08-10 16:54:44 +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
|
* #pw-body
|
||||||
*
|
*
|
||||||
* ProcessWire 3.x, Copyright 2016 by Ryan Cramer
|
* ProcessWire 3.x, Copyright 2023 by Ryan Cramer
|
||||||
* https://processwire.com
|
* https://processwire.com
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
@@ -179,12 +179,12 @@ class WireDatabaseBackup {
|
|||||||
// find and replace in row data (not supported by exec/mysql method)
|
// find and replace in row data (not supported by exec/mysql method)
|
||||||
'findReplace' => array(
|
'findReplace' => array(
|
||||||
// Example: 'databass' => 'database'
|
// Example: 'databass' => 'database'
|
||||||
),
|
),
|
||||||
|
|
||||||
// find and replace in create table statements (not supported by exec/mysql)
|
// find and replace in create table statements (not supported by exec/mysql)
|
||||||
'findReplaceCreateTable' => array(
|
'findReplaceCreateTable' => array(
|
||||||
// Example: 'DEFAULT CHARSET=latin1;' => 'DEFAULT CHARSET=utf8;',
|
// Example: 'DEFAULT CHARSET=latin1;' => 'DEFAULT CHARSET=utf8;',
|
||||||
),
|
),
|
||||||
|
|
||||||
// EXEC MODE IS CURRRENTLY EXPERIMENTAL AND NOT RECOMMEND FOR USE YET
|
// EXEC MODE IS CURRRENTLY EXPERIMENTAL AND NOT RECOMMEND FOR USE YET
|
||||||
// if true, we will try to use mysql via exec first (faster). if false, we won't attempt that.
|
// if true, we will try to use mysql via exec first (faster). if false, we won't attempt that.
|
||||||
@@ -218,7 +218,7 @@ class WireDatabaseBackup {
|
|||||||
'dbPath' => '', // optional mysql/mysqldump path on file system
|
'dbPath' => '', // optional mysql/mysqldump path on file system
|
||||||
'dbSocket' => '',
|
'dbSocket' => '',
|
||||||
'dbCharset' => 'utf8',
|
'dbCharset' => 'utf8',
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array of text indicating details about what methods were used (primarily for debugging)
|
* Array of text indicating details about what methods were used (primarily for debugging)
|
||||||
@@ -534,7 +534,13 @@ class WireDatabaseBackup {
|
|||||||
$filename = $this->sanitizeFilename($filename);
|
$filename = $this->sanitizeFilename($filename);
|
||||||
if(!file_exists($filename)) return array();
|
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);
|
$line = fgets($fp);
|
||||||
if(strpos($line, self::fileHeader) === 0 || strpos($line, "# " . self::fileHeader) === 0) {
|
if(strpos($line, self::fileHeader) === 0 || strpos($line, "# " . self::fileHeader) === 0) {
|
||||||
$pos = strpos($line, '{');
|
$pos = strpos($line, '{');
|
||||||
|
Reference in New Issue
Block a user