Hi,
We are using WP Media Folder plugin v4.2.6.
Researching the reason for a crash of our production website today we came across the following lines of php code in class-media-folder.php:
public function generatePageTree($datas, $parent = 0, $depth = 0, $limit = 0) {
if ($limit > 1000)
return '';
$tree = array();
for ($i = 0, $ni = count($datas); $i < $ni; $i++) {
if (!empty($datas[$i])) {
if ($datas[$i]->parent == $parent) {
$datas[$i]->name = $datas[$i]->name;
$datas[$i]->depth = $depth;
$tree[] = $datas[$i];
$t = $this->generatePageTree($datas, $datas[$i]->term_id, $depth + 1, $limit++);
$tree = array_merge($tree, $t);
}
}
}
return $tree;
}
The reported error message in the application log was:
PHP Warning: array_merge(): Argument #2 is not an array in /var/www/html/wp-content/plugins/wp-media-folder/class/class-media-folder.php on line 1310
PHP Fatal error: Uncaught TypeError: Argument 1 passed to Wp_Media_Folder:
arent_sort() must be of the type array, null given, called in /var/www/html/wp-content/plugins/wp-media-folder/class/class-media-folder.php on line 470 and defined in /var/www/html/wp-content/plugins/wp-media-folder/class/class-media-folder.php:1327
After changing the first line of the function above to "if ($limit > 1500)" the website started working again.
Could you please explain what is the reason behind the limit of 1000 recursive calls and how it can be avoided or increased in the best possible way (e.g. without custom changes directly in the plugin code)?
Regards,
vipteam
We are using WP Media Folder plugin v4.2.6.
Researching the reason for a crash of our production website today we came across the following lines of php code in class-media-folder.php:
public function generatePageTree($datas, $parent = 0, $depth = 0, $limit = 0) {
if ($limit > 1000)
return '';
$tree = array();
for ($i = 0, $ni = count($datas); $i < $ni; $i++) {
if (!empty($datas[$i])) {
if ($datas[$i]->parent == $parent) {
$datas[$i]->name = $datas[$i]->name;
$datas[$i]->depth = $depth;
$tree[] = $datas[$i];
$t = $this->generatePageTree($datas, $datas[$i]->term_id, $depth + 1, $limit++);
$tree = array_merge($tree, $t);
}
}
}
return $tree;
}
The reported error message in the application log was:
PHP Warning: array_merge(): Argument #2 is not an array in /var/www/html/wp-content/plugins/wp-media-folder/class/class-media-folder.php on line 1310
PHP Fatal error: Uncaught TypeError: Argument 1 passed to Wp_Media_Folder:

After changing the first line of the function above to "if ($limit > 1500)" the website started working again.
Could you please explain what is the reason behind the limit of 1000 recursive calls and how it can be avoided or increased in the best possible way (e.g. without custom changes directly in the plugin code)?
Regards,
vipteam
- Page :
- 1
There are no replies made for this post yet.