backdrop-contrib / og

The Organic Groups module provides users the ability to create, manage, and delete 'groups' on a site.
GNU General Public License v2.0
1 stars 8 forks source link

Notice: Trying to access array offset on value of type bool in og_context_handler_url() #140

Closed olafgrabienski closed 1 year ago

olafgrabienski commented 1 year ago

The full PHP notice is:

Trying to access array offset on value of type bool in og_context_handler_url() (line 497 of og_context.module)

So far I can't tell how exactly to reproduce the issue. I see many of these notices in DBlog on a site which is an upgrade from D7. Code-wise, line 497 reminds the recently fixed issue https://github.com/backdrop-contrib/og/issues/135. So, a fix could maybe look like this:

if (strpos($item['path'], 'node/add/') !== 0) { if ($item && strpos($item['path'], 'node/add/') !== 0) {

But first, I'd like to be able to know the steps to reproduce the issue.

argiepiano commented 1 year ago

Thanks @olafgrabienski. This looks like a correct fix, as menu_get_item() can return FALSE when there are problems getting the menu item from the database. I'll be happy to merge this fix.

As a side note, this may be a sign of problems in your upgraded site in core, that are beyond the OG functionality - so if you can find a way to reproduce this may help troubleshoot site upgrading issues. Given the place where this warning is happening (after menu_get_item() the quickest way to figure out the problem is by examining the stack of calls when $item is empty.

argiepiano commented 1 year ago

This is happening when entityreference_prepopulate is enable and you get a "Page not found". Similar situation as #135. PR coming.

argiepiano commented 1 year ago

PR #143

olafgrabienski commented 1 year ago

Sorry for being late, and thanks for the explanation and the PR! I've just verified on a OG powered site with Entityreference Prepopulate that the PR fixes the issue: no PHP notice anymore when there is a "Page not found".

Since https://github.com/backdrop-contrib/og/releases/tag/1.x-2.10.0-beta there were some issues fixed, and most things are working fine now. What do you think about a new release?

argiepiano commented 1 year ago

Let's do it!

argiepiano commented 1 year ago

Should we merge #134 too?

olafgrabienski commented 1 year ago

Sure, if you're okay with the caveat mentioned in https://github.com/backdrop-contrib/og/issues/26#issuecomment-1497998534.

argiepiano commented 1 year ago

Release 1.x-2.10.1 is out! We'll need to update the repo for localize at some point...