mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 04:22:07 +02:00
MDL-76362 core: plugin names must be strings to be valid
This commit is contained in:
parent
d08319ddf7
commit
a1f4f7bac5
@ -970,10 +970,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -255,6 +255,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