Potential bug on Ultimate SEO URLs

If it doesn't quite fit in the other areas, put it here...
Blaine
Posts: 8
Joined: Wed Mar 12, 2025 1:46 pm
Phoenix Version:

Potential bug on Ultimate SEO URLs

Post by Blaine »

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.



Join The Code Co-op to get access to your library in the Code Co-op Forum
User avatar
burt
Core Team
Posts: 4916
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 296 times
Been thanked: 493 times

Re: Potential bug on Ultimate SEO URLs

Post by burt »




Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply