MyBB Community Forums

Full Version: Announcements Added to Categories not appearing....
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I think I have found a bug, but I am unsure as I am new to using mybb, so I thought I would ask about it, if I am missing something obvious I hope to be enlightened, however I suspect this may be a bug and one I will therefore have to fix myself.

Announcements are working fine, global announcements appear in every forum, if you set an announcement against a forum it displays in that forum, however if you set an announcement against a category the announcement does not show in the forums within that category (or any sub-forums).

Any thoughts?

This is a new new install of version 1.6.4 - I have also noticed the same behaviour on the MyBB demo.

Further to this, I have investigated the issue myself and I am now almost certain that this a bug.

Looking at forumdisplay.php, specifically lines 630-632:

630:	// Get Announcements
631:	$forum_stats = $cache->read("forumsdisplay");
632:	if($forum_stats[-1]['announcements'] || $forum_stats[$fid]['announcements'])

The $forum_stats variable is populated with an array that is indexed by fid and has a second-level key of "announcements" with a value of 1. I have tested this extensively and it appears that this array is populated by key values of any fid where that forum has one or more announcements against it (even if that announcement is out of date).

The next line is where the problem lies.

The conditional on line 632 looks for something to evaluate to true for the "announcements" key in the sub-array where the first level key is either "-1" (which is true in the case of global announcements) or the current forum id "fid". Therefore, any announcements against parent forums will not evaluate this conditional to true and will therefore not be loaded and displayed.

I propose the following solution, which I have implemented on my own forum:

In forumdisplay.php on line 632 change this:
632:	if($forum_stats[-1]['announcements'] || $forum_stats[$fid]['announcements'])
To this:
632:	if($forum_stats[-1]['announcements'] || array_intersect_key(array_flip($parentlistexploded), $forum_stats))

I have now reported this as a bug.
Confirming the same experience. Newly instaled 1.6.4 few days ago.

after ViniH fix it working great!

THNX ViniH
(2011-11-24, 10:23 AM)LandEagle Wrote: [ -> ]Confirming the same experience. Newly instaled 1.6.4 few days ago.

after ViniH fix it working great!

THNX ViniH

No problem, glad I could help.
Normally you would report something like this at the dev site: http://dev.mybb.com/
(2011-11-24, 04:44 PM)Paul H. Wrote: [ -> ]Normally you would report something like this at the dev site: http://dev.mybb.com/

I did that as soon as I confirmed that it was a bug.

http://dev.mybb.com/issues/1781
Ok, thanks Smile