ChronoEngine.com homepage

Forums

Please write a review for the extension you are using on the Joomla extensions directory before posting a new question as we are being spammed by many negative reviews.

Thank you for your support!

WSOD loading a form for edit and timeout

emmexx 13 Jul, 2018
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
This topic is locked and no more replies can be posted.

2Checkout.com

2CheckOut.com Inc. (Ohio, USA) is an authorized retailer for goods and services provided by ChronoEngine.com