I'm not on PHP 5.3 myself, but I think that attached patch is required.

CommentFileSizeAuthor
#14 entity_save.patch1.27 KBfago
entity.save_.0.patch947 bytessun
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

fago’s picture

Status: Needs review » Postponed (maintainer needs more info)

I'm not on it either, but the reference is currently required for user saving to work. Once #999004: user_save() relies on $edit instead of $account is fixed, this problem would be gone though.

Is anyone on 5.3 experiencing troubles with that?

Also, why should the reference problematic? When entity_save() is called directly with an entity object, it should work, or?

pillarsdotnet’s picture

I'm running php 5.3 without this patch, with E_ALL turned on, and haven't seen any notices pointing to this particular issue.

pillarsdotnet’s picture

@fago -- the reference is only problematic if this particular function gets called by call_user_func_array(). See the note in the PHP manual, just above the user-contributed section. It looks like none of your callback functions take a variable number of arguments, so they should be okay. Hook functions that are dispatched by module_invoke() or module_invoke_all() are a different story.

fago’s picture

yep, but entity_save() isn't called that way so it should be fine.

chx’s picture

The patch is completely harmless, it's entirely pointless (and one might say wrong and misunderstood) to take an object by reference. http://drupal4hu.com/node/224

sun’s picture

Status: Postponed (maintainer needs more info) » Needs review

yeah, I think we did the same for all function arguments being objects throughout Drupal core.

pillarsdotnet’s picture

Title: entity_save() is not PHP 5.3 compatible » entity_save() should not accept object arguments by reference.

Title change, since this has nothing to do with php 5.3 compatibility.

fago’s picture

In that case, it's not true. As said, the current saving implementing for users changes the reference on the object. PHP5's way of dealing with objects is not the same as a reference, so don't mix that up.

And without the user_save() patch being committed, this patch is not harmless. Try running entity API tests without it...

fago’s picture

Status: Needs review » Postponed
Issue tags: -PHP 5.3
pillarsdotnet’s picture

Component: Entity CRUD API - main » Core integration
Status: Postponed » Needs review

Since #999004: user_save() relies on $edit instead of $account is fixed, this should no longer be postponed.

pillarsdotnet’s picture

entity.save_.0.patch queued for re-testing.

fago’s picture

right. I've updated the patch so the user-callback doesn't try to change the entity object any more.

I guess we should introduce a dependency on 7.2 once we commit the patch. Though #1013302: Versioned dependencies fail with dev versions and git clones still bothers me.

fago’s picture

FileSize
1.27 KB
fago’s picture

Status: Needs review » Fixed

committed - be sure to run drupal > 7.2 when using entity_save() for user accounts.
I'm adding a note that we require 7.2 on the project page.

Status: Fixed » Closed (fixed)

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