mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 12:40:01 +01:00
MDL-76362 core: plugin names must be strings to be valid
This commit is contained in:
parent
e068f2284f
commit
93ab932211
@ -1001,10 +1001,9 @@ $cache = '.var_export($cache, true).';
|
||||
}
|
||||
// Modules MUST NOT have any underscores,
|
||||
// component normalisation would break very badly otherwise!
|
||||
return (bool)preg_match('/^[a-z][a-z0-9]*$/', $pluginname);
|
||||
|
||||
return !is_null($pluginname) && (bool) preg_match('/^[a-z][a-z0-9]*$/', $pluginname);
|
||||
} else {
|
||||
return (bool)preg_match('/^[a-z](?:[a-z0-9_](?!__))*[a-z0-9]+$/', $pluginname ?? '');
|
||||
return !is_null($pluginname) && (bool) preg_match('/^[a-z](?:[a-z0-9_](?!__))*[a-z0-9]+$/', $pluginname);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -257,6 +257,12 @@ class component_test extends advanced_testcase {
|
||||
[['tool', '_example'], false],
|
||||
[['tool', 'example_'], false],
|
||||
[['tool', 'example__x1'], false],
|
||||
|
||||
// Some invalid cases.
|
||||
[['mod', null], false],
|
||||
[['mod', ''], false],
|
||||
[['tool', null], false],
|
||||
[['tool', ''], false],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user