Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
entity system
Priority:
Major
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
22 Mar 2012 at 23:29 UTC
Updated:
29 Jul 2014 at 20:30 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
fagoalso see http://drupal.org/node/1361232#comment-5768718
Comment #2
fagoYep, we'll need to convert the system to PSR-0. For now I think it's best to just go and add the auto-loaders manually in order to make the tests work. Then once, we've converted the entity api system we can remove those. That way we don't postpone the current entity api patches being worked on.
Comment #3
amateescu commentedI would like to postpone this task until (at least) #1361232: Make the taxonomy entities classed objects gets in, because that will be a pain to re-roll due to all the improvements to the entity system in there.
Comment #4
duellj commentedThanks fago, rerolled patch in #1361234: Make the node entity a classed object.
Comment #5
berdirYay, Taxonomy entity classes is in, can this be activated now?
Comment #6
amateescu commentedI think it can be activated, yes, but I'd like to discuss first if it's worth waiting for the remaining entity patches to get in before starting to work on this.
Comment #7
fagoWe should at least wait for #1277776: Add generic field/property getters/setters (with optional language support) for entities, as this also touches the entity module directly.
The others don't touch the entity module much/at all, so I think we should be good to go then.
Comment #8
duellj commentedShould we create a separate issue for converting the taxonomy and comment entity classes to PSR-0, or can that be covered in this issue?
Comment #9
berdirI guess that would make sense, especially because they could probably already be converted and don't conflict with other patches.
Comment #10
fagoI guess we should discuss the naming first anyway.
For entity.module classes I guess things are pretty clear:
Entity -> Drupal\entity\Entity
EntityInterface -> Drupal\entity\EntityInterface
EntityStorageException -> Drupal\entity\StorageException
EntityDatabaseStorageController -> Drupal\entity\DatabaseStorageController
...
However, how's for entity-type providing modules? Let's take the example of comments.
a)
or should we use
b)
When looking at the provided class of comment.module the Drupal\comment\Entity variant is nice as the purpose of the class is clear just with the name.
However, when using the class the naming would become quite quickly ambiguous without aliasing, e.g. think of comment module dealing with comment and node entities. So probably we should go with a).
Comment #11
berdirYes, a) IMHO. b) would require tons of use X as Y aliases all over the place.
Comment #12
Crell commentedIn light of #1507828: [policy, no patch] Revised standards for class naming within namespaces, definitely A. B would be a nightmare.
Comment #13
fagoah, good!
Ok, here is a first patch converting entity module and taxonomy and comment entities. I've left out the conversion of efq for now, as well as the classes of the old-entity system which will go away anyway.
The patch includes the latest patch from #1277776: Add generic field/property getters/setters (with optional language support) for entities.
It's based upon the entity-psr0 branch from http://drupal.org/sandbox/fago/1497344 - please use Git for further updates of the patch and contact me if you need access.
Comment #14
fagoAccording to http://drupal.org/node/1353118 I've used full qualified names for documenting hooks - I don't really like it though as it's rather verbose. I'd prefer to always go with imported and so short class names.
Comment #15
robloach#13: d8-entity-psr0.patch queued for re-testing.
Comment #17
robloachNot sure about doing the Entity system, Taxonomy AND Comment all at the same time. We could simplify the patch if we push Taxonomy and Comment to their own issues.
Here's a patch that attempts to just do the base Entity system. It also renames DrupalDefaultEntityController to DefaultEntityController and moves the Controller and Query classes to their own namespace to help clean up the file structure.
Grr, testbot. Passes locally. I'll have to take a look later on. Any assistance appreciated :-) .
Comment #19
berdirCreated separate issues for comment and taxonomy:
- #1533020: Convert comment.module entity classes to PSR-0
- #1533022: Convert taxonomy.module entity classes to PSR-0
The File, Node and User conversion patches have already switched to PSR-0.
Comment #20
berdirRe-rolled due to the module per directory patch, added a bunch of missing use statements. This should pass most tests if not all.
use statements for Exceptions are tricky, they are easily overlooked and there isn't much test coverage for them.
Comment #22
duellj commentedEOF new line
Also looks like you missed some use for EntityFieldQuery in node_access_test.module and list.module (there might be others).
Comment #23
robloachComment #25
robloach#23: 1495024.patch queued for re-testing.
Comment #27
xjmWe should also add information about this conversion to the original change notification at
http://drupal.org/node/1400186http://drupal.org/node/1479568 once it is ready.Comment #28
robloachNeeds a re-roll as User.php and Node.php are now in. Need to update those use statements.
Comment #29
robloachComment #30
robloachWas missing a couple references.
Comment #32
berdirOk, this one should pass. Was missing a use in the query test and the node revision failures were random and have been fixed.
No idea why my patch has such a big size difference, this is git diff -M, without -M it was about 160kb.
Comment #34
berdir#32: entity-psr0-1404198-32.patch queued for re-testing.
Comment #36
berdir#32: entity-psr0-1404198-32.patch queued for re-testing.
Comment #37
robloachComment #38
robloachLet's not split them into the namespaces.
Comment #40
robloachMmm?
Comment #42
robloach#40: 1495024.patch queued for re-testing.
Comment #44
robloachI'd like to have #1550680: Automatically convert PSR-0 namespaces for extensions into upper CamelCase first.
Comment #45
robloach#40: 1495024.patch queued for re-testing.
Comment #47
berdirThe controller classes still had the Controller namespace, let's see if this works.
Looks like the module namespace issue is stuck at where it was before, let's try to get stuff in, afaik that one is a search & replace mostly.
PS: Once again, I do not understand how my file size differs that much, I'm either getting ~60kb with -M or 170kb without.
Comment #49
berdirHm, I think the patch from #40 that I re-rolled is an old one. The one from #38 actually had a comparable file size and the one that I re-rolled seems to be missing the same use in entity_query.test. The other fails I fail to reproduce. Will check tomorrow.
Comment #50
berdir#47: entity-psr0-1404198-47.patch queued for re-testing.
Comment #52
berdirOk, let's try this again.
Resolved the merge conflicts and also fixed a few wrong namespaces.
Comment #54
berdirAh, much better. That fail actually makes sense because that's new code that was added since the previous patch. Which means that this patch should be green...
Comment #56
aspilicious commented#54: entity-psr0-1495024-54.patch queued for re-testing.
Comment #58
berdirWould help if I'd use the correct namespace.
Comment #59
berdir#58: entity-psr0-1495024-58.patch queued for re-testing.
Comment #61
berdirRe-rolled, the Simpletest conversion broke it, as so many other issues probably...
Comment #62
aspilicious commentedShouldn't this be Drupal\entity\EntityController ?
If that should change it should change in a lot of places. Same for EntityControllerInterface
20 days to next Drupal core point release.
Comment #63
berdirYep, it should. I think I found all of them, please verify :)
I also assume that we can now default to EntityStorageController in hook_entity_info() and merge these two together once file is converted? (separate issue) The only other remaining usage of EntityController is in TestEntityBundleController and as I understand it, entities will have to use entity class and storage controller, right?
Comment #64
aspilicious commentedIsn't the node controller psr-0 alrdy?
We are in the entity namespace, shoud we use this line than?
Same question
Same questions
Drupal\entityEntityStorage... ???
Probably need long version to
Same for throws
Same for return statements :p
Again, I think we have to go over all instances of node Controller again. Probably not in this issue.
I didn't cover everything, lots of return and throws statements still use the short form (certainly in lib\Drupal\entity)
19 days to next Drupal core point release.
Comment #65
berdirThanks for the review. Ok, ok, I didn't catch them all ;)
- Yep, NodeController should be fixed in a separate issue, especially because they have been renamed to NodeStorageController :)
- Removed unecessary uses.
- Fixed a ton additional references in docblocks.
Comment #66
sunThanks! Nice work.
Comment #67
aspilicious commented#65: entity-psr0-1495024-65.patch queued for re-testing.
Comment #68
aspilicious commentedIs PagerDefault a namespace?
Full namespace path? ;)
Same
Same
Same
18 days to next Drupal core point release.
Comment #69
berdirPagerDefault as a non-namespaced class. Fixed @throws.
Comment #70
klausiReturn no results, good work!
2 minor leftovers that need to be fixed.
Comment #71
berdirAnd fixes these two as well. Also fixed the alternative entity controller example.
Comment #72
aspilicious commentedFinally I can set this to rtbc :D. (we need a followup for the nodecontroller stuff)
Comment #73
catchThis looks great. I'm assuming the NodeController stuff will go when we remove the EntityController class, which in turn will be after files get converted to classed objects?
Committed/pushed and moving to change notification', this can likely be added to the existing modules one, or we might need to update the entities as classed objects, not sure tbh.
Comment #74
aspilicious commentedAdded entity to http://drupal.org/node/1320394
Thats all we need.
Comment #75
berdirNope, that's not enough. We need to update the million references to those classes in http://drupal.org/node/1400186 as well.
Comment #76
aspilicious commentedChange notice is rewritten, only the api docs need a new reference once they are update on api.drupal.org.
Also noticed we missed some docs, here is the followup
Comment #77
aspilicious commentedForgot the user entity, will reroll soon :)
I alrdy fixed the taxonomy stuff in the taxonomy to psr-0 conversion.
Comment #78
aspilicious commentedWith user changes
Comment #79
berdirPatch looks good to me, just a bunch of straight forward replacements. RTBC.
Change notices look good as well apart from the mentioned link problem.
Comment #80
catchThanks, committed/pushed to 8.x. Looks like the change notice has bee updated again since Berdir's comment, so marking back to fixed.
Comment #81
amateescu commentedRestoring title.
Comment #82
berdirjthorson just spotted this in IRC:
Obviously, that line needs to go. Might be the reason for the current random upgrade test failures or not, let's fix this and find out.
Comment #83
aspilicious commentedLets see if this is green
Comment #84
aspilicious commentedEDIT: whoops unneeded
Comment #85
berdirLooks good.
Comment #86
catchThanks! Committed/the follow-up to 8.x.