Page 1 of 1

Undefined offset in announcement (error)

Posted: 27. January 2009 14:33
by mk1200
Your Portal Version: 1.0.2
Your phpBB Type: Standard phpBB3
MODs installed: Yes
Your knowledge: Basic Knowledge

PHP Version: 5.2.6
MySQL Version: 5.0.51a

What have you done before the problem was there?
A moderator posted an announcement and I bumped the number of announcements on the portal to 2. It was originally 1 and pushed the old announcement off of the homepage.

So both announcements were showing up fine. 1 of the announcements was downgraded to a normal topic and 1 of the announcements is showing on the homepage. Everything looks good, but my error log has something strange in it.


What have you already tryed to solve the problem?
Nothing

Description and Message
Here is my cPanel error log:

Code: Select all

[27-Jan-2009  03:50:48 -28800] [phpBB Debug] [client 72.30.142.185] [File portal.php?announcement=1] PHP Notice: in file /home/xxxxx/public_html/portal/block/announcements.php on line 244 : Undefined offset:  1
[27-Jan-2009  03:50:48 -28800] [phpBB Debug] [client 72.30.142.185] [File portal.php?announcement=1] PHP Notice: in file /home/xxxxx/public_html/portal/block/announcements.php on line 245 : Undefined offset:  1
[27-Jan-2009  03:50:48 -28800] [phpBB Debug] [client 72.30.142.185] [File portal.php?announcement=1] PHP Notice: in file /home/xxxxx/public_html/portal/block/announcements.php on line 253 : Undefined offset:  1
[27-Jan-2009  03:50:48 -28800] [phpBB Debug] [client 72.30.142.185] [File portal.php?announcement=1] PHP Notice: in file /home/xxxxx/public_html/portal/block/announcements.php on line 260 : Undefined offset:  1
[27-Jan-2009  03:50:48 -28800] [phpBB Debug] [client 72.30.142.185] [File portal.php?announcement=1] PHP Notice: in file /home/xxxxx/public_html/portal/block/announcements.php on line 262 : Undefined offset:  1
[27-Jan-2009  03:50:48 -28800] [phpBB Debug] [client 72.30.142.185] [File portal.php?announcement=1] PHP Notice: in file /home/xxxxx/public_html/portal/block/announcements.php on line 263 : Undefined offset:  1
[27-Jan-2009  03:50:48 -28800] [phpBB Debug] [client 72.30.142.185] [File portal.php?announcement=1] PHP Notice: in file /home/xxxxx/public_html/portal/block/announcements.php on line 264 : Undefined offset:  1
[27-Jan-2009  03:50:48 -28800] [phpBB Debug] [client 72.30.142.185] [File portal.php?announcement=1] PHP Notice: in file /home/xxxxx/public_html/portal/block/announcements.php on line 265 : Undefined offset:  1
[27-Jan-2009  03:50:48 -28800] [phpBB Debug] [client 72.30.142.185] [File portal.php?announcement=1] PHP Notice: in file /home/xxxxx/public_html/portal/block/announcements.php on line 266 : Undefined offset:  1
[27-Jan-2009  03:50:48 -28800] [phpBB Debug] [client 72.30.142.185] [File portal.php?announcement=1] PHP Notice: in file /home/xxxxx/public_html/portal/block/announcements.php on line 267 : Undefined offset:  1
[27-Jan-2009  03:50:48 -28800] [phpBB Debug] [client 72.30.142.185] [File portal.php?announcement=1] PHP Notice: in file /home/xxxxx/public_html/portal/block/announcements.php on line 268 : Undefined offset:  1
[27-Jan-2009  03:50:48 -28800] [phpBB Debug] [client 72.30.142.185] [File portal.php?announcement=1] PHP Notice: in file /home/xxxxx/public_html/portal/block/announcements.php on line 270 : Undefined offset:  1
[27-Jan-2009  03:50:48 -28800] [phpBB Debug] [client 72.30.142.185] [File portal.php?announcement=1] PHP Notice: in file /home/xxxxx/public_html/portal/block/announcements.php on line 271 : Undefined offset:  1
[27-Jan-2009  03:50:48 -28800] [phpBB Debug] [client 72.30.142.185] [File portal.php?announcement=1] PHP Notice: in file /home/xxxxx/public_html/portal/block/announcements.php on line 271 : Undefined offset:  1
[27-Jan-2009  03:50:48 -28800] [phpBB Debug] [client 72.30.142.185] [File portal.php?announcement=1] PHP Notice: in file /home/xxxxx/public_html/portal/block/announcements.php on line 274 : Undefined offset:  1
[27-Jan-2009  03:50:48 -28800] [phpBB Debug] [client 72.30.142.185] [File portal.php?announcement=1] PHP Notice: in file /home/xxxxx/public_html/portal/block/announcements.php on line 280 : Undefined offset:  1
The IP belongs to Yahoo.[/i]

Re: Undefined offset in announcement (error)

Posted: 27. January 2009 17:36
by Kevin
This happens e.g. if the second announcement is called by url (portal.php?announcement=1) although the portal is set to display only one.
In your constellation this might have happened because a bot or something has called a url of your portal from times, where it was set to display two.
Anyway, this could be called a bug, nobody likes debug errors. The fix should look like this:
Open announcements.php, search:

Code: Select all

$announcement = request_var('announcement', -1); 
add after:

Code: Select all

$announcement = ($announcement > $portal_config['portal_number_of_announcements'] -1) ? -1 : $announcement; 
This will handle a call to announcement numbers higher than the portal_number_of_announcements value.

Here is the complete ticket and solution: bugtracker/viewbug.php?b=140

Re: Undefined offset in announcement (error)

Posted: 27. January 2009 17:57
by mk1200
Thanks, editing the file now.

Re: Undefined offset in announcement (error)

Posted: 27. January 2009 18:02
by Kevin
Wait, take this code:

Code: Select all

$announcement = ($announcement > $portal_config['portal_number_of_announcements'] -1) ? -1 : $announcement;  

Re: Undefined offset in announcement (error)

Posted: 27. January 2009 18:38
by mk1200
Got it.