Closed (fixed)
Project:
Metatag
Version:
7.x-1.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
5 Sep 2013 at 14:15 UTC
Updated:
4 Jan 2014 at 03:57 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
hswong3i commentedComment #2
damienmckennaThis needs an update script to fix the field for any existing installs.
Comment #3
damienmckennaThis may work, I need to test it out.
Comment #4
damienmckennaComment #5
damienmckennaUpdated patch that just includes some drupal_set_message comments.
Comment #6
damienmckennaI tested this on MySQL and it worked, but I don't have PostgreSQL (or anything else) available to test it there.
Comment #7
damienmckennaCommitted. Thanks hswong3i!
Comment #8
damienmckennaActually, the revision_id field needs to allow NULL values, as e.g. the user entity saves a NULL for the revision_id in all field records.
Comment #9
damienmckennaI've reverted this patch and will not be committing it, but I do very much appreciate the time you put into the patch.
Comment #10
rob_johnston commentedI'm going to agree with the OP. We had an upgrade on MS SQL Server fail this morning and we fixed it by implement the patch in #1 (and then later found this issue). I've gathered some evidence to support my argument, so here goes...
For MySql, from http://dev.mysql.com/doc/refman/5.7/en/create-table.html
For PostGres, from http://www.postgresql.org/docs/9.3/interactive/ddl-constraints.html#DDL-...
For Oracle, from http://docs.oracle.com/cd/B28359_01/server.111/b28318/glossary.htm#CNCPT...
MS SQL Server, from http://technet.microsoft.com/en-us/library/aa933112(v=SQL.80).aspx
So there are 4 common RDBMS's that are used with Drupal and none of them allow a null value in a primary key. I think the solution here is to not create a primary key, but rather a unique constraint. See db_add_unique_key() function.
Comment #11
rob_johnston commentedComment #12
damienmckenna@rob_johnston: Thanks for the detailed analysis.
I believe my mistake was examining the a field_data_field_* table rather than field_revision_field_* table - in the former case the table only keeps track of the published revision_id so it isn't part of the primary key, whereas in the latter case there are multiple records and revision_id disallows NULLs and is a primary key.
So yeah, this needs to be applied.
I think the logic around it needs to be verified that a zero is saved as the revision_id.
Comment #13
damienmckennaThis is the most recent patch rerolled.
Comment #14
damienmckennaThis is an updated version of #13 that updates calls to metatag_metatags_save() so that the revision_id defaults to a zero if there's no actual value.
Comment #15
hyperglide commentedCan you provide a testing sequence or guidance to help move this patch to RTBC.
Comment #16
damienmckennaI committed patch #13 instead of #14 as I'm going to leave the fixes for revision_id CRUD logic to #1572474: Add Revisions to Metatags for Entities.
Comment #17
damienmckennaDoing some further consideration of this problem, we need to run an update to ensure all revision_id values are numeric before restructuring the schema.
Comment #18
damienmckennaCommitted. FYI the new update is 7016 and the previous one was bumped to 7017.