Skip to:
Content

bbPress.org

Opened 22 months ago

Closed 4 months ago

Last modified 4 months ago

#3232 closed defect (fixed)

Unidentified index Error

Reported by: Venutius Owned by: johnjamesjacoby
Milestone: 2.6.5 Priority: normal
Severity: normal Version: 2.6.0
Component: Component - Forums Keywords:
Cc:

Description

I'm seeing the following error:

[23-Nov-2018 03:38:40 UTC] PHP Notice: Undefined index: forum_id in /wp-content/plugins/bbpress/includes/forums/template.php on line 767

Looking at that function, I can see there's an empty check on the next line:

// Loop through forums and create a list
$sub_forums = bbp_forum_get_subforums( $r['forum_id'] );
if ( !empty( $sub_forums ) ) {

Maybe we can also have an isset check for $rforum_id??

Attachments (1)

Screen Shot 2019-11-19 at 8.46.58 PM.png​ (75.2 KB) - added by johnjamesjacoby 10 months ago.
Looks OK to me?

Download all attachments as: .zip

Change History (21)

#1 @johnjamesjacoby
22 months ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 2.6
  • Owner set to johnjamesjacoby

#2 @johnjamesjacoby
22 months ago

Interesting. I’ll look into it.

What pages are you seeing this on?

#3 @Venutius
22 months ago

I'm not sure, it's on a live site and I'm just seeing the errors come through on my log.

#4 @johnjamesjacoby
22 months ago

  • Resolution set to fixed
  • Status changed from new to closed

In 6875:

Forums: protect against a missing/malformed forum_id value when listing subforums.

Fixes #3232.

#5 @johnjamesjacoby
10 months ago

  • Milestone changed from 2.6 to 2.6.1
  • Resolution fixed deleted
  • Status changed from closed to reopened

#6 @johnjamesjacoby
10 months ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 6941:

Subforums: use the default forum ID when listing subforums.

This commit fixes a regression causing subforums not be listed in forum indexes.

Fixes #3232. Props scmsteve. For 2.7, trunk.

#7 @johnjamesjacoby
10 months ago

In 6942:

Subforums: use the default forum ID when listing subforums.

This commit fixes a regression causing subforums not be listed in forum indexes.

Fixes #3232. Props scmsteve. For 2.6.1, branches/2.6.

#8 @johnjamesjacoby
10 months ago

  • Milestone changed from 2.6.1 to 2.6.2
  • Resolution fixed deleted
  • Status changed from closed to reopened

This was only partially resolved in 2.6.1, so reopening for more research and moving to 2.6.2.

#9 @johnjamesjacoby
10 months ago

  • Version changed from 2.5.14 to 2.6.0

#10 @johnjamesjacoby
10 months ago

  • Keywords needs-testing added
  • Milestone changed from 2.6.2 to 2.6.3

#11 @Robin W
10 months ago

  • Priority changed from normal to high

This is still causing problems, I have been working with a user who has both

Notice: Undefined index: forum_id for line 732

// Query for subforums
	$sub_forums = ! empty( $r['forum_id'] )
		? bbp_forum_get_subforums( $r['forum_id'] )
		: array();

and

Notice: Undefined index: link_before and
Notice: Undefined index: link_after

for line 772

<?php
// Maybe wrap output
                $output = ! empty( $links )
                        ? $r['before'] . implode( $r['sep'], $links ) . $r['after']
                        : '';

the later seems to cause the valid $links array that I have checked exists immediately befiore this line and should make up the sub forum list to turn into a blank $output array, therefore causing the sub forums not to list

#12 @Robin W
10 months ago

Basically this array doesn't end up in a list of subforums - he just gets nothing

array (size=64)
  0 => string '<a href="https://novwater.dev.cc/forum/countries/australia/" class="bbp-forum-link">Australia</a>' (length=97)
  1 => string '<a href="https://novwater.dev.cc/forum/countries/austria/" class="bbp-forum-link">Austria</a>' (length=93)
  2 => string '<a href="https://novwater.dev.cc/forum/countries/azerbaijan/" class="bbp-forum-link">Azerbaijan</a>' (length=99)
  3 => string '<a href="https://novwater.dev.cc/forum/countries/bahrain/" class="bbp-forum-link">Bahrain</a>' (length=93)
  4 => string '<a href="https://novwater.dev.cc/forum/countries/belgium/" class="bbp-forum-link">Belgium</a>' (length=93)
  5 => string '<a href="https://novwater.dev.cc/forum/countries/brazil/" class="bbp-forum-link">Brazil</a>' (length=91)
  6 => string '<a href="https://novwater.dev.cc/forum/countries/bulgaria/" class="bbp-forum-link">Bulgaria</a>' (length=95)
  7 => string '<a href="https://novwater.dev.cc/forum/countries/cambodia/" class="bbp-forum-link">Cambodia</a>' (length=95)
  8 => string '<a href="https://novwater.dev.cc/forum/countries/canada/" class="bbp-forum-link">Canada</a>' (length=91)
  9 => string '<a href="https://novwater.dev.cc/forum/countries/chile/" class="bbp-forum-link">Chile</a>' (length=89)
  10 => string '<a href="https://novwater.dev.cc/forum/countries/china/" class="bbp-forum-link">China</a>' (length=89)
  11 => string '<a href="https://novwater.dev.cc/forum/countries/croatia/" class="bbp-forum-link">Croatia</a>' (length=93)
  12 => string '<a href="https://novwater.dev.cc/forum/countries/cyprus/" class="bbp-forum-link">Cyprus</a>' (length=91)
  13 => string '<a href="https://novwater.dev.cc/forum/countries/czech-republic/" class="bbp-forum-link">Czech Republic</a>' (length=107)
  14 => string '<a href="https://novwater.dev.cc/forum/countries/denmark/" class="bbp-forum-link">Denmark</a>' (length=93)
  15 => string '<a href="https://novwater.dev.cc/forum/countries/estonia/" class="bbp-forum-link">Estonia</a>' (length=93)
  16 => string '<a href="https://novwater.dev.cc/forum/countries/finland/" class="bbp-forum-link">Finland</a>' (length=93)
  17 => string '<a href="https://novwater.dev.cc/forum/countries/france/" class="bbp-forum-link">France</a>' (length=91)
  18 => string '<a href="https://novwater.dev.cc/forum/countries/germany/" class="bbp-forum-link">Germany</a>' (length=93)
  19 => string '<a href="https://novwater.dev.cc/forum/countries/gibraltar/" class="bbp-forum-link">Gibraltar</a>' (length=97)
  20 => string '<a href="https://novwater.dev.cc/forum/countries/greece/" class="bbp-forum-link">Greece</a>' (length=91)
  21 => string '<a href="https://novwater.dev.cc/forum/countries/guernsey/" class="bbp-forum-link">Guernsey</a>' (length=95)
  22 => string '<a href="https://novwater.dev.cc/forum/countries/hungary/" class="bbp-forum-link">Hungary</a>' (length=93)
  23 => string '<a href="https://novwater.dev.cc/forum/countries/iceland/" class="bbp-forum-link">Iceland</a>' (length=93)
  24 => string '<a href="https://novwater.dev.cc/forum/countries/india/" class="bbp-forum-link">India</a>' (length=89)
  25 => string '<a href="https://novwater.dev.cc/forum/countries/indonesia/" class="bbp-forum-link">Indonesia</a>' (length=97)
  26 => string '<a href="https://novwater.dev.cc/forum/countries/iran/" class="bbp-forum-link">Iran</a>' (length=87)
  27 => string '<a href="https://novwater.dev.cc/forum/countries/ireland/" class="bbp-forum-link">Ireland</a>' (length=93)
  28 => string '<a href="https://novwater.dev.cc/forum/countries/israel/" class="bbp-forum-link">Israel</a>' (length=91)
  29 => string '<a href="https://novwater.dev.cc/forum/countries/italy/" class="bbp-forum-link">Italy</a>' (length=89)
  30 => string '<a href="https://novwater.dev.cc/forum/countries/japan/" class="bbp-forum-link">Japan</a>' (length=89)
  31 => string '<a href="https://novwater.dev.cc/forum/countries/jersey/" class="bbp-forum-link">Jersey</a>' (length=91)
  32 => string '<a href="https://novwater.dev.cc/forum/countries/latvia/" class="bbp-forum-link">Latvia</a>' (length=91)
  33 => string '<a href="https://novwater.dev.cc/forum/countries/lebanon/" class="bbp-forum-link">Lebanon</a>' (length=93)
  34 => string '<a href="https://novwater.dev.cc/forum/countries/lithuania/" class="bbp-forum-link">Lithuania</a>' (length=97)
  35 => string '<a href="https://novwater.dev.cc/forum/countries/luxembourg/" class="bbp-forum-link">Luxembourg</a>' (length=99)
  36 => string '<a href="https://novwater.dev.cc/forum/countries/malaysia/" class="bbp-forum-link">Malaysia</a>' (length=95)
  37 => string '<a href="https://novwater.dev.cc/forum/countries/malta/" class="bbp-forum-link">Malta</a>' (length=89)
  38 => string '<a href="https://novwater.dev.cc/forum/countries/morocco/" class="bbp-forum-link">Morocco</a>' (length=93)
  39 => string '<a href="https://novwater.dev.cc/forum/countries/myanmar/" class="bbp-forum-link">Myanmar</a>' (length=93)
  40 => string '<a href="https://novwater.dev.cc/forum/countries/netherlands/" class="bbp-forum-link">Netherlands</a>' (length=101)
  41 => string '<a href="https://novwater.dev.cc/forum/countries/new-zealand/" class="bbp-forum-link">New Zealand</a>' (length=101)
  42 => string '<a href="https://novwater.dev.cc/forum/countries/norway/" class="bbp-forum-link">Norway</a>' (length=91)
  43 => string '<a href="https://novwater.dev.cc/forum/countries/philippines/" class="bbp-forum-link">Philippines</a>' (length=101)
  44 => string '<a href="https://novwater.dev.cc/forum/countries/poland/" class="bbp-forum-link">Poland</a>' (length=91)
  45 => string '<a href="https://novwater.dev.cc/forum/countries/portugal/" class="bbp-forum-link">Portugal</a>' (length=95)
  46 => string '<a href="https://novwater.dev.cc/forum/countries/qatar/" class="bbp-forum-link">Qatar</a>' (length=89)
  47 => string '<a href="https://novwater.dev.cc/forum/countries/romania/" class="bbp-forum-link">Romania</a>' (length=93)
  48 => string '<a href="https://novwater.dev.cc/forum/countries/1025-2/" class="bbp-forum-link">Russia</a>' (length=91)
  49 => string '<a href="https://novwater.dev.cc/forum/countries/saudi-arabia/" class="bbp-forum-link">Saudi Arabia</a>' (length=103)
  50 => string '<a href="https://novwater.dev.cc/forum/countries/singapore/" class="bbp-forum-link">Singapore</a>' (length=97)
  51 => string '<a href="https://novwater.dev.cc/forum/countries/slovakia/" class="bbp-forum-link">Slovakia</a>' (length=95)
  52 => string '<a href="https://novwater.dev.cc/forum/countries/slovenia/" class="bbp-forum-link">Slovenia</a>' (length=95)
  53 => string '<a href="https://novwater.dev.cc/forum/countries/spain/" class="bbp-forum-link">Spain</a>' (length=89)
  54 => string '<a href="https://novwater.dev.cc/forum/countries/sweden/" class="bbp-forum-link">Sweden</a>' (length=91)
  55 => string '<a href="https://novwater.dev.cc/forum/countries/switzerland/" class="bbp-forum-link">Switzerland</a>' (length=101)
  56 => string '<a href="https://novwater.dev.cc/forum/countries/taiwan/" class="bbp-forum-link">Taiwan</a>' (length=91)
  57 => string '<a href="https://novwater.dev.cc/forum/countries/thailand/" class="bbp-forum-link">Thailand</a>' (length=95)
  58 => string '<a href="https://novwater.dev.cc/forum/countries/turkey/" class="bbp-forum-link">Turkey</a>' (length=91)
  59 => string '<a href="https://novwater.dev.cc/forum/countries/ukraine/" class="bbp-forum-link">Ukraine</a>' (length=93)
  60 => string '<a href="https://novwater.dev.cc/forum/countries/united-arab-emirates/" class="bbp-forum-link">United Arab Emirates</a>' (length=119)
  61 => string '<a href="https://novwater.dev.cc/forum/countries/united-kingdom/" class="bbp-forum-link">United Kingdom</a>' (length=107)
  62 => string '<a href="https://novwater.dev.cc/forum/countries/united-states/" class="bbp-forum-link">United States</a>' (length=105)
  63 => string '<a href="https://novwater.dev.cc/forum/countries/vietnam/" class="bbp-forum-link">Vietnam</a>' (length=93)

#13 @johnjamesjacoby
10 months ago

The forum_id argument is now always defined, even if empty. If they're still seeing "Undefined index" errors with forum_id on line 732, then they have not updated bbPress to 2.6.1 or 2.6.2, or something is filtering the list_forums arguments via bbp_parse_args() and not doing its own parsing of the $defaults parameter.

  • bbp_before_list_forums_parse_args
  • bbp_after_list_forums_parse_args

#14 @johnjamesjacoby
10 months ago

Thank you @robin-w for looking into this! 💚

#15 @johnjamesjacoby
10 months ago

  • Milestone changed from 2.6.3 to 2.6.4

@robin-w any updates with this? Going to bump to 2.6.4 because I am still under the impression this was fixed, and folks are just not updating.

#16 @Robin W
10 months ago

my guy who I am testing with is away, so yes bump to 2.6.4 and I'll come back

#17 @johnjamesjacoby
8 months ago

  • Milestone changed from 2.6.4 to 2.6.5

Moving open issues from 2.6.4 to 2.6.5, for 2.6.4 release today.

#18 @johnjamesjacoby
4 months ago

  • Milestone changed from 2.6.5 to 2.6.6

#19 @johnjamesjacoby
4 months ago

  • Component changed from General to Component - Forums
  • Keywords needs-patch needs-testing removed
  • Milestone changed from 2.6.6 to 2.6.5
  • Priority changed from high to normal
  • Resolution set to fixed
  • Status changed from reopened to closed

Marking this issue as fixed in 2.6.5.

There is no longer any way for the reported PHP Warnings to occur.

Anyone reading this ticket in the future who is seeing Warnings inside this function should look for filters on bbp_before_list_forums_parse_args or bbp_after_list_forums_parse_args that are nullifying keys in the $r array.

As always, feel free to reopen this ticket if I'm completely wrong. 😀

#20 @Robin W
4 months ago

no, sorry I should have come back and said that this was resolved.

Note: See TracTickets for help on using tickets.