-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
5.3 refactoring fun-time party land #667
Conversation
- Requires the delta-zip branch on HM_Backup - Simply passes the most recent previous backup from the same schedule
- A couple of options weren't correctly specified in the docblock which means they no longer worked since WP_CLI now requires that - The --path arg conflicted with the existing WP_CLI global path arg - Removed some backup path cruft that is now handled by HMBKP_Path
It's no longer going to be a separate submodule
First bash at a major re-factor to introduce some more modern design patterns and conventions - Switches to using Namespaces (`HM\BackUpWordPress\`) instead of class prefixes - Rename some files and classes for consistency, split each class into it's own file - De-couple `Scheduled_Backup` from `Backup`, the former no longer extends the latter, instead relying on dependancy injection. - Required re-factoring several aspects of both classes so they could work together without being so tightly coupled, specifically - Correctly set `Backup` properties using the saved options in `Scheduled_Backup::__construct` - Update all calls to `Backup` methods that were being called directly through `Scheduled_Backup` relying on the fact it was a child, instead just call `Backup` directly - `Backup::do_action` now requires callbacks to be registered by the caller (which `Scheduled_Backup` has been updaed to do) - Get rid of the `Backup::set_path` && `Scheduled_Backup::set_path` methods as they were simply duplicating the functionality of `Path::set_path` - Update all tests, they all pass! - Also fixup the issue where some tests were causing each other to fail becuase they weren't properly cleaning up after themselves (see #612 (comment))
Stop including backup type and date / time in the database dump filename, it's pointless information and the fact that it caused each dump to be unique was causing issues with the delta backups
Fixed up all the major issues reported, still a ton of minor issues. |
Love this! There are a few in there that were also bothering me, others that I hadn't thought of at all...great stuff
What would be the benefit? I agree |
Instead of calling
to run a schedule. can't we just do something like
|
Yeah that would be neater although would hit the DB twice instead of once. |
I've moved all the issue over from HM Backup |
parent::set_excludes( HMBKP_EXCLUDE, true ); | ||
} | ||
// Setup The Backup class | ||
$this->backup = new Backup(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
De-couple Scheduled_Backup from Backup, the former no longer extends the latter, instead relying on dependancy injection.
As I understand it, dependency injection would require the BackUp
instance to be passed as a parameter to the constructor
public function __construct( Backup $backup ) {
$this->backup = $backup;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I ended up not doing that as I hadn't actually run into a situation where I needed to pass something different.
(One of the main reasons for dependancy injection is it means you can pass in mock objects for unit testing purposes)
Conflicts: backupwordpress.php classes/class-backupwordpress-wp-cli-command.php classes/class-path.php classes/class-requirements.php
Conflicts: classes/class-path.php
5.3 refactoring fun-time party land
First bash at a major re-factor to introduce some more modern design patterns and conventions that are available to us now we support PHP
5.3
as a minimum.What have we here?
class-backup.php
HM\BackUpWordPress\
) instead of class prefixes throughoutScheduled_Backup
fromBackup
, the former no longer extends the latter, instead relying on dependancy injection.Backup
properties using the saved options inScheduled_Backup::__construct
Backup
methods that were being called directly throughScheduled_Backup
relying on the fact it was a child, instead just callBackup
directlyBackup::do_action
now requires callbacks to be registered by the caller (whichScheduled_Backup
has been updaed to do)Backup::set_path
&&Scheduled_Backup::set_path
methods as they were simply duplicating the functionality ofPath::set_path
Other ideas
Backup
andScheduled_Backup
are both still large classes that should be modularised, some ways we could go are:get_files
, excludes, filesize stuff) into it's own classBackup_Path
andRoot_Path
both extend a base classPath
conform_dir
toPath
fromBackup
and probably rename it tonormalise
Backup_Archive
&Database_Dump
classServices
should be renamedExtensions
as that's really what they areService
should handle it's owndo_action
hooking instead of that being coupled in withScheduled_Backup::do_action
Setup
intoPlugin
.Before we merge