h5p / h5p-wordpress-plugin

Adds support for H5P Content in WordPress.
https://wordpress.org/plugins/h5p/
70 stars 75 forks source link

Bug out of memory on version 1.15.6 #151

Closed vietguitar closed 9 months ago

vietguitar commented 1 year ago

320957290_8800457653312692_556752672779275351_n

icc commented 1 year ago

This seems to be related to the changes in #133 We probably want to avoid running this if there are no $user_ids

Does anyone want to make a PR for this?

otacke commented 1 year ago

@vietguitar How would $user_ids ever be empty? It could be an empty array, but that's not an issue for array_unique. You might want to leave more context for that screenshot if you want someone to be able to reproduce and fix the issue: What were you doing as a user when this happend, the exact PHP error message that you found, etc.

boonebgorges commented 1 year ago

I'm unsure of how $user_ids would ever be empty, but the reporter is correct that if it's an empty array, get_users() will fetch all users. This could definitely cause memory issues on certain installations.

A simple fix (though perhaps a stopgap if the empty $user_ids indicates a separate bug) is to add a block above the get_users() call similar to the one that appears below it:

if ( empty( $user_ids ) ) {
  return $results;
}
ir4klis commented 1 year ago

I'm unsure of how $user_ids would ever be empty

An example that demonstrates this behavior is when a user attempts to access user activity for items that have no user activity recorded yet.

This bug is really stealthy since it may go unnoticed on small or moderately-sized installations, as it can be temporarily "masked" by raising PHP memory limits.
However, on significantly larger installations, it would always result in OOM errors for items with empty user activity.

Rel. files: