From 9d7a24a411fc2a2471ae8a9acc2803cb780e47d5 Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Wed, 21 Dec 2022 11:57:09 +0000 Subject: [PATCH 1/7] [#152] tests: Prevent unit test failures when run together Options are stored as a static class variable, so need to be reset after tests to prevent knock-on effects on tests run after. --- tests/unit/custom_test.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/unit/custom_test.php b/tests/unit/custom_test.php index 2f9e830..68290d2 100644 --- a/tests/unit/custom_test.php +++ b/tests/unit/custom_test.php @@ -35,6 +35,19 @@ * @SuppressWarnings(public) Allow as many methods as needed. */ class local_datacleaner_custom_sql_test extends advanced_testcase { + + /** + * Initialise a cleaner object to reset static options. + * + * This prevents impact on other tests which assume default options. + * + * @return void + * @throws coding_exception + */ + public function tearDown(): void { + new \cleaner_custom_sql_pre\clean(['verbose' => false, 'dryrun' => false]); + } + public function test_executes_sql() { global $DB; From 16e62b455ec22f23daa439e827a73256e3b4078c Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Wed, 21 Dec 2022 14:18:54 +0000 Subject: [PATCH 2/7] [#152] lib: Replace deprecated user fields function --- cli/lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/lib.php b/cli/lib.php index d74f77d..45b5044 100644 --- a/cli/lib.php +++ b/cli/lib.php @@ -98,7 +98,7 @@ function safety_checks($dryrun) { AND u.deleted = 0"; if ($DB->count_records_sql($csql, $params)) { - $namefields = "u." . implode(', u.', get_all_user_name_fields()); + $namefields = "u." . implode(', u.', \core_user\fields::get_name_fields()); $sql = "SELECT u.id, u.username, {$namefields} FROM {user} u From dbcfb0b14ceda814dbd1a9885e1e3cb65b03ed91 Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Wed, 21 Dec 2022 14:19:08 +0000 Subject: [PATCH 3/7] [#152] users: Remove obsolete user profile fields --- cleaner/users/classes/clean.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/cleaner/users/classes/clean.php b/cleaner/users/classes/clean.php index 8fb7d0e..2596910 100644 --- a/cleaner/users/classes/clean.php +++ b/cleaner/users/classes/clean.php @@ -124,11 +124,6 @@ private static function set_fixed_fields() { 'picture' => 0, 'description' => '', 'lastip' => '', - 'icq' => '', - 'skype' => '', - 'yahoo' => '', - 'aim' => '', - 'msn' => '', 'phone1' => '', 'phone2' => '', 'idnumber' => '', From 1fac15d513a582351f420bae755d01914385caef Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Wed, 21 Dec 2022 15:48:31 +0000 Subject: [PATCH 4/7] [#152] users: Skip user changes if no users are selected --- cleaner/users/classes/clean.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cleaner/users/classes/clean.php b/cleaner/users/classes/clean.php index 2596910..368ce0d 100644 --- a/cleaner/users/classes/clean.php +++ b/cleaner/users/classes/clean.php @@ -46,6 +46,11 @@ public static function execute() { self::$idstoupdate = self::create_user_id_list_to_update(); + if (empty(self::$idstoupdate)) { + echo "No users to update.\n"; + return; + } + if (self::$options['dryrun']) { echo "Dry run mode, no records were updated.\n"; return; From e6cbf37334f1a46812b1782bda979b62d1cee9c5 Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Fri, 3 Feb 2023 10:44:50 +0000 Subject: [PATCH 5/7] [#152] Bump version and supported versions These changes only support Moodle 3.11+ --- version.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/version.php b/version.php index add61d3..588cd83 100644 --- a/version.php +++ b/version.php @@ -24,8 +24,9 @@ defined('MOODLE_INTERNAL') || die; -$plugin->version = 2021081900; -$plugin->release = '2.3.9'; +$plugin->version = 2022020300; +$plugin->release = '2.3.10'; $plugin->maturity = MATURITY_STABLE; -$plugin->requires = 2020110900; // Moodle 3.10 release and upwards. +$plugin->requires = 2021051700; // Moodle 3.11 release and upwards. +$plugin->supports = [311, 401]; $plugin->component = 'local_datacleaner'; From 18bb0be21338391bd6e144c99dfd215731be4bbd Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Fri, 3 Feb 2023 10:45:08 +0000 Subject: [PATCH 6/7] [#152] Add MOODLE_311_STABLE branch to README --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d1dffe4..06e930e 100644 --- a/README.md +++ b/README.md @@ -8,10 +8,11 @@ Moodle DataCleaner is an anonymiser of your Moodle data. The following maps the plugin version to use depending on your Moodle version. -| Moodle verion | Branch | -| ----------------- | -------------------| -| Moodle up to 3.9 | master | -| Moodle 3.10 | MOODLE_310_STABLE | +| Moodle verion | Branch | +| --------------------- | -------------------| +| Moodle up to 3.9 | master | +| Moodle 3.10 | MOODLE_310_STABLE | +| Moodle 3.11 and above | MOODLE_311_STABLE | The following maps the plugin version to use depending on your Totara version. From 75c7982c2306eff92971fc23d64f49d8b561e628 Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Fri, 3 Feb 2023 11:01:45 +0000 Subject: [PATCH 7/7] [#152] Update Github actions matrix for new stable branch --- .github/workflows/ci.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 257a37b..c82eb3a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,8 +38,14 @@ jobs: fail-fast: false matrix: include: - - { moodle-branch: 'MOODLE_310_STABLE', php: '7.4', node: '14.15.1', database: 'mariadb' } - - { moodle-branch: 'MOODLE_310_STABLE', php: '7.4', node: '14.15.1', database: 'pgsql' } + - {moodle-branch: 'MOODLE_311_STABLE', php: '7.3', node: '14.15.1', database: 'mariadb'} + - {moodle-branch: 'MOODLE_311_STABLE', php: '7.3', node: '14.15.1', database: 'pgsql'} + - {moodle-branch: 'MOODLE_400_STABLE', php: '7.3', node: '14.15.1', database: 'mariadb'} + - {moodle-branch: 'MOODLE_400_STABLE', php: '7.3', node: '14.15.1', database: 'pgsql'} + - {moodle-branch: 'MOODLE_401_STABLE', php: '7.4', node: '14.15.1', database: 'mariadb'} + - {moodle-branch: 'MOODLE_401_STABLE', php: '7.4', node: '14.15.1', database: 'pgsql'} + - {moodle-branch: 'MOODLE_401_STABLE', php: '8.0', node: '14.15.1', database: 'mariadb'} + - {moodle-branch: 'MOODLE_401_STABLE', php: '8.0', node: '14.15.1', database: 'pgsql'} steps: - name: Check out repository code @@ -58,6 +64,7 @@ jobs: php-version: ${{ matrix.php }} extensions: pgsql, zip, gd, xmlrpc, soap coverage: none + ini-values: max_input_vars=5000 - name: Initialise moodle-plugin-ci run: |