• Hi there,

    I’ve identified a reproducible PHP warning in the current version of the Subscribe to Comments Reloaded plugin, specifically when handling subscription links for posts that no longer exist.

    The issue:

    When a user tries to manage their subscription using a link that includes an invalid or deleted post ID via the srp parameter (e.g., after a site rebuild or content cleanup), the following PHP warnings are thrown:

    PHP Warning:  Trying to access array offset on value of type null in wp_subscribe_reloaded.php on line 1780
    PHP Warning: Attempt to read property "post_content" on null in wp_subscribe_reloaded.php on line 1780

    How to reproduce:

    1. Visit a link like this (valid structure, but invalid post ID):
    https://yoursite.com/gerir-subscricoes/?srp=123456&srk=xyz&sra=s&srsrc=f

    If the post ID (srp) doesn’t correspond to an existing post, the plugin tries to access $data[0]->post_content even though $data is null.

    Root cause:

    The method management_page_sc() assumes that $this->subscribe_reloaded_manage() will always return a valid array containing post data. But if the post ID is invalid or deleted, the return is null, and trying to access [0]->post_content causes the warning.

    Suggested fix:

    Inside the management_page_sc() function (around line 1780), consider adding a safety check like:

    public function management_page_sc() {
    $data = $this->subscribe_reloaded_manage();

    if ( isset($data[0]) && isset($data[0]->post_content) ) {
    return $data[0]->post_content;
    }

    return '<p>' . __( 'The subscription link is not valid or the original post has been removed.', 'subscribe-to-comments-reloaded' ) . '</p>';
    }

    This will prevent the PHP warnings and provide a better user experience in the case of outdated or broken subscription links.

    Thanks for your great work on this plugin — I hope this helps make it even more robust in future versions!

    Best regards,
    Ângelo Antunes

The topic ‘PHP Warning when accessing invalid subscription links with missing post ID’ is closed to new replies.