Backup error #9
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-thirtybees/tbupdater#9
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
While updating on my Windows localhost the software ends with the following error message when it starts making a backup:
Error when trying to add C:xampphtdocs_webshop4AdapterAdapter_AddressFactory.php to archive C:xampphtdocs_webshop4AdapterAdapter_AddressFactory.php.
For some reason the slashes between "xampp" and "htdocs" and between the directory and the filename have disappeared.
This failed upgrade left my webshop with a new very big backup table. I saw no alternative but to delete it before trying upgrading with manual backup only.
After some research I came to the conclusion that very likely the entry into the database is at least part of the problem.
Tbupdater first collects the filenames (with path) that need to be backed up. It them puts them into the database in the table tb_tbupdater_files_for_backup. And it then retrieves them from that table for the actual archiving..
My suspicion is that those filenames with path are not escaped and that as a consequence those backslashes are interpreted as escapes by MySQL. In the array $files in Backup::addFiles the backslashes are still present. Inside the database they are no longer there.
Unfortunately the code is too cryptic for me to find a remedy.
Thanks for the extra info. Those are some great clues we can use to figure it out. Thanks for your help!
I noted that I had put my next comments in another thread (https://github.com/thirtybees/thirtybees/issues/374#issuecomment-337756137).
The counter is now on 5 bugs in backup of which I solved four. My next one has to do with the database backup (so file backup works). Database backup stops due to a javascript error: Uncaught TypeError: Cannot read property 'nextQuickInfo' of null at Object.success (upgrader.js:484)
The improved code for Backup::addFiles is
` public static function addFiles(array $files)
{
foreach ($files as &$item) {
$item = ['file' => Db::getInstance()->escape($item)];
}
Note that this includes two bug fixes. The escape of the filename and sending $chunk instead of $files to the database.
The other two fixed bugs are in AjaxProcessor.php. I will list them later:
The database backup error gives me a headache. Maybe someone else knows more about what is happening here.
The javascript error is caused by a kind of crash. That is: the ajax ends returning nothing - yet that is interpreted by upgrader.js as a success. The error follows when it cannot find the fields that it expects.
The silent end happens during the query in AjaxProcessor.php that starts on line 731:
$data = $this->db->executeS( (new DbQuery()) ->select('*') ->from($table) ->limit((int) $backupLoopLimit, 200), true, false );To find out what goes wrong here I put some debug code in Db.php in the function Db::executeS(). To prevent it from being triggered during earlier calls to this function I used a global flag that I only set just before the relevant code.
A var_dump of the query delivered the following:
object(TbUpdaterModule\DbQuery)#69 (1) { ["query":protected]=> array(8) { ["select"]=> array(1) { [0]=> string(1) "*" } ["from"]=> array(1) { [0]=> string(14) "tb_tb_access" } ["join"]=> array(0) { } ["where"]=> array(0) { } ["group"]=> array(0) { } ["having"]=> array(0) { } ["order"]=> array(0) { } ["limit"]=> array(2) { ["offset"]=> int(200) ["limit"]=> int(0) } }}What looks interesting here is "
tb_tb_access". It looks like an extra prefix is set before the table name. Yet the query in AjaxProcessor.php is called with the correct "tb_access".Does anyone who knows the database functions what is going wrong here?
How stupid can you get?
The function Db::displayError() in the tbupdater module displays its error messages with Tools::displayError(). Unfortunately this function does nothing to display the messages so that they disappear in the void.
It is already very puzzling that this module contains its own version of the TB classes. That these have such a low quality is even more puzzling. Not being able to display error messages is about as low as you can get.
It would seem to me logical to at least keep things parallel. So for all those classes that the TBupdater contains it should always use a copy of the latest version of TB itself.
I wrote a little report of what should be changed in the tbupdater module. I need to stop working on it as other issues need my attention. Due to the way Github maltreats code inside the text I have attached a text file.
If the proposed modifications are implemented the module should be able to finish when you don't disable the backup option. However, there is still a bug in the backup database section as it will overwrite itself. The code should be stored in filename.sql.bz2, filename-2.sql.bz2, filename-3.sql.bz2, etc. However, there is a bug so that it always uses the same filename so that it overwrites previous parts and only the last part of the backup is saved.
Another issue that needs attention is that this is the only module that is Composer based. As a consequence it uses old versions of the main TB classes. I believe this Composer shell should be removed so that we don't have duplicate code that is hard to maintain.
tpupdater-changes.txt
The problem with the database backup files is in the function initializeFiles() in AjaxPrrocessor.php on line 2560.
You find there the line
$this->backupDbFilename = 'auto-backupdb_'.$this->backupName.'.sql';This should be
$this->backupDbFilename = 'auto-backupdb_XXXXXX_'.$this->backupName.'.sql';The missing of the XXXX part causes that on 645 no file numbers are inserted and the files overwrite each other.
Ahhh great find. Thanks!
Something has gone wrong. In version 1.25 all the improvements of 1.24 have been discarded.
Well, module tbupdater is in the process of getting abandoned in favor of Core Updater. Currently needed only for updating modules.
Which means, tbupdater won't receive bug fixes any more.