Ever since @richard67 introduced me to the 2-in-1 bug specials I only find this kind of bugs. This morning we will see that an update with <supported_databases>
always results in an error and the error message is misleading.
<supported_databases>
in its XML update file, e.g. https://github.com/lucid-fox/social-magick/releases/download/1.0.1/socialmagick-1.0.1.zipUpdate found, no warning.
A bunch of misleading warnings:
Joomla 4.1.5 on PHP 8.1 but this might be irrelevant as the issue seems to exist since #12355
They say a picture is worth one thousand words. I agree:
In libraries/src/Updater/Adapter/ExtensionAdapter.php:159 we are trying to see if the site's database connector object's $dbType
(all lowercase) matches one of the keys of the $supportedDbs
array. However, the keys in the $supportedDbs
array are upppercase. Therefore we will never match a database type...
This is bug number one.
We then display the JLIB_INSTALLER_AVAILABLE_UPDATE_DB_MINIMUM message but instead of reporting the database server type (e.g. MySQL) we report the database connector name (e.g. MySQLi or PDO MySQL). This causes the asinine and misleading messages sampled above.
This is bug number two.
For the first bug change line 159 from
if (\array_key_exists($dbType, $supportedDbs))
to
if (in_array(strtolower($dbType), array_map('strtolower', array_keys($supportedDbs))))
For the second bug, change lines 167 to 174 from
$dbMsg = Text::sprintf(
'JLIB_INSTALLER_AVAILABLE_UPDATE_DB_MINIMUM',
$this->currentUpdate->name,
$this->currentUpdate->version,
Text::_($db->name),
$dbVersion,
$minimumVersion
);
to
$dbMsg = Text::sprintf(
'JLIB_INSTALLER_AVAILABLE_UPDATE_DB_MINIMUM',
$this->currentUpdate->name,
$this->currentUpdate->version,
Text::_('JLIB_DB_SERVER_TYPE_' . $dbType),
$dbVersion,
$minimumVersion
);
and create the lang strings JLIB_DB_SERVER_TYPE_MARIADB, JLIB_DB_SERVER_TYPE_MYSQL, JLIB_DB_SERVER_TYPE_POSTGRESQL, JLIB_DB_SERVER_TYPE_ORACLE, JLIB_DB_SERVER_TYPE_SQLITE, JLIB_DB_SERVER_TYPE_MSSQL which are far cleaner than the existing, unprefixed ones.
Hat tip to the ever keen-eyed @woluweb who noticed these warnings and reported them to a repository I help with.
Title |
|
||||||
Labels |
Added:
No Code Attached Yet
|
@richard67 A few weeks ago, when I stumbled into a bug while fixing another. It was an off-hand comment but now everything I do, I stumble into these 2-bugs-for-1 specials
Buy one get one free
@nikosdion Ahh, now I remember. Will you do the PR for this issue?
@richard67 Yup! Let me upgrade a few sites I was too dead tired to upgrade last night and then I'm on it.
@brianteeman An idea for a new t-shirt is slowly forming in my head...
"There are no bugs without u"
OMG, Brian, now I have to convince Crystal to make it into a cheesy to-shirt design!
Closing as having a pull request. See #38121 . Thanks @nikosdion .
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2022-06-22 11:17:54 |
Closed_By | ⇒ | richard67 |
@nikosdion When was that or what does it refer to?