Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-39444 get_string: remove unnecessary clean_param

This clean_param was added as part of MDL-22015. It is a good idea when
developer debug is turned on, but it showed up as a surprisingly
expensive cost in our profiling.

This change:

1. Removes the check during string_extist. This will not change
behaviour, the method returns false if the string does not exist.

2. In get_string, it only does the check if debugging is set to
DEVELOPER level.
  • Loading branch information...
commit 0dc15de222e9910b545c97e4f93503a539dc1265 1 parent c6be138
@timhunt timhunt authored
Showing with 2 additions and 11 deletions.
  1. +2 −11 lib/moodlelib.php
View
13 lib/moodlelib.php
@@ -6645,10 +6645,6 @@ public function load_component_strings($component, $lang, $disablecache=false, $
* @return boot true if exists
*/
public function string_exists($identifier, $component) {
- $identifier = clean_param($identifier, PARAM_STRINGID);
- if (empty($identifier)) {
- return false;
- }
$lang = current_language();
$string = $this->load_component_strings($component, $lang);
return isset($string[$identifier]);
@@ -7130,10 +7126,6 @@ public function load_component_strings($component, $lang, $disablecache=false, $
* @return boot true if exists
*/
public function string_exists($identifier, $component) {
- $identifier = clean_param($identifier, PARAM_STRINGID);
- if (empty($identifier)) {
- return false;
- }
// simple old style hack ;)
$str = get_string($identifier, $component);
return (strpos($str, '[[') === false);
@@ -7391,8 +7383,7 @@ function get_string($identifier, $component = '', $a = NULL, $lazyload = false)
return new lang_string($identifier, $component, $a);
}
- $identifier = clean_param($identifier, PARAM_STRINGID);
- if (empty($identifier)) {
+ if (debugging('', DEBUG_DEVELOPER) && clean_param($identifier, PARAM_STRINGID) === '') {
throw new coding_exception('Invalid string identifier. The identifier cannot be empty. Please fix your get_string() call.');
}
@@ -11236,7 +11227,7 @@ protected function get_string() {
// Check if we need to process the string
if ($this->string === null) {
// Check the quality of the identifier.
- if (clean_param($this->identifier, PARAM_STRINGID) == '') {
+ if (debugging('', DEBUG_DEVELOPER) && clean_param($this->identifier, PARAM_STRINGID) === '') {
throw new coding_exception('Invalid string identifier. Most probably some illegal character is part of the string identifier. Please check your string definition');
}
Please sign in to comment.
Something went wrong with that request. Please try again.