Notice: Undefined property: stdClass::$ in _userpoints_node_action_has_status_changed()

I get a few of these errors when i put a node to sticky. No point have been taken from the user.

CommentFileSizeAuthor
#2 status_changed-1567352-2.patch1.55 KBAnonymous (not verified)
#3 status_changed-1567352-3.patch2.13 KBAnonymous (not verified)

Comments

BillyMG’s picture

Assigned: Unassigned » BillyMG
Priority: Normal » Minor

Very odd, but I'm not seeing that. Can you include a line number and/or your version of that function? It should be very easy to find in the userpoints_node_action.inc file. It may also be a PHP version thing, if you can tell me what version of PHP you're running.

Anonymous’s picture

StatusFileSize
new1.55 KB

It's line 460:

if ($node->$action !== null && $node->$action != $newStatus) {

$action contains the name of the action (eg. "<Create>") and due to the < character it isn't printed with the message.

I think _userpoints_node_action_has_status_changed() should better be called with $actionID, see patch attached patch at #3

Anonymous’s picture

Status: Active » Needs review
StatusFileSize
new2.13 KB

The patch above didn't consider the 'userpoints_node_created' action. I've added handling for it, but as I don't know much about the internals of this module, please check carefully.

Anonymous’s picture

It's related to #1158288: Points charge-off on un publishing, which might need a backport.

BillyMG’s picture

Sorry about the delay, I didn't see this bug before. I've made some updates to DEV for 7.x and 6.x, so please give them a try after they update and let me know if this is still an issue.

Anonymous’s picture

I can't actually find any relevant change against this issue in the latest dev 7.x!? Please consider my patch at comment #3. I didn't really provide it just for fun ;)

When feeding the _userpoints_node_action_has_status_changed() with the $actionName, line 461 will evaluate like:

if ($node->'<Sticky>' !== null && $node->'<Sticky>' != $newStatus) {

This is all the PHP notice is about! (see, $node has not property called <Sticky>)

You'd need to use the $actionId instead (see my patch above!). Then the statement will evaluate like:

if ($node->sticky !== null && $node->sticky != $newStatus) {

I hope it is clearer now to you.

The bug can be reproduced by making a node sticky for example. Other actions (unpublishing, promoting) will likely cause the same error message. Make sure to have PHP notices turned on to see the message, or consult the watchdog log.

BillyMG’s picture

Whoops, I made some changes, but the $actionID one didn't make it in. Sorry about that; give the new DEV build a try.

BillyMG’s picture

Status: Needs review » Closed (fixed)

This should be fixed with that recent build. If not, please open a new ticket.