Cannot load long term data from Web UI

The issue I am facing:
When trying to load the long term data I get the following error:

An unknown error occurred while loading the data.

Check the server's log files (/var/log/lighttpd/error-pihole.log) for details.

You may need to increase PHP memory limit.

You can find more info in pi-hole's FAQ:
FAQ - Pi-hole documentation

Also the Web UI is bugged (see screenshot attached): it does not show all data such as temperature, it does not show the page's footer in the homepage (it does in other pages), and it does not show any of the blocked data.

PiHole is correctly blocking ads.

Debug Token: https://tricorder.pi-hole.net/RbUsADtw/

Contents of /var/log/lighttpd/error-pihole.log:

2023-12-17 00:00:20: server.c.1787) logfiles cycled UID = 0 PID = 28355
2023-12-17 16:03:50: server.c.1976) server stopped by UID = 0 PID = 1
2023-12-17 16:04:59: server.c.1513) server started (lighttpd/1.4.59)
2023-12-17 16:06:58: mod_fastcgi.c.487) FastCGI-stderr:PHP Warning:  Use of undefined constant SQLITE3_OPEN_READONLY - assumed 'SQLITE3_OPEN_READONLY' (this will throw an Error in a future version of PHP) in /var/www/html/admin/scripts/pi-hole/php/database.php on line 57
2023-12-17 16:06:58: mod_fastcgi.c.487) FastCGI-stderr:PHP Fatal error:  Uncaught Error: Class 'SQLite3' not found in /var/www/html/admin/scripts/pi-hole/php/database.php:42
2023-12-17 16:06:58: mod_fastcgi.c.487) FastCGI-stderr:Stack trace:
2023-12-17 16:06:58: mod_fastcgi.c.487) FastCGI-stderr:#0 /var/www/html/admin/scripts/pi-hole/php/database.php(60): SQLite3_connect_try()
2023-12-17 16:06:58: mod_fastcgi.c.487) FastCGI-stderr:#1 /var/www/html/admin/scripts/pi-hole/php/gravity.php(14): SQLite3_connect()
2023-12-17 16:06:58: mod_fastcgi.c.487) FastCGI-stderr:#2 /var/www/html/admin/index.php(66): gravity_last_update()
2023-12-17 16:06:58: mod_fastcgi.c.487) FastCGI-stderr:#3 {main}
2023-12-17 16:06:58: mod_fastcgi.c.487) FastCGI-stderr:  thrown in /var/www/html/admin/scripts/pi-hole/php/database.php on line 42

Details about my system:
Raspberry Pi Zero W, running Raspberry Pi OS.

What I have changed since installing Pi-hole:
Nothing, however the issue persists even after making a fresh install of PiHole.

  • Tried following the instructions in the PiHole documentation linked in the error, but to no avail. Nothing changed.

Looks like your PHP installation is missing a module (not installed or disabled):

2023-12-19 14:40:54: mod_fastcgi.c.487) FastCGI-stderr:PHP Warning:  Use of undefined constant SQLITE3_OPEN_READONLY - assumed 'SQLITE3_OPEN_READONLY' (this will throw an Error in a future version of PHP) in /var/www/html/admin/scripts/pi-hole/php/database.php on line 57
2023-12-19 14:40:54: mod_fastcgi.c.487) FastCGI-stderr:PHP Fatal error:  Uncaught Error: Class 'SQLite3' not found in /var/www/html/admin/scripts/pi-hole/php/database.php:42

Try to install the module using this command:

sudo apt install php-sqlite3

I ran the suggested command and got this:

sudo apt install php-sqlite3
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
php-sqlite3 is already the newest version (2:7.4+76).
0 upgraded, 0 newly installed, 0 to remove and 104 not upgraded.

Anything else I can try?

Can you please generate a new debug log?

The previous one is not available any more (logs are deleted after 48 hours).

Of course, here it is:

https://tricorder.pi-hole.net/JKrgFiGE/

Thank you for any further help.

Your PHP issue seems to be fixed, but now you have 2 different small issues:

  1. Your /etc/pihole/versions file is empty or corrupted:
    Run pihole updatechecker to recreate the file and pihole -v to check the versions.

  2. your database has integrity issues:

    *** [ DIAGNOSING ]: Pi-hole FTL Query Database
    -rw-rw-r-- 1 pihole pihole 4.7M Jan  1 09:31 /etc/pihole/pihole-FTL.db
    [i] Checking integrity of /etc/pihole/pihole-FTL.db ... (this can take several minutes)
    [✗] Integrity errors in /etc/pihole/pihole-FTL.db found.
    
        *** in database main ***
        Tree 727 page 727: btreeInitPage() returns error code 11
        Tree 725 page 725: btreeInitPage() returns error code 11
        Tree 700 page 700: btreeInitPage() returns error code 11
        Tree 697 page 697: btreeInitPage() returns error code 11
        Tree 698 page 698: btreeInitPage() returns error code 11
        Tree 698 page 2 cell 0: Child page depth differs
        Tree 726 page 726: btreeInitPage() returns error code 11
        Page 21: never used
        Page 22: never used
        Page 23: never used
        ... # similar lines ommited
        Page 158: never used
    

    The easiest way to fix this is to move the current database and Pi-hole will create a new one:

    Run these commands to move the existing database to a new file name and restart Pi-hole.

    sudo service pihole-FTL stop
    
    sudo mv /etc/pihole/pihole-FTL.db /etc/pihole/pihole-FTL-old.db
    
    sudo service pihole-FTL start
    

NOTE:
If you keep seeing file corruption in your system, it could mean your SD card is too old or defective and you will need to replace it.

I did everything you mentioned and I think the second thing is fixed, the first thing however seems to be problematic still.
When I run pihole updatechecker and pihole -v I get the following:

pi@raspberrypi:~ $ pihole updatechecker

/etc/pihole/versions: line 1: $'\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377CORE_VERSION=v5.17.2': command not found

/etc/pihole/versions: line 1: $'\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377CORE_VERSION=v5.17.2': command not found
pi@raspberrypi:~ $ pihole -v

/etc/pihole/versions: line 1: $'\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377CORE_VERSION=v5.17.2': command not found

/opt/pihole/version.sh: 1: /etc/pihole/versions: ?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????CORE_VERSION=v5.17.2: File name too long

Pi-hole version is v5.17.2 (Latest: v5.17.2)

web version is v5.21 (Latest: v5.21)

FTL version is v5.23 (Latest: v5.23)

Here's a debug log generated after doing what you last recommended:

https://tricorder.pi-hole.net/WbUtEuBf/

Your versions file is starting with a lot of strange characters and this caused the errors you saw:

-rw-r--r-- 1 root root 663 Jan  1 20:49 /etc/pihole/versions
   ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������CORE_VERSION=v5.17.2
   CORE_BRANCH=master
   CORE_HASH=60b6a101
   GITHUB_CORE_VERSION=v5.17.2
   GITHUB_CORE_HASH=60b6a101
   WEB_VERSION=v5.21
   WEB_BRANCH=master
   WEB_HASH=be05b0f6
   GITHUB_WEB_VERSION=v5.21
   GITHUB_WEB_HASH=be05b0f6
   FTL_VERSION=v5.23
   FTL_BRANCH=master
   FTL_HASH=d201776e
   GITHUB_FTL_VERSION=v5.23
   GITHUB_FTL_HASH=1a114133
   CORE_VERSION=v5.17.2

You can try to delete /etc/pihole/versions and run pihole updatechecker again.

I'm not sure what is causing this issue, but I'm starting to suspect you have a bad SD card and this is causing file corruption all over the place.

Thank you for all your help.
I did what you suggested and it seems to have worked however my main issue still remains.

I understand if you think it's my SD in which case, I will change it and do a fresh install but I thought I'd leave one last debug log just in case, so here it is:

https://tricorder.pi-hole.net/eY1eOIf8/

Your log is showing PHP issues again, related to sqlite3 module:

2024-01-02 09:35:00: mod_fastcgi.c.487) FastCGI-stderr:PHP Warning:  Use of undefined constant SQLITE3_OPEN_READONLY 

Did you install or update something else? Maybe there is another installation process removing PHP modules (or you really have an issue with your SD card).

What is the output of apt list php-sqlite3 ?

This is what I see here:

root@pihole:/# apt list php-sqlite3
Listing... Done
php-sqlite3/oldstable,now 2:7.4+76 all [installed]

The version information may be different, depending on the OS and PHP version, but it should show [installed].

I didn't install or update anything, my output is as follows:

pi@raspberrypi:~ $ apt list php-sqlite3 
Listing... Done
php-sqlite3/oldstable,now 2:7.4+76 all [installed]

This is really making little to no sense

Solved by doing:

apt purge php-{cgi,curl,fpm,gd,mbstring,sqlite3,xml,zip}
apt purge 'php7.4-*'
apt autoremove --purge
pihole reconfigure
repair

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.