Buy Now
Sign in

WSOD loading a form for edit and timeout

emmexx , July 13 at 09:48
E
emmexx
A form I'm working on started giving me a WSOD when I opened it to edit.
 Fatal error: Maximum execution time of 30 seconds exceeded in
/.../public_html/libraries/cegcore2/helpers/data_loader.php on
line 148
Other simpler forms open as usual.
I doubled the max_executiion_time parameter in php.ini but it is not always possible to change it (it depends on the server or the host).
This is the culprit code:
 private function textarea(&$html){​
​ //textarea fields​
​ $pattern = '/<textarea([^>]*?)>(.*?)<\/textarea>/is';​
​ preg_match_all($pattern, $html, $matches);​
​ ​
​ if(!empty($matches)){​
​ foreach($matches[0] as $field){​
​ if(strpos($field, 'data-ghost=') !== false){​
​ continue;​
​ }​
​ ​
​ preg_match($this->name_pattern, $field, $name_attr);​
​ if(!empty($name_attr[2])){​
​ $field_name = $name_attr[2];​
​ $data_value = $this->getValue($field_name);​
​ ​
​ if($data_value !== false){​
​ $updated_field = preg_replace($this->textarea_pattern, '${1}'.str_replace(['\\', '$'], ['\\\\', '\$'], $data_value).'${4}', $field);​
​ $html = str_replace($field, $updated_field, $html); // <<<---​
​ }​
​ }​
​ }​
​ }​
​ }
I don't understand how a str_replace function could exceed 30 seconds substituting text on some element of a form.
The form loaded as expected until 2 or 3 days ago so probably something was changed by a sysadmin on that server but I suspect there's something else here.
bye
maxx
E
emmexx
My apologies, I didn't see a previous thread about the same problem: https://www.chronoengine.com/forums/posts/t103673/max-execution-error-when-form-gets-large
maxx