At least in MySQL, the Backup and Migrate module completely ignores database query errors when it tries to restore. In one case, I had a problem where it unzipped a gzipped archive that was corrupted, attempted to run about 2000+ queries, and they all failed. But the module still reported that it had successfully restored my database.

When I looked in the dblog, it showed me that there were 2000+ errors.

This is the code from 6.x that needs to be updated (it's in includes/destinations.db.mysql.inc in method _restore_db_from_file()):

 $line = trim($line);
 if ($line) {
   // Use the helper instead of the api function to avoid substitution of '{' etc.
   _db_query($line);
   $num++;
 }

It should be something more like this:

        $line = trim($line);
        if ($line) {
          // Use the helper instead of the api function to avoid substitution of '{' etc.
          if (!_db_query($line)) {
            trigger_error(check_plain("Database error running query " . $line));
            return FALSE;
          }
          $num++;
        }
      }
 

It looks as though 7.x would have the same problem, since the corresponding code (same exact function name in same file) just runs ->execute() on the query line, and doesn't check for any errors, as far as I can tell.

Comments

ronan’s picture

Assigned: Unassigned » ronan

Agreed. I'll work on this next chance I get.

couturier’s picture

Issue summary: View changes
Status: Active » Postponed (maintainer needs more info)

Can anyone verify if @ronan has fixed this with the release of 7.x-3.2?

couturier’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

Closing after more than two weeks with no activity.

ivnish’s picture

Assigned: ronan » Unassigned