No Code Attached Yet
avatar nikosdion
nikosdion
22 Jun 2022

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.

Steps to reproduce the issue

Expected result

Update found, no warning.

Actual result

A bunch of misleading warnings:

  • For the extension Social Magick version 1.0.2 is available, but your current database MySQL (PDO) is not supported anymore.
  • For the extension Social Magick version 1.0.1 is available, but your current database MySQL (PDO) is not supported anymore.
  • For the extension Social Magick version 1.0.0 is available, but your current database MySQL (PDO) is not supported anymore.

System information (as much as possible)

Joomla 4.1.5 on PHP 8.1 but this might be irrelevant as the issue seems to exist since #12355

Additional comments

They say a picture is worth one thousand words. I agree:
Screenshot 2022-06-22 at 09 29 03

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.

How to fix this

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.

Credits

Hat tip to the ever keen-eyed @woluweb who noticed these warnings and reported them to a repository I help with.

avatar nikosdion nikosdion - open - 22 Jun 2022
avatar joomla-cms-bot joomla-cms-bot - change - 22 Jun 2022
Title
<supported_databases> in updates XML always results in an error (which also has wrong wording).
in updates XML always results in an error (which also has wrong wording).
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 22 Jun 2022
avatar richard67
richard67 - comment - 22 Jun 2022

Ever since @richard67 introduced me to the 2-in-1 bug specials

@nikosdion When was that or what does it refer to?

avatar nikosdion
nikosdion - comment - 22 Jun 2022

@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 ?

avatar brianteeman
brianteeman - comment - 22 Jun 2022

Buy one get one free

avatar richard67
richard67 - comment - 22 Jun 2022

@nikosdion Ahh, now I remember. Will you do the PR for this issue?

avatar nikosdion
nikosdion - comment - 22 Jun 2022

@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...

avatar brianteeman
brianteeman - comment - 22 Jun 2022

"There are no bugs without u"

avatar nikosdion
nikosdion - comment - 22 Jun 2022

OMG, Brian, now I have to convince Crystal to make it into a cheesy to-shirt design!

avatar nikosdion
nikosdion - comment - 22 Jun 2022

I did the PR #38121 against Joomla 4.2 since I am adding language strings. Even though they don't need to be translated (they are product names) I believe the right way to do it is to put them in the upcoming version that's looming closer every day.

avatar richard67 richard67 - close - 22 Jun 2022
avatar richard67
richard67 - comment - 22 Jun 2022

Closing as having a pull request. See #38121 . Thanks @nikosdion .

avatar richard67 richard67 - change - 22 Jun 2022
Status New Closed
Closed_Date 0000-00-00 00:00:00 2022-06-22 11:17:54
Closed_By richard67

Add a Comment

Login with GitHub to post a comment