• Hello AAM Team, I’m experiencing a PHP warning with the latest version of AAM (7.0.11) on PHP 8.2:

    Error Message: Warning: Attempt to read property “post_status” on null in /wp-content/plugins/advanced-access-manager/application/Service/Content.php on line 792

    Environment: – AAM Version: 7.0.11 (updated 6 days ago) – PHP Version: 8.2.x (recommended by hosting provider Infomaniak) – WordPress: [6.9]

    Root Cause: In the _map_edit_post_caps() method (line 792), get_post($post_id) returns null in some cases, but the code attempts to access $post->post_status without checking if $post is a valid object first.

    Current Code: php private function _map_edit_post_caps($caps, $post_id) { $post = get_post($post_id); $is_draft = $post->post_status === 'auto-draft'; // ← Fails when $post is null // ... }

    Suggested Fix: php private function _map_edit_post_caps($caps, $post_id) { $post = get_post($post_id); if (!$post || !is_object($post)) { return $caps; } $is_draft = $post->post_status === 'auto-draft'; // ... rest of the code }

    PHP 8.2 is stricter about null safety than previous versions, so this type of check is now necessary. Could you please include this fix in the next update? Thank you for your excellent plugin!

    Best regards

Viewing 1 replies (of 1 total)
  • Plugin Support Vasyl Martyniuk

    (@mvb_wordpress)

    @yg1958 thank you for the report. Indeed. It is possible when get_post function returns null if post does not exist. We are going to address this in the next AAM release.

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.