PHP Notice: Undefined property: stdClass::$last_comment_timestamp in node_uuid_entities_features_export_entity_alter() (line 383 of uuid.core.inc)

Comments

balintbrews’s picture

StatusFileSize
new1.05 KB

The attached patch works well, it solves the issue. However, I was wondering, maybe instead of the following statement:

if (isset($entity->{$property}) || property_exists($entity, $property)) {

We could use this:

if (property_exists($entity, $property)) {

Since property_exists checks if the property exists in the given object, and it returns TRUE even if the property has the value NULL, using isset is not necessary in my opinion.

Also, for the sake of consistency, I would change the statement in the user_uuid_entities_features_export_entity_alter as well.

dixon_’s picture

Status: Needs review » Fixed

Thanks both for the patches. I've committed Bálint's patch in #1. That approach does indeed make a little bit more sense.

This also fixes #1458010: On-behalf hook_uuid_entities_export_entity_alter()s look for nonexistent properties, which is a duplicate of this.

mfb’s picture

isset($entity->{$property}) || property_exists($entity, $property) is simply a performance optimization - because isset() executes *much* faster than property_exists(). See e.g. http://api.drupal.org/api/drupal/modules%21field%21field.attach.inc/func...

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.