SimpleMachines / SMF

Simple Machines Forum — SMF in short — is free and open-source community forum software, delivering professional grade features in a package that allows you to set up your own online community within minutes!
https://www.simplemachines.org/
Other
587 stars 253 forks source link

[2.1]: Multiple cron.php errors: Trying to access array offset on null; database value you're trying to insert does not exist; given array of integer values is empty #8301

Open sbulen opened 2 months ago

sbulen commented 2 months ago

Basic Information

After approving a requestable membergroup request, several errors may be logged. The background task is not processed successfully, and the task stays in the queue. Subsequent runs of cron add additional errors. Clearing the background tasks usually (not always) resolves the issues.

Errors include:

Steps to reproduce

  1. Install new forum
  2. Create a requestable user group
  3. Create a new user
  4. Logon as that new user, and request entry into the requestable user group
  5. As admin/moderator, approve the request

Users are added to the group, but the notifications are not sent. Errors are logged, and the background tasks remain in the queue.

3.0 seems to work fine!!!

Expected result

Approval completion with notification.

Actual result

Approval is completed, user is added to group, but the notification is not sent and the background tasks queue gets clogged.

Version/Git revision

2.1.4

Database Engine

All

Database Version

8.4

PHP Version

8.3.8

Logs

Background task task_data:
{"member_id":1,"member_ip":"127.0.0.1","request_list":[],"status":"approve","reason":"","time":1722785847}

Additional Information

From the forum: https://www.simplemachines.org/community/index.php?topic=589416.0 https://www.simplemachines.org/community/index.php?topic=587401.0

sbulen commented 2 months ago

The 3rd error, the empty request_list in GroupAct-Notify.php line 33, I have only seen on some fresh installs, and is difficult to reproduce. I suspect it is tied to group maintenance between the request & the approval.

The other two errors are caused by $user_info not being defined in the task. Attempting to access it produces the Logging.php line 546 error, $memIP remains not defined, so the line 559 error results on the DB call.

(Interestingly, 546 invokes the error handler, which creates a skeletal $user_info full of blanks & zeroes... I'm not sure we want the error handler to do that?)

err1 err2

sbulen commented 2 months ago

You can get slightly different errors in different versions of php, & whether or not the user has allowed email notifications.

Another common one is "2: Undefined array key "is_admin"" in Security.php, line 910. This appears to have the same root cause - undefined $user_info.

I believe 3.0 is OK because it no longer mixes globals & properties...

sbulen commented 2 months ago

You can get the empty request_list error if you delete that particular membergroup while the request is mid-process.