PHP errors on /stream page

eojthebrave - July 27, 2008 - 19:07
Project:Activity Stream
Version:6.x-2.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:akalsey
Status:closed
Description

Errors on /stream

notice: Trying to get property of non-object in /sites/all/modules/activitystream/activitystream.module on line 244.
notice: Undefined variable: page in /sites/all/modules/activitystream/activitystream.module on line 183.

The first one is caused by this code on line 244

<?php
} elseif ($user->uid) {
?>

Since in this case we are calling the function _activitystream_get_activity with no arguments, and $user defaults to NULL. Changing the check to just $user works fine, and shouldn't cause any problems as the $user object is null if no $user is passed to the function.

The problem with $page is because the $page variable is never set during this function call, nor passed to it. Given that this function is only ever called as a menu callback I think it's safe to assume that $page would always be true, and just remove the if statement all together.

Fixing the problem with $page on line 183 introduces these errors

notice: Undefined variable: node in /sites/all/modules/activitystream/activitystream.module on line 186.
notice: Trying to get property of non-object in /sites/all/modules/activitystream/activitystream.module on line 186.

So I removed this line

<?php
$breadcrumb
[] = l($node->nid, 'node/');
?>

which doesn't seem to be of any use since the $node object is never loaded for this page request, and I can't figure out how or why we need it in the breadcrumb.

AttachmentSize
actvitystream-php_notices_on_stream_page.patch1.69 KB

#1

akalsey - July 31, 2008 - 02:36
Status:patch (code needs review)» patch (reviewed & tested by the community)

Looks like the $page and breadcrumb issues both come from a refactoring where I split the viewing code into multiple functions. Ported to 5.x and committed. Will apply patch to 6.x branch shortly

#2

akalsey - July 31, 2008 - 02:39
Assigned to:Anonymous» akalsey

Ported to 5.x and committed.

#3

akalsey - July 31, 2008 - 16:53
Status:patch (reviewed & tested by the community)» fixed

Applied to 6.x and committed.

#4

akalsey - July 31, 2008 - 17:33
Status:fixed» closed
 
 

Drupal is a registered trademark of Dries Buytaert.