PHP errors on /stream page
| Project: | Activity Stream |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | akalsey |
| Status: | closed |
Jump to:
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.
| Attachment | Size |
|---|---|
| actvitystream-php_notices_on_stream_page.patch | 1.69 KB |

#1
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
Ported to 5.x and committed.
#3
Applied to 6.x and committed.
#4