Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

Error in plugin "On site notifications"

+2 votes
asked Aug 25, 2017 in Plugins by Jonatan
edited Aug 25, 2017 by Jonatan
[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
commented Sep 13, 2017 by pupi1985
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
answered Aug 26, 2017 by pupi1985
edited Aug 26, 2017 by pupi1985

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>';


        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.