Skip to content

Commit

Permalink
Merge pull request #2118 from pi-hole/supress-invalid-warnings
Browse files Browse the repository at this point in the history
Prevent misleading warning being printed to the lighttpd error log when importing from teleporter backup
  • Loading branch information
PromoFaux authored Feb 12, 2022
2 parents d9ad678 + edfcf45 commit c394d4c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions scripts/pi-hole/php/teleporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,15 @@ function archive_restore_table($file, $table, $flush=false)
if(is_null($contents))
return 0;

// Flush table if requested, only flush each table once
// Flush table if requested. Only flush each table once, and only if it exists
if($flush && !in_array($table, $flushed_tables))
{
$db->exec("DELETE FROM \"".$table."\"");
array_push($flushed_tables, $table);
$tableExists = $db->querySingle("SELECT name FROM sqlite_master WHERE type='table' AND name='".$table."';");
if ($tableExists)
{
$db->exec("DELETE FROM \"".$table."\"");
array_push($flushed_tables, $table);
}
}

// Prepare fields depending on the table we restore to
Expand Down

0 comments on commit c394d4c

Please sign in to comment.