Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notice: Undefined index: message_ids in read.php on line 270 #838

Open
Phorum opened this issue Jun 11, 2011 · 5 comments
Open

Notice: Undefined index: message_ids in read.php on line 270 #838

Phorum opened this issue Jun 11, 2011 · 5 comments

Comments

@Phorum
Copy link
Collaborator

Phorum commented Jun 11, 2011

Steps to rperoduce:

  • enable message cache
  • make forum moderated
  • post a message (anonymous or registered)
  • access this to-be moderated message (either as admin or moderator)

The following will be generated (I wrapped the long lines):
{{{

( ! ) Notice: Undefined index: message_ids in read.php on line 270
Call Stack

Time Memory Function Location

1 0.0029 325788 {main}( ) ../read.php:0

( ! ) Warning: sort() expects parameter 1 to be array, null given in read.php
on line 276
Call Stack

Time Memory Function Location

1 0.0029 325788 {main}( ) ../read.php:0
2 0.0490 3626740 sort ( NULL ) ../read.php:276

( ! ) Warning: array_slice() expects parameter 1 to be array, null given in
read.php on line 305
Call Stack

Time Memory Function Location

1 0.0029 325788 {main}( ) ../read.php:0
2 0.0498 3627148 array_slice ( NULL, 0, '30' ) ../read.php:305

( ! ) Warning: Invalid argument supplied for foreach() in read.php on line 325
Call Stack

Time Memory Function Location

1 0.0029 325788 {main}( ) ../read.php:0

( ! ) Warning: Cannot modify header information - headers already sent by (output started
at read.php:270) in common.php on line 1805
Call Stack

Time Memory Function Location

1 0.0029 325788 {main}( ) ../read.php:0
2 0.0579 3793172 include( 'posting.php' ) ../read.php:857
3 0.0616 3915172 include( 'include/posting/check_permissions.php' ) ../posting.php:504
4 0.0618 3918988 phorum_redirect_by_url( $redir_url =
'http://phorum/phorum/list.php?10' ) ../check_permissions.php:159
5 0.0618 3918988 header ( 'Location: http://phorum/phorum/list.php?10' ) ../common.php:1805
}}}

This will not happen when the message cache is disabled.

Looking at the database, it makes sense that line 270 in the source fails first. The meta property in the database looks like this:
{{{
a:0:{}
}}}
And line 270 like this:
{{{
267 if($PHORUM["DATA"]["MODERATOR"] && isset($data[$thread]["meta"]["message_ids_moderator"])) {
268 $message_index=$data[$thread]['meta']['message_ids_moderator'];
269 } else {
270 $message_index=$data[$thread]['meta']['message_ids'];
271 }
}}}

I think the fix could be as simple as:
{{{
$message_index=isset($data[$thread]['meta']['message_ids']) ?
$data[$thread]['meta']['message_ids'] :
array();
}}}

I.e. always have an array, either empty or with content.

Reported by: Markus [email protected]
Imported from TRAC: http://trac.phorum.org/ticket/944

@Phorum
Copy link
Collaborator Author

Phorum commented Jun 11, 2011

Wait, something else smells fishy here too.

There's a different behavior of Phorum whether case is enabled or not.

Ignoring the warning for a second, the behavior is:

  • '''cache disabled''': access to to-be moderated message is: Sorry, the message you have requested could not be found.
  • '''cache enable''': access to to-be moderated message redirects to list view, without intermediate message

Another bug?

By: Markus [email protected]

@brianlmoon
Copy link
Member

Yeah, this looks like an issue with new moderated threads when logged in as a moderator. The thread would have no message ids in the meta data. I am not sure it has anything to do with caching.

@ghost ghost assigned brianlmoon Jul 25, 2011
@tomazb
Copy link

tomazb commented May 23, 2012

There was another comment on http://trac.phorum.org/ticket/944 and I agree with Markus. With caching on message is seen to all despite being hidden.

@tomazb
Copy link

tomazb commented Jun 6, 2012

And also marked as hidden despite being visible!

@oricgn
Copy link
Contributor

oricgn commented Sep 11, 2015

Steps to reproduce:
enable message cache
make forum moderated
post a message (anonymous or registered)
access this to-be moderated message (either as admin or moderator)

I tried to reproduce this behavior (version 5.2.20) without success, no notices or warnings. Meta data always contains the message_ids value...

Perhaps already corrected?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants