File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -169,13 +169,19 @@ public function clear_log_data() {
169
169
* @return string Error constant name.
170
170
*/
171
171
private function preg_error_message ( $ error ) {
172
- $ constants = get_defined_constants ( true );
173
- if ( ! array_key_exists ( 'pcre ' , $ constants ) ) {
174
- return '<unknown error> ' ;
172
+ static $ error_names = null ;
173
+
174
+ if ( null === $ error_names ) {
175
+ $ definitions = get_defined_constants ( true );
176
+ $ pcre_constants = array_key_exists ( 'pcre ' , $ definitions )
177
+ ? $ definitions ['pcre ' ]
178
+ : array ();
179
+ $ error_names = array_flip ( $ pcre_constants );
175
180
}
176
181
177
- $ names = array_flip ( $ constants ['pcre ' ] );
178
- return isset ( $ names [ $ error ] ) ? $ names [ $ error ] : '<unknown error> ' ;
182
+ return isset ( $ error_names [ $ error ] )
183
+ ? $ error_names [ $ error ]
184
+ : '<unknown error> ' ;
179
185
}
180
186
}
181
187
You can’t perform that action at this time.
0 commit comments