Undefined property in _simpleads_activate_deactive_ad

Created on 25 June 2018, over 6 years ago
Updated 9 June 2023, over 1 year ago

Whilst working on a different patch, I've noticed a bug that was introduced between 1.8 and 1.9.

In the 1.9 version of _simpleads_activate_deactive_ad() there is a new $current_status = _simpleads_get_node_status($node->nid) line that retrieves the current status of the ad node based on the node ID.

However, this function is called during simpleads_node_presave() so there is no node ID yet to load which results in an "undefined property" error which are causing my tests to fail:

Undefined property: stdClass::$nid

My suggestion would be to change it to simply use $node->status which then gets my tests to pass, but I'm not sure if that affects anything elsewhere and there are no tests in the simpleads module to run. I'll attach a patch for review.

It also might be good to use the NODE_PUBLISHED and NODE_NOT_PUBLISHED constants further down in this function, just for readability.

πŸ› Bug report
Status

Closed: won't fix

Version

1.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom opdavies Wales

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024