e107inc / e107

e107 Bootstrap CMS (Content Management System) v2 with PHP, MySQL, HTML5, jQuery and Twitter Bootstrap. Issue Discussion Room: https://gitter.im/e107inc/e107
https://e107.org
GNU General Public License v3.0
322 stars 214 forks source link

PM plugin fatal error in PHP 8.2 #4998

Closed Jimmi08 closed 1 year ago

Jimmi08 commented 1 year ago

Bug Description

When you send PM without attachment

Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in ***plugins\pm\pm_class.php:283 Stack trace: #0 ***plugins\pm\pm.php(672): private_message->add(Array) #1 ***plugins\pm\pm.php(869): pm_extended->post_pm() #2 {main} thrown in***plugins\pm\pm_class.php on line 283

This line: $this->pm_send_notify($vars['to_info']['user_id'], $vars, $pmid, count($a_list));

$vars['uploaded'] is not set

Vodhin commented 1 year ago

It seems that the foreach($array) function in versions of PHP after 7.5 fail if the array is empty, missing, or null. Try setting your PHP version to 7.5 (I have not had any luck running anything e107 on PHP versions newer than 7.5 at all)

Jimmi08 commented 1 year ago

@Vodhin Thanks for advice but it is not point of creating issues :)

Deltik commented 1 year ago

Fixed by https://github.com/e107inc/e107/pull/5006