Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+2 votes
690 views
in Plugins by
edited by
[error] PHP Notice:  Undefined offset: 1 in /var/www/vhosts/spaceamigos.com/httpdocs/qa-plugin/q2apro-on-site-notifications/q2apro-onsitenotifications-page.php on line 135, referer:

Line: https://github.com/q2apro/q2apro-on-site-notifications/blob/master/q2apro-onsitenotifications-page.php#L135
by
I was wondering if you finally found the issue that generates this and/or if the solution suggested actually fixed it

1 Answer

+3 votes
by
edited by

I just glanced at the code. There are two things to bear in mind.

1. That piece of code, regardless of Q2A, has something smelly. Because on L124 the $m[1] access is protected checking that $m[1] actually has something in it. However, on L135, it is not. Protecting L135 would prevent the issue.

2. I can't think of any case in Q2A in which you could have a u_message event in the ^eventlog table without having the text messageid=X as a param. Maybe there is a plugin inserting records in the ^eventlog table with the u_message string. That shouldn't be the best approach but querying the ^eventlog isn't either.

In conclusion, move the curly bracket in L125 exactly before the curly bracket in L136. That's the fix.

If you want to have more information about the guilty piece of text that's generating the issue you could replace the whole IF in L123 with:

if(preg_match('/messageid=([0-9]+)/',$ustring,$m) === 1) {

    $event['messageid'] = (int)$m[1];

} else {

    if (qa_get_logged_in_handle() === 'pupi1985') {

        echo '<pre>';

        var_dump($event);

        echo '</pre>';

    }

}

Replace pupi1985 with your own username in the site so that only you can see the error log when it appears. Then paste it here to see what the root cause of the issue is.

...