There are several locations where the class hierarchy results in duplicate code. Because PHP doesn't support multiple inheritance this becomes more cumbersome than it ought to be. One option would be to use Traits to make shared code more.. shared.

An example would be the database integration for both the source and destination classes. Right now, because of the class architecture, there are copies of get_table_names(), lock_tables(), and others in both backup_migrate_destination_db and backup_migrate_source_db with the exact same code. Using a trait this could be simplified so that there would be e.g. backup_migrate_trait_db that had these methods, and the trait would be added to both of the classes - same results, but only one copy of the methods.

One obvious problem with this idea is that it would bump the module's requirements to PHP 5.4.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

DamienMcKenna created an issue. See original summary.

DamienMcKenna’s picture

Might do this in 2019..

DamienMcKenna’s picture

Status: Active » Needs review
FileSize
66.35 KB

First steps - moving the database (and MySQL) methods into shared traits.

DamienMcKenna’s picture

Thinking through it, if this is committed it would need to be in a v4 branch due to the clear drop in backwards compatibility. Given the life left in Drupal 7 I'm not sure it's worth doing it.