Hey PHX team. I was doing some exploratory things with AI and came across a potential bug for Ultimate SEO URLS as some of my crons were crashing and pointing to USU as a potential culprit....Here's our findings...
Bug #1 — Unguarded fetchArray() on false in /includes/apps/ultimate_seo_urls/main/usu_main.php
What happens: In extractCacheData() under case $cache_type == 'sqlite':, the code runs:
$result = $object->getDb()->query( $query );
$row = $result->fetchArray();
Why it's a bug: When the SQLite database is locked by another process, $object->getDb()->query($query) returns false. Calling $result->fetchArray() on false throws a Fatal Error (Uncaught Error: Call to a member function fetchArray() on false) in PHP 8+.
How the developer should fix it: Check if ( !($result instanceof SQLite3Result) ) { return true; } before calling $result->fetchArray().
Bug #2 — Missing busyTimeout() and VACUUM Collision in /includes/apps/ultimate_seo_urls/cache_system/sqlite.php
What happens: createDatabase() instantiates self::$db = new SQLite3( self::$sqlite_db_file ); without setting self::$db->busyTimeout(5000); (so SQLite fails immediately on any concurrent access), and gc() runs self::$db->query('VACUUM'); on live requests (Warning: SQLite3::query(): cannot VACUUM - SQL statements in progress).
Bug #3 — $cache_on Left null on Non-Module Pages in /includes/apps/ultimate_seo_urls/cache_system/sqlite.php:
What happens: In Sqlite_Cache_Module::i(), self::$cache_on is only assigned inside the if (... instanceof aPage_Modules) branch. In the else branch (any page or script without a USU page module), self::$cache_on remains null. Later, store() and retrieve() check if ( false !== self::$cache_on )—which evaluates to true when self::$cache_on is null, forcing USU to read and write cache rows even when USU_CACHE_ON is set to 'False'!
These were potential issues causing cron jobs to crash when cache system was set to sqlite. I've changed to mysql for the cache system.
