Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
entity system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
16 Oct 2012 at 02:59 UTC
Updated:
29 Jul 2014 at 21:21 UTC
Jump to comment: Most recent file
Comments
Comment #1
andypostheh it needs real implementation
Comment #2
andypostActually only delete() method affected by this, so test is changed to make sure that delete works
Comment #3
podarok#2 looks good for me
Comment #4
webchickCan I get more information on why this is a) desirable, and b) constitutes a major bug?
Comment #5
webchickComment #6
dries commentedNice fix/improvement. I'm comfortable with changing the existing tests. Committed to 8.x. Thanks.
Comment #7
xjmUm, what?
This seems like a really bad idea to me.
Comment #8
xjmGiven that:
It seems like a bad idea to me to allow something that evaluates to empty as a key, especially as the ID. I'd want to see a very strong case for the need for this change before considering it. Can we revert this until we can discuss the implications?
Comment #9
webchickI think Dries's commit was a cross-post with mine given the timestamps, and given xjm's comments which seem worthy of consideration, reverted this patch from 8.x, pending more discussion.
Also, when I asked andypost why this was major in IRC he said something like "because it's hard to track down" but I don't think that qualifies against the "significant repercussions" definition at http://drupal.org/node/45111. Not worth holding up features for this unless we get more details on what caused this patch to be written in the first place.
Comment #10
andypostok, let's leave this normal but I disagree... no matter.
Currently we allow usage of '0' as machine-name but have a bug when trying to delete entities with this key
Comment #11
xjmSo, according to @andypost, right now it's possible to create something with 0 as the key, but not delete it. I'd recommend fixing this by disallowing whatever path is currently being used to create them with zero as a key.
Comment #12
xjmIn form_process_machine_name it looks like a single zero is in fact possible as a machine name currently.
Comment #13
andypostSuppose better title, actually describes the issue
Updated summary
Comment #14
xjmAlright, if we want to allow this patch in as a stopgap to fix the bug with deletion, here's what I'd personally like to see:
@todofor a followup.isNew()has bearing on whether we can delete things? It wasn't obvious to me at all looking in the interface and storage controller, so I'd like to know why that is the fix.Comment #15
andypost@xjm You can found affected code in /core/lib/Drupal/Core/Entity/Entity.php
so
!$this->id();in isNew() methods makes type-cast of string '0' to boolAgreed that tests could be extended with addition of entity with '0' machine name
Comment #16
andypostPatch with test that adds a entity with '0' and tries to delete
Comment #17
andypostChanging title - actually isNew() should check that ID-value exists but currently it check for equality to FALSE
Also filed #1814962: Disallow machine names to start with numbers
Comment #17.0
andypostUpdated issue summary.
Comment #18
sunWe can check for === NULL instead.
Comment #19
xjm#18 sounds safest to me. Edit: I'll expand the scope of the followup issue.
Comment #20
xjmOh, I see #1814962: Disallow machine names to start with numbers has been been re-scoped already.
How should we respond if someone tries to create an entity with an ID that's an empty string,
FALSE, etc.? Is that a separate issue from this or #1814962: Disallow machine names to start with numbers? Edit: Maybe we should throw an exception, and yes, I do think it's probably a separate issue, since it's notisNew()'s business to catch that.Comment #21
andypost=== NULL is a good idea!
1814962 is about UI, nothing stops to entity_create('entity', array('id'=>'0')) so this issue makes sense too
Comment #22
andypostPatch
Comment #23
xjmAlright, this looks better to me now (assuming it passes tests).
I opened #1817176: Determine how to handle empty values for entity IDs for the question about empty IDs on creation.
Comment #24
podarok#22 yet one to RTBC
let`s make this in
following #1817176: Determine how to handle empty values for entity IDs now
Comment #25
webchickLooks good. Thanks for the follow-up.
Committed and pushed to 8.x. Thanks!
Comment #26
tim.plunkettThis commit broke HEAD.
Can we revert it for now and figure it all out?
Comment #27
tim.plunkettHere are the fails
I can try to debug this tomorrow once it's reverted.
Comment #28
webchickYep.
git revert 453b2517f5cLOL, I'm really sorry andypost. :) We'll get there!
Comment #29
andypost@sun is trying to change this a different way #1798944: Convert config_test entity forms to EntityFormController
Comment #30
andypostAbout '0' value - we have UID=0 in core, so related but by the same nature #1825568: Random test failure in Drupal\system\Tests\Entity\EntityFormTest
Comment #31
andypostProbably this was fixed, let's get just test patch
Comment #33
sun$id still contains the random ID instead of '0'.
Comment #34
andypostHere's a fixed version
Comment #35
sunThanks, I think this is a regression test that is worth to add.
Comment #36
catchComitted/pushed the test. Thanks!
Comment #38
yched commentedCross-linking for the folks that took part in the thread: #1970110: Should ConfigEntity::isNew() be based on id or uuid ?
Comment #38.0
yched commentedUpdated issue summary.