Skip to content

Commit

Permalink
MDL-81044 backup: Rename excluded events hook to meet style
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Feb 27, 2024
1 parent e567c21 commit 5109761
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
5 changes: 4 additions & 1 deletion backup/upgrade.txt
@@ -1,13 +1,16 @@
This files describes API changes in /backup/*,
information provided here is intended especially for developers.

=== 4.4 ===

* New \core_backup\hook\before_course_modified_check hook which can be used to exclude events from automated backup has been implemented (See MDL-73926 and MDL-81044).

=== 4.3 ===

* The function get_async_backup_links_backup has a new param of $backupid and is part of a fix to
async backups (See MDL-69983).
* During restore the function create_included_users has been updated to convert backups containing
legacy MD5 hashed passwords to the new password hashing scheme (See MDL-79134).
* New get_excluded_events hook for excluding events from automated backup has been implemented (See MDL-73926).

=== 4.1 ===

Expand Down
6 changes: 3 additions & 3 deletions backup/util/helper/backup_cron_helper.class.php
Expand Up @@ -801,15 +801,15 @@ protected static function is_course_modified($courseid, $since) {
$params = array('courseid' => $courseid, 'since' => $since);

// Exclude events defined by hook.
$hook = new \core\hook\backup\get_excluded_events();
$hook = new \core_backup\hook\before_course_modified_check();
\core\hook\manager::get_instance()->dispatch($hook);
$excludedevents = $hook->get_events();
$excludedevents = $hook->get_excluded_events();

foreach ($readers as $readerpluginname => $reader) {
$where = "courseid = :courseid and timecreated > :since and crud <> 'r'";

$excludeevents = [];
// Prevent logs of prevous backups causing a false positive.
// Prevent logs of previous backups causing a false positive.
if ($readerpluginname != 'logstore_legacy') {
$excludeevents[] = '\core\event\course_backup_created';
}
Expand Down
Expand Up @@ -14,19 +14,18 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace core\hook\backup;
namespace core_backup\hook;

use core\hook\described_hook;

/**
* Get a list of event names which are excluded to trigger from course changes in automated backup.
*
* @package core
* @package core_backup
* @copyright 2023 Tomo Tsuyuki <tomotsuyuki@catalyst-au.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
final class get_excluded_events implements described_hook {

final class before_course_modified_check implements described_hook {
/**
* @var string[] Array of event names.
*/
Expand Down Expand Up @@ -58,7 +57,7 @@ public static function get_hook_tags(): array {
* @param string[] $events Array of event name strings
* @return void
*/
public function add_events(array $events): void {
public function exclude_events(array $events): void {
$this->events = array_merge($this->events, $events);
}

Expand All @@ -68,7 +67,7 @@ public function add_events(array $events): void {
*
* @return array
*/
public function get_events(): array {
public function get_excluded_events(): array {
return $this->events;
}
}

0 comments on commit 5109761

Please sign in to comment.