Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent misleading warning being printed to the lighttpd error log when importing from teleporter backup #2118

Merged
merged 1 commit into from
Feb 12, 2022

Conversation

PromoFaux
Copy link
Member

By submitting this pull request, I confirm the following:

  • I have read and understood the contributors guide, as well as this entire template.
  • I have made only one major change in my proposed changes.
  • I have commented my proposed changes within the code.
  • I have tested my proposed changes, and have included unit tests where possible.
  • I am willing to help maintain this change if there are issues with it later.
  • I give this submission freely and claim no ownership.
  • It is compatible with the EUPL 1.2 license
  • I have squashed any insignificant commits. (git rebase)

What does this PR aim to accomplish?:

Fixes #2117 by adding a check for table name before attempting to flush it

@PromoFaux PromoFaux requested a review from a team February 12, 2022 12:29
@yubiuser
Copy link
Member

yubiuser commented Feb 12, 2022

As I've been asked:
Rather then specify exactly which tables to ignore, skip the flush if the table does not exists.
https://stackoverflow.com/questions/1601151/how-do-i-check-in-sqlite-whether-a-table-exists

@PromoFaux PromoFaux force-pushed the supress-invalid-warnings branch from c8200e2 to 0d066ce Compare February 12, 2022 13:33
@PromoFaux
Copy link
Member Author

FP'd new code, tested by using adding some error logging into it as below:

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

Which outputs:

2022-02-12 13:31:15: mod_fastcgi.c.487) FastCGI-stderr:doing adlist
2022-02-12 13:31:15: mod_fastcgi.c.487) FastCGI-stderr:doing adlist_by_group
2022-02-12 13:31:15: mod_fastcgi.c.487) FastCGI-stderr:not doing blacklist
2022-02-12 13:31:15: mod_fastcgi.c.487) FastCGI-stderr:not doing regex_blacklist
2022-02-12 13:31:15: mod_fastcgi.c.487) FastCGI-stderr:doing client
2022-02-12 13:31:15: mod_fastcgi.c.487) FastCGI-stderr:doing client_by_group
2022-02-12 13:31:15: mod_fastcgi.c.487) FastCGI-stderr:doing domain_audit
2022-02-12 13:31:15: mod_fastcgi.c.487) FastCGI-stderr:doing domainlist_by_group
2022-02-12 13:31:15: mod_fastcgi.c.487) FastCGI-stderr:doing group
2022-02-12 13:31:15: mod_fastcgi.c.487) FastCGI-stderr:not doing whitelist
2022-02-12 13:31:15: mod_fastcgi.c.487) FastCGI-stderr:not doing regex_whitelist

scripts/pi-hole/php/teleporter.php Outdated Show resolved Hide resolved
scripts/pi-hole/php/teleporter.php Outdated Show resolved Hide resolved
@PromoFaux PromoFaux force-pushed the supress-invalid-warnings branch from 0d066ce to e9e85e4 Compare February 12, 2022 13:39
@PromoFaux PromoFaux requested a review from yubiuser February 12, 2022 13:39
…en attempting to flush tables that don't actually exist

Signed-off-by: Adam Warner <me@adamwarner.co.uk>
@PromoFaux PromoFaux force-pushed the supress-invalid-warnings branch from e9e85e4 to edfcf45 Compare February 12, 2022 13:40
@PromoFaux PromoFaux merged commit c394d4c into devel Feb 12, 2022
@PromoFaux PromoFaux deleted the supress-invalid-warnings branch February 12, 2022 13:43
@PromoFaux PromoFaux linked an issue Feb 12, 2022 that may be closed by this pull request
@pralor-bot
Copy link

This pull request has been mentioned on Pi-hole Userspace. There might be relevant details there:

https://discourse.pi-hole.net/t/pi-hole-ftl-v5-14-web-v5-11-and-core-v5-9-released/53529/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Warnings in lighttpd error log when using teleporter
3 participants