Support

Akeeba Backup for Joomla!

#35535 Table Array' doesn't exist

Posted in ‘Akeeba Backup for Joomla! 4 & 5’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Environment Information

Joomla! version
n/a
PHP version
n/a
Akeeba Backup version
n/a

Latest post by on Sunday, 22 August 2021 20:17 CDT

bindcommerce

When I start my backup, after some seconds, I read this error:

Table 'passalib_web.Array' doesn't exist SQL=SHOW COLUMNS FROM Array WHERE `Extra` = 'auto_increment' AND `Null` = 'NO'

nicholas
Akeeba Staff
Manager

Without a backup log file taken with the log level set to All Information and Debug we cannot provide any meaningful assistance.

Please make sure the log level is set to All Information and Debug, try taking a new backup and then ZIP and attach your backup log file to your next reply.

Nicholas K. Dionysopoulos

Lead Developer and Director

πŸ‡¬πŸ‡·Greek: native πŸ‡¬πŸ‡§English: excellent πŸ‡«πŸ‡·French: basic β€’ πŸ• My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

bindcommerce

Sorry, thank you. Here you are.

nicholas
Akeeba Staff
Manager

The problem comes from the table named 2021. Please exclude this table from the backup. The next version of Akeeba Backup will include a workaround.

The reason is very technical. The short explanation is that we are using Joomla's database API which has a bug only triggered when a table's name consists of only numeric characters (0 to 9).

Here's the technical explanation, for anyone interested.

We are using Joomla's database API to execute SQL statements in safe way against your database. Part of that usage is β€œquoting” table names, i.e. asking Joomla to put the table names between a pair of the database's entity quote character by calling its quoteName() method. 

However, Joomla's quoteName() method has a bug which prevents it from correctly processing table names which are numbers.

This method accepts either a string or an array. The latter allows a developer to  quote multiple table names with one function call and is a remnant of code first written about 15 years ago. These days this kind of multi-type input, multi-type output is considered a bad design but Joomla has not addressed it for backwards compatibility concerns.

The problem is in how Joomla handles the input to quoteName() to determine if it's a string or an array. It checks if the table name is a string INSTEAD OF checking if it's not an array. Well, you think, it can be either or so what's the big deal?

It turns out it is a big deal. The devil is in the details and the details in this case is how PHP works under the hood.

PHP is, at the time of this writing, a type unsafe (dynamically typed) programming language. This means that PHP variables do not have an intrinsic type. Something can be a string, a number, an array or all of the above at once. The string "2021" is, indeed, all of the above at once.

We may be passing the string "2021" but as far as PHP is concerned a string consisting entirely of numbers is a numeric value, namely an integer. Therefore the is_string() check Joomla does returns false.

Joomla then tries to handle the input (our string "2021") as an array. You'd expect that this would fail with a sensible error message. However, PHP treats all strings as arrays. Since 2021 is also a string it is also an array. Therefore Joomla iterates over the array representation of our string. This means that it gives us quoted names for four tables names 2, 0, 2, 1.

Of course we know that we are only passing strings, not arrays, in our code so we expect this to return a string. Because of Joomla's bug we get an array and this breaks the backup.

The workaround is simple enough. Instead of using Joomla's quoteName() method we will use our own which replaces the if (is_string(...)) with if (!is_array(...)). Even though PHP can access a string as an array it will NOT report its type as an array; the is_array() will return false. Therefore numeric table names will now be able to work.

Thank you for this bug report! I have been using Joomla since it was called Mambo, some 17 years ago. This is the first time I came across this weird little bug in Joomla's database code. Just when I thought I've seen it all... :D

Nicholas K. Dionysopoulos

Lead Developer and Director

πŸ‡¬πŸ‡·Greek: native πŸ‡¬πŸ‡§English: excellent πŸ‡«πŸ‡·French: basic β€’ πŸ• My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

bindcommerce

Thanks to you for the analysis!

My first CMS website (my company website) was Mambo, but I moved to Joomla one month later :)

nicholas
Akeeba Staff
Manager

You're welcome! There will be a new release on Monday which addresses this issue.

Nicholas K. Dionysopoulos

Lead Developer and Director

πŸ‡¬πŸ‡·Greek: native πŸ‡¬πŸ‡§English: excellent πŸ‡«πŸ‡·French: basic β€’ πŸ• My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

System Task
system
This ticket has been automatically closed. All tickets which have been inactive for a long time are automatically closed. If you believe that this ticket was closed in error, please contact us.

Support Information

Working hours: We are open Monday to Friday, 9am to 7pm Cyprus timezone (EET / EEST). Support is provided by the same developers writing the software, all of which live in Europe. You can still file tickets outside of our working hours, but we cannot respond to them until we're back at the office.

Support policy: We would like to kindly inform you that when using our support you have already agreed to the Support Policy which is part of our Terms of Service. Thank you for your understanding and for helping us help you!