Skip to content

Commit 3daf99f

Browse files
authored
Merge pull request #153 from marxjohnson/152-moodle-401-fixes
Fixes for Moodle 4.1 compatibility
2 parents f579016 + 75c7982 commit 3daf99f

File tree

6 files changed

+37
-15
lines changed

6 files changed

+37
-15
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,14 @@ jobs:
3838
fail-fast: false
3939
matrix:
4040
include:
41-
- { moodle-branch: 'MOODLE_310_STABLE', php: '7.4', node: '14.15.1', database: 'mariadb' }
42-
- { moodle-branch: 'MOODLE_310_STABLE', php: '7.4', node: '14.15.1', database: 'pgsql' }
41+
- {moodle-branch: 'MOODLE_311_STABLE', php: '7.3', node: '14.15.1', database: 'mariadb'}
42+
- {moodle-branch: 'MOODLE_311_STABLE', php: '7.3', node: '14.15.1', database: 'pgsql'}
43+
- {moodle-branch: 'MOODLE_400_STABLE', php: '7.3', node: '14.15.1', database: 'mariadb'}
44+
- {moodle-branch: 'MOODLE_400_STABLE', php: '7.3', node: '14.15.1', database: 'pgsql'}
45+
- {moodle-branch: 'MOODLE_401_STABLE', php: '7.4', node: '14.15.1', database: 'mariadb'}
46+
- {moodle-branch: 'MOODLE_401_STABLE', php: '7.4', node: '14.15.1', database: 'pgsql'}
47+
- {moodle-branch: 'MOODLE_401_STABLE', php: '8.0', node: '14.15.1', database: 'mariadb'}
48+
- {moodle-branch: 'MOODLE_401_STABLE', php: '8.0', node: '14.15.1', database: 'pgsql'}
4349

4450
steps:
4551
- name: Check out repository code
@@ -58,6 +64,7 @@ jobs:
5864
php-version: ${{ matrix.php }}
5965
extensions: pgsql, zip, gd, xmlrpc, soap
6066
coverage: none
67+
ini-values: max_input_vars=5000
6168

6269
- name: Initialise moodle-plugin-ci
6370
run: |

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ Moodle DataCleaner is an anonymiser of your Moodle data.
88

99
The following maps the plugin version to use depending on your Moodle version.
1010

11-
| Moodle verion | Branch |
12-
| ----------------- | -------------------|
13-
| Moodle up to 3.9 | master |
14-
| Moodle 3.10 | MOODLE_310_STABLE |
11+
| Moodle verion | Branch |
12+
| --------------------- | -------------------|
13+
| Moodle up to 3.9 | master |
14+
| Moodle 3.10 | MOODLE_310_STABLE |
15+
| Moodle 3.11 and above | MOODLE_311_STABLE |
1516

1617
The following maps the plugin version to use depending on your Totara version.
1718

cleaner/users/classes/clean.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ public static function execute() {
4646

4747
self::$idstoupdate = self::create_user_id_list_to_update();
4848

49+
if (empty(self::$idstoupdate)) {
50+
echo "No users to update.\n";
51+
return;
52+
}
53+
4954
if (self::$options['dryrun']) {
5055
echo "Dry run mode, no records were updated.\n";
5156
return;
@@ -124,11 +129,6 @@ private static function set_fixed_fields() {
124129
'picture' => 0,
125130
'description' => '',
126131
'lastip' => '',
127-
'icq' => '',
128-
'skype' => '',
129-
'yahoo' => '',
130-
'aim' => '',
131-
'msn' => '',
132132
'phone1' => '',
133133
'phone2' => '',
134134
'idnumber' => '',

cli/lib.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ function safety_checks($dryrun) {
9898
AND u.deleted = 0";
9999

100100
if ($DB->count_records_sql($csql, $params)) {
101-
$namefields = "u." . implode(', u.', get_all_user_name_fields());
101+
$namefields = "u." . implode(', u.', \core_user\fields::get_name_fields());
102102

103103
$sql = "SELECT u.id, u.username, {$namefields}
104104
FROM {user} u

tests/unit/custom_test.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,19 @@
3535
* @SuppressWarnings(public) Allow as many methods as needed.
3636
*/
3737
class local_datacleaner_custom_sql_test extends advanced_testcase {
38+
39+
/**
40+
* Initialise a cleaner object to reset static options.
41+
*
42+
* This prevents impact on other tests which assume default options.
43+
*
44+
* @return void
45+
* @throws coding_exception
46+
*/
47+
public function tearDown(): void {
48+
new \cleaner_custom_sql_pre\clean(['verbose' => false, 'dryrun' => false]);
49+
}
50+
3851
public function test_executes_sql() {
3952
global $DB;
4053

version.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@
2424

2525
defined('MOODLE_INTERNAL') || die;
2626

27-
$plugin->version = 2021081900;
28-
$plugin->release = '2.3.9';
27+
$plugin->version = 2022020300;
28+
$plugin->release = '2.3.10';
2929
$plugin->maturity = MATURITY_STABLE;
30-
$plugin->requires = 2020110900; // Moodle 3.10 release and upwards.
30+
$plugin->requires = 2021051700; // Moodle 3.11 release and upwards.
31+
$plugin->supports = [311, 401];
3132
$plugin->component = 'local_datacleaner';

0 commit comments

Comments
 (0)