Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
field system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
5 Feb 2009 at 17:57 UTC
Updated:
27 Mar 2009 at 21:30 UTC
Jump to comment: Most recent file
Comments
Comment #1
venkatd commentedI defined FIELD_STORAGE_UPDATE to be TRUE and FIELD_STORAGE_INSERT to be FALSE.
I wasn't sure whether the constants should be defined as integers or if it would be better to keep the constants the same.
Comment #2
jkitching commentedJust wanted to fill a simple patch to figure out CVS commands and the process for posting one up here.
I wasn't entirely sure where the constant definitions were supposed to go, but all of the others were in field.module so I put them there.
Comment #3
venkatd commentedI made a new version of the patch that makes use of the constants throughout the module.
Comment #4
bjaspan commentedThanks for the patch! Review:
* The INSERT and UPDATE constants are really just unique identifiers. In other languages they would be an "atom." They do not really correspond to TRUE and FALSE. So, I'd suggest just defining them as strings for themselves, e.g. define(INSERT, 'INSERT'). Then, code can check if ($op == INSERT).
* Add a PHPdoc block for each constant explaining what it is for. See field.module for an example. Make sure the PHPdoc is in the same @defgroup as the function(s) that use the constants so they show up on the same page at api.drupal.org.
* Since hook_field_storage_write() always needs to know whether it is an insert or an update, there is probably no benefit to having a default value for the argument. Just make it mandatory and always provide one value or the other.
* In field_sql_storage_field_storage_write(), you changed the $update argument to $op but then did not change the body of the function to use $op instead of $update. Running the unit tests would have revealed this mistake.
Keep it coming! :-)
Comment #5
venkatd commentedMade some changes. Now the defines have been moved to field.module. Now, FIELD_STORAGE_INSERT = 'insert' and FIELD_STORAGE_UPDATE = 'update'.
Fixed my mistake of not renaming $update.
Not sure if I did the @defgroup thing right. Also, my localhost Field SimpleTests are running out of memory so I haven't tested these changes either.
Comment #6
bjaspan commentedHi. Here is my second-round review. Note that I am asking you to make these changes instead of making them myself in order to help you learn how to do core patches, not because I'm trying to be annoying. :-)
* @defgroup field_storage is at the top of field.attach.inc. But these defines there instead of a separate defgroup.
* You are passing FIELD_STORAGE_UPDATE from field_attach_insert(). This turns out to work because it just causes an extra db_delete() that has nothing to delete, but is still wrong.
* If you set a patch to status "Code Needs Review", the testbot will run all core tests with your patch applied for you.
Comment #7
venkatd commentedThanks for the review!
Here's yet another attempt.
Comment #8
yched commented-
if ($op == 'update') {should beif ($op == FIELD_STORAGE_UPDATE) {now- Minor :
should probably be "when updating an existing object".
Comment #9
venkatd commentedDid the $op == 'update' to $op == FIELD_STORAGE_UPDATE change.
Reworded the $op comments as suggested.
Edit: Oops! I forgot to set the status to "code needs review."
Comment #10
bjaspan commentedRTBC.
Comment #12
bjaspan commentedRe-rolled from docroot.
Comment #13
dries commentedCommitted to CVS HEAD. Thanks.