Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
300
Merge Requests
300
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
38e5e907
Commit
38e5e907
authored
Mar 13, 2009
by
Dries
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Patch
#369785
by bjaspan, venkatd, linolium: define constants for field storage.
parent
cda3f7f8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
8 deletions
+22
-8
modules/field/field.api.php
modules/field/field.api.php
+4
-4
modules/field/field.attach.inc
modules/field/field.attach.inc
+16
-2
modules/field/modules/field_sql_storage/field_sql_storage.module
.../field/modules/field_sql_storage/field_sql_storage.module
+2
-2
No files found.
modules/field/field.api.php
View file @
38e5e907
...
...
@@ -556,11 +556,11 @@ function hook_field_storage_load($obj_type, $queried_objs, $age) {
* The entity type of object, such as 'node' or 'user'.
* @param $object
* The object on which to operate.
* @param $
update
*
TRUE if this is an update to an existing object, FALSE if it is
*
an insert of
a new object.
* @param $
op
*
FIELD_STORAGE_UPDATE when updating an existing object,
*
FIELD_STORAGE_INSERT when inserting
a new object.
*/
function
hook_field_storage_write
(
$obj_type
,
$object
,
$
update
=
TRUE
)
{
function
hook_field_storage_write
(
$obj_type
,
$object
,
$
op
)
{
}
/**
...
...
modules/field/field.attach.inc
View file @
38e5e907
...
...
@@ -29,6 +29,20 @@
* The Drupal system variable field_storage_module identifies the
* field storage module to use.
*/
/**
* Argument for an insert operation.
* This is used in hook_field_storage_write when updating an
* existing object.
*/
define
(
'FIELD_STORAGE_UPDATE'
,
'update'
);
/**
* Argument for an update operation.
* This is used in hook_field_storage_write when inserting a new object.
*/
define
(
'FIELD_STORAGE_INSERT'
,
'insert'
);
/**
* @} End of "defgroup field_storage"
*/
...
...
@@ -386,7 +400,7 @@ function _field_attach_insert($obj_type, &$object) {
}
_field_invoke
(
'insert'
,
$obj_type
,
$object
);
module_invoke
(
variable_get
(
'field_storage_module'
,
'field_sql_storage'
),
'field_storage_write'
,
$obj_type
,
$object
);
module_invoke
(
variable_get
(
'field_storage_module'
,
'field_sql_storage'
),
'field_storage_write'
,
$obj_type
,
$object
,
FIELD_STORAGE_INSERT
);
list
(
$id
,
$vid
,
$bundle
,
$cacheable
)
=
field_attach_extract_ids
(
$obj_type
,
$object
);
if
(
$cacheable
)
{
...
...
@@ -411,7 +425,7 @@ function _field_attach_update($obj_type, &$object) {
}
_field_invoke
(
'update'
,
$obj_type
,
$object
);
module_invoke
(
variable_get
(
'field_storage_module'
,
'field_sql_storage'
),
'field_storage_write'
,
$obj_type
,
$object
,
TRU
E
);
module_invoke
(
variable_get
(
'field_storage_module'
,
'field_sql_storage'
),
'field_storage_write'
,
$obj_type
,
$object
,
FIELD_STORAGE_UPDAT
E
);
list
(
$id
,
$vid
,
$bundle
,
$cacheable
)
=
field_attach_extract_ids
(
$obj_type
,
$object
);
if
(
$cacheable
)
{
...
...
modules/field/modules/field_sql_storage/field_sql_storage.module
View file @
38e5e907
...
...
@@ -229,7 +229,7 @@ function field_sql_storage_field_storage_load($obj_type, $objects, $age) {
return
$additions
;
}
function
field_sql_storage_field_storage_write
(
$obj_type
,
$object
,
$
update
=
FALSE
)
{
function
field_sql_storage_field_storage_write
(
$obj_type
,
$object
,
$
op
)
{
list
(
$id
,
$vid
,
$bundle
)
=
field_attach_extract_ids
(
$obj_type
,
$object
);
$etid
=
_field_sql_storage_etid
(
$obj_type
);
...
...
@@ -247,7 +247,7 @@ function field_sql_storage_field_storage_write($obj_type, $object, $update = FAL
// where it's an empty array with the faster isset().
if
(
isset
(
$object
->
$field_name
)
||
property_exists
(
$object
,
$field_name
))
{
// Delete and insert, rather than update, in case a value was added.
if
(
$
update
)
{
if
(
$
op
==
FIELD_STORAGE_UPDATE
)
{
db_delete
(
$table_name
)
->
condition
(
'etid'
,
$etid
)
->
condition
(
'entity_id'
,
$id
)
->
execute
();
if
(
isset
(
$vid
))
{
db_delete
(
$revision_name
)
->
condition
(
'etid'
,
$etid
)
->
condition
(
'entity_id'
,
$id
)
->
condition
(
'revision_id'
,
$vid
)
->
execute
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment