Support

Akeeba Backup for Joomla!

#28158 issue when backed up site has new_ as prefix

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 Wednesday, 23 August 2017 17:17 CDT

woluweb
Hi,

Just to share you an information about an unwanted side-effect when reinstalling a .jpa file of a site where database prefix was "new_".

During installation, I had asked for changing database prefix from the original (new_) to something different (say abc_).

After installation, I noticed some weird behaviours in backend.
Example : the redirections components would not work as intended, ...

Then I went to see the database and I saw that in com_redirect the Name of the Column had also been changed (new_ being replaced by abc_, explaining why the backend was not working correctly).

So it seems that when a user changes prefix of a database during installation, that change is not only done for database prefix, but also in Table Columns (and maybe everywhere in fact, I have not tested further).

[ nothing urgent for me as I have corrected manually, but I wanted to let you know about what seems to be a bug ]

nicholas
Akeeba Staff
Manager
This is something that happens at backup time, not at restoration time.

First, a list of all tables (and database entities, if you have so chosen) is generated. This list has the original entity names, e.g. new_redirect_links.

This list is then processed and a mapping between the real (original) entity names and the abstract Joomla!-style entity names -e.g. new_redirect_links to #__redirect_links- is created. Basically we create a mapping between table names and a notation which allows us to replace their prefixes.

Then we process the CREATE command of every table, view, procedure etc, replacing the original table names with their abstract versions.

Unfortunately, this is NOT enough. Newer versions of the Joomla! CMS as well as third party extensions use named table indices, using the database table name prefix. If we do not address that the restoration WILL fail if you are restoring to the same database as the original site (since you cannot have two named indices with the same name under the same database). So we have to blindly replace `new_ with `#__. This also matches columns names which begin with the same string as the database prefix INCLUDING the underscore.

Considering the frequency of each eventuality (restoring to the same database vs using a misguided prefix like old_, new_, created_, modified_, asset_, vgroup_ etc) we have concluded that the former happens several thousands of times more frequently than the latter. Therefore we have to keep the blind replace. The other option would be writing a SQL parser which, to the best of my knowledge, nobody has managed to do in PHP in a way that's actually usable in a generic way and does not require manual intervention on every tenth table.

So, basically, you draw the short straw. You have to change the prefix of all your tables and their indices manually before taking a backup. And never, ever, EVER use the prefix old_ or new_ again. Just like bak_ and #__ it has special meaning and causes all sorts of trouble. Use a random four to five character prefix instead. Not less, not more and don't use non-random words.

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!

woluweb
Txs a lot for the detailed explanation Nicholas.

So it is more a feature than a bug :)

At least now I am aware that prefixes like new_ have side-effects and should not be used :)
Actually, I always choose random.
The reason why I chose "new_" on this occasion was that their hosting Cy would only allow 1 database and I had to duplicate the site.
So I wanted something more explicit than "5dhf"...

Maybe just an idea to avoid others to face the same issue : why not having a warning about those "dangerous prefixes" when akeeba sees that such a prefix is used
- when taking a backup
- or when changing the prefix when installing a site
then suggesting to first change prefix with Admin Tools for example :-)

OK, just a suggestion, you will see better than me the pros/cons.

nicholas
Akeeba Staff
Manager
Maybe just an idea to avoid others to face the same issue : why not having a warning about those "dangerous prefixes" when akeeba sees that such a prefix is used


Because in eleven and a half years spanning over twenty eight thousand tickets and three thousand emails we had exactly one issue report. Yours. You drew the short straw. Sorry.

Also, it's not a closed set. If the prefix matches the beginning of a row name you get a conflict. We do warn about bak_ and #__ which some people do use and had reports about at backup time. In fact, we will refuse to take a backup of these tables because they will definitely cause a restoration issue.

Very marginal and EXTREMELY uncommon cases are neither documented not warned about. Yours is such a case. The case of having a comment which contains valid (but commented out) SQL code inside a procedure on the same line as a non-comment SQL statement is another. The thing is, these issues affect less than 0.01% of our clients, making it unappealing to address them.

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!

woluweb
OK, very fine for me :-)
I was not aware I was the first one in the world to choose "new_" when duplicating a website :-D

Happy to be unique
But indeed, if it is that rare, then forget about it, I fully agree ;)

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!