mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-02 08:21:09 -08:00
Fixes for the prefix-guessing and sanitizing.
This commit is contained in:
parent
70ef904951
commit
955f75f733
|
@ -214,12 +214,12 @@ class RestoreFromBackup extends Command
|
||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
if ( $this->option('prefix') ) {
|
if ( $this->option('prefix') !== null ) {
|
||||||
self::$prefix = $this->option('prefix');
|
self::$prefix = $this->option('prefix');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->option('sanitize-only')) {
|
if ($this->option('sanitize-only')) {
|
||||||
if ( !self::$prefix) {
|
if ( self::$prefix === null) {
|
||||||
print "okay, no prefix declared, we're going to GUESS IT!!!!\n";
|
print "okay, no prefix declared, we're going to GUESS IT!!!!\n";
|
||||||
self::$prefix = SQLStreamer::guess_prefix(STDIN);
|
self::$prefix = SQLStreamer::guess_prefix(STDIN);
|
||||||
print "FINAL PREFIX IS: ".self::$prefix."\n";
|
print "FINAL PREFIX IS: ".self::$prefix."\n";
|
||||||
|
@ -446,8 +446,20 @@ class RestoreFromBackup extends Command
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$sql_importer = new SQLStreamer($sql_contents, $pipes[0], self::$prefix);
|
if ( $this->option('no-sanitize')) {
|
||||||
$bytes_read = $sql_importer->line_aware_piping();
|
while (($buffer = fgets($sql_contents, self::$buffer_size)) !== false) {
|
||||||
|
$bytes_read += strlen($buffer);
|
||||||
|
// \Log::debug("Buffer is: '$buffer'");
|
||||||
|
$bytes_written = fwrite($pipes[0], $buffer);
|
||||||
|
|
||||||
|
if ($bytes_written === false) {
|
||||||
|
throw new Exception("Unable to write to pipe");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$sql_importer = new SQLStreamer($sql_contents, $pipes[0], self::$prefix);
|
||||||
|
$bytes_read = $sql_importer->line_aware_piping();
|
||||||
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
\Log::error("Error during restore!!!! ".$e->getMessage());
|
\Log::error("Error during restore!!!! ".$e->getMessage());
|
||||||
// FIXME - put these back and/or put them in the right places?!
|
// FIXME - put these back and/or put them in the right places?!
|
||||||
|
|
Loading…
Reference in a new issue