Download & Extend

backup and migrate php 5.4 compatibility

Project:Backup and Migrate
Version:6.x-2.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:curiosity26
Status:fixed
Issue tags:PHP 5.4

Issue Summary

After I updated the php on my Drupal site to 5.4 all these warnings popped up.
Here is the strict warning messages:

  • strict warning: Declaration of backup_migrate_filter_backup_restore::backup_settings_form_submit() should be compatible with backup_migrate_filter::backup_settings_form_submit($form, &$form_state) in /var/www/html/test_site/sites/all/modules/backup_migrate/includes/filters.backup_restore.inc on line 169.
  • strict warning: Declaration of backup_migrate_filter_backup_restore::backup() should be compatible with backup_migrate_filter::backup($file, $settings) in /var/www/html/test_site/sites/all/modules/backup_migrate/includes/filters.backup_restore.inc on line 169.
  • strict warning: Declaration of backup_migrate_filter_backup_restore::restore() should be compatible with backup_migrate_filter::restore($file, $settings) in /var/www/html/test_site/sites/all/modules/backup_migrate/includes/filters.backup_restore.inc on line 169.
  • strict warning: Declaration of backup_migrate_filter_compression::restore() should be compatible with backup_migrate_filter::restore($file, $settings) in /var/www/html/test_site/sites/all/modules/backup_migrate/includes/filters.compression.inc on line 288.
  • strict warning: Declaration of backup_migrate_filter_encryption::restore() should be compatible with backup_migrate_filter::restore($file, $settings) in /var/www/html/test_site/sites/all/modules/backup_migrate/includes/filters.encryption.inc on line 176.
  • strict warning: Non-static method backup_migrate_destination::create() should not be called statically in /var/www/html/test_site/sites/all/modules/backup_migrate/includes/destinations.inc on line 193.
  • strict warning: Non-static method backup_migrate_destination::create() should not be called statically in /var/www/html/test_site/sites/all/modules/backup_migrate/includes/destinations.inc on line 193.
  • strict warning: Non-static method backup_migrate_destination::create() should not be called statically in /var/www/html/test_site/sites/all/modules/backup_migrate/includes/destinations.inc on line 193.
  • strict warning: Non-static method backup_migrate_destination::create() should not be called statically in /var/www/html/test_site/sites/all/modules/backup_migrate/includes/destinations.inc on line 193.
  • strict warning: Declaration of backup_migrate_destination_db_mysql::_unlock_tables() should be compatible with backup_migrate_destination_db::_unlock_tables($tables) in /var/www/html/test_site/sites/all/modules/backup_migrate/includes/destinations.db.mysql.inc on line 288.
  • strict warning: Non-static method backup_migrate_destination::create() should not be called statically in /var/www/html/test_site/sites/all/modules/backup_migrate/includes/destinations.inc on line 193.

Comments

#1

Version:6.x-2.5» 6.x-2.6

I just got the same set of warnings.
I am using php 5.4.3.
I just installed Backup and Migrate.
I've seen a similar problem with the Filefield module (http://drupal.org/node/1728248).

#2

From reading similar issues on othe rmodules I don't expect this to be fixed in D6. I'm using PHP 5.3 on my D6 sites.

#3

Is there a secret to switching back and forth between php versions? Every time that I try, my apache is too new, so I change apache, change php, and then my site crashes and nothing works until I switch everything back.
Thanks

#4

I have no problem for Drupal switching PHP versions back and forth. If you can't find what's going wrong you should open a new thread in the forum or support mailing list and provide more info on what's happening.

#5

Thanks, I'm just going to upgrade to d7.

#6

Assigned to:Anonymous» curiosity26
Status:active» needs review

I ran into this issue too. Unfortunately, I can't just up and migrate all my sites to Drupal 7, so I thought I would just issue this fix. It's actually very simple. PHP 5.4 gets a huge performance boost by enforcing that the programmer handles their own argument definitions and class extension conformity. If the function defined in a base class has a parameter passed by reference, all functions thereafter must also pass that parameter by reference, and vice versa. Also, if a function takes x parameters, giving it x + n parameters in an extended definition will result in an error. Instead, use func_get_args and pull the arguments off the end. If you want to pass these extended args by reference, pass in the data wrapped in a stdClass. As of PHP 5, objects are always passed by ref.

Anyway, I've isolated the files that have the issue. I use MySQL so if you use pg or ms, you might still get an error in the db connector include. I just zipped the whole module because it's much easier.

AttachmentSize
backup_migrate.zip 93.04 KB

#7

Sorry, guys. Use this version. I missed the issue with statically calling backup_migrate_destination::create. This is fixed in this version.

AttachmentSize
backup_migrate.zip 92.98 KB

#8

Do you know if this can be merged into the 6 branch of Backup and Migrate ?
I would need this patch, but I prefer to stick to "official branches" ?

Thanks for your reply.

#9

The file I posted was for D6, btw. I haven't submitted an official patch yet. I'm still fumbling with tracing a few hanging issues. The fix above silences the errors from the original post, as well as many other errors. But there's still an issue with cron and scheduled backups. The array of schedules seems to fall out. There's also an issue with certain admin forms showing up. I think the two issues might be somewhat related. As soon as I get an initial working version, I plan on submitting to the official channels for proper review.

#10

Works good. Thanks!

#11

Status:needs review» patch (to be ported)

Still a few things with the newest version that doesn't comply in php 5.4. Invalid static function call on backup_migrate_destination::create() is the initial culprit. The rest is inconsistent class function extensions with pass by reference parameters. This patch fixes them. Tested. Hope this cures what ails ya!

PS. I use mysql so I only made updates to destinations.db.inc in the includes directory. There might be some errors popup if you use S3 or some other db. Easy fix though.

AttachmentSize
backup-migrate-php5.4-compay-1514072-11.patch 162.16 KB

#12

After applying #11 I get

Fatal error: Cannot redeclare backup_migrate_destination_files::get_file() in

Should I apply #7 first then #11?

#13

In includes/destinations.inc changing the function create to a static function will cause problems. Instead what I tried was to change the call from a static one to a non static one by creating an instance of the class backup_migrate_destination;

on line 192, this code :

<?php
function backup_migrate_create_destination($destination_type, $params = array()) {
 
$params['type'] = $destination_type;
  return
backup_migrate_destination::create($params);
}
?>

should be changed to this :

<?php
function backup_migrate_create_destination($destination_type, $params = array()) {
 
$params['type'] = $destination_type;
 
$destination = new backup_migrate_destination;
  return
$destination->create($params);
}
?>

It seems to be working for me. Warnings are gone and I am still able to do backups whereas I couldn't if declared static.

#14

Version:6.x-2.6» 6.x-2.x-dev
Status:patch (to be ported)» fixed

I was unable to reproduce the errors, but I backported the backup_migrate_create_destination function from the d7 version so hopefully this is fixed for everybody now.