Closed (fixed)
Project:
Project
Version:
7.x-2.x-dev
Component:
Projects
Priority:
Normal
Category:
Task
Assigned:
Issue tags:
Reporter:
Created:
15 May 2012 at 17:25 UTC
Updated:
4 Jan 2014 at 02:05 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
dwwThanks for this patch. Upon visual inspection:
A) PHPDoc blocks should have 1-liner summaries.
B) The
$project_urlsparam should probably be renamed to$project_machine_namesand the comments (and code) updated accordingly. Confusingly, in D6 (actually all the way back to 4.6 and earlier), the project "shortname" aka machine-name was called the "uri". Which looks a lot like "url". And it's not technically a URI, either. :( So, I'm trying to eradicate this confusion by just calling it a shortname or better yet, "machine-name" whenever possible. ;)C) Code style whitespace bugs (extra spaces) here:
There are also some extra spaces in a few other spots (e.g. inside comment blocks)
D) Code style whitespace bugs (missing spaces) here:
That should look like this:
E) A couple problems with this code block:
- Why not just use
$project_entity_types directly? Can DBTNG not handle it if the array is keyed without sequential keys?- If it has to be numerical sequential keys, you can just use
array_values()instead offoreachlike this.- If you were going to use
foreachthe code style should be:F) The way you're JOINing here for
field_data_field_project_typeassumes fields are stored in the database. Field storage is pluggable. I think there's a Field API way to do what you're doing here without manually building up DBTNG queries which will work even if fields are stored in mongo or something. I'm in a bit of a hurry right now, so I can't find you the function and link it here, but you can ask chx if you need help with this. ;)G) This isn't what this function wants to be doing:
As per point B we just want the machine names here, not the full path alias. However, while I'm talking about this line, again, it's missing spaces for code style.
Thanks!
-Derek
Comment #2
mikey_p commentedThe system for querying fields is called EntityFieldQuery (api docs) and there is an example usage in the project_load() function in project.module itself.
Comment #3
mikey_p commentedAlso, for tying this to nodes (I noticed a comment about attaching an issue queue to a user), it's a little clumsy for the moment but somewhere we added a constant for the entity type that can be turned into projects, PROJECT_ENTITY_TYPE which is just set to 'node'.
Comment #4
dwwRe: tying this to nodes, see #1586210: Clean up confusion where we appear to support more entity types -- trying to be general is great, but there are limits. ;) To avoid needless complication, we have to just accept the fact that Project* is assuming that projects, releases, and issues are all *nodes*. We can't really handle using arbitrary entities as projects without much more complication than we can afford (given how much work we already have ahead of us to port all this and convert it to Field API), especially since there's dubious value in making this fully entity-agnostic. Attaching an issue queue to a user sounds funny, but I can't really justify the maintenance overhead to begin to try to support that. ;)
And, maybe I'm just stuck in my old thinking, but I really believe that all of these qualify for all the things that make a node a node -- a real path, the possibility for revisions, comments, etc. I don't see a problem requiring nodes for any of these, and it definitely makes the code simpler and easier to understand.
Comment #5
rgristroph commentedHere's a re-work that uses EntityFieldQuery.
I think the comment formatting / code style issues have been addressed. (I'm setting up coder / coder_tough_love to make checking those easier in the future).
The $uri is renamed to $project_machine_names. The code is fewer lines which is generally a sign that it is better :)
A sister patch that uses this will be posted to #1549808 shortly.
--Rob
Comment #6
senpai commentedSetting to 'needs review'. Let's see what the Bot says.
Comment #7
dww@Senpai: thanks for setting the status. I was going to review anyway, but it's nice to actually stick to the real workflow with the issue status, especially since we've got minor help for obvious problems from the bot.
@rgristroph: Thanks for the patch. Mostly looking great. A few remaining problems:
H) As I linked in #4, see #1586210: Clean up confusion where we appear to support more entity types. We removed
PROJECT_ENTITY_TYPE. Now I'm having second thoughts. If we reopen that, we can fix this. But for now, that constant isn't defined so you should just use 'node'.I) If
$issuesisFALSEand$include_sandboxis set to'include_sandboxes', this code will simply return all nodes in the system. Nothing is restricting it to project nodes.Thanks again,
-Derek
Comment #8
dwwAlso, I just noticed another thing here:
J) Similar to point H,
project_project_entity_bundles()no longer exists, either. It's now calledproject_project_node_types()...Comment #9
rgristroph commentedI think the attached patch should address all of the issues raised so far.
--Rob
Comment #10
dww(You forgot to update the status to "needs review"). ;)
I was about to bump this back to "needs work" when I saw this:
However, upon further research, D7 gives us no way to just load a few fields on all 10K projects. We have to
entity_load()all of them. :( In fact, entityreference has the exact same problem unless you use the autocomplete widget -- they have toentity_load()everything, too. Shocking.So, #1549808: Port the lame D6 node/add/project-issue UI to D7 is likely to crash d.o once we deploy it. But, it seems pointless to keep pouring energy into this to try to play crazy tricks to make a totally broken UI work on a d.o-sized site. This code here (and the UI it supports) works fine on small Project* sites. It's a totally broken mess (to be clear, this patch is perfectly fine code, D7 itself is to blame) for something d.o-sized. But whatever... that's really for #1044950: Re-architect the project-dropdown UI selector on node/add/project-issue to prevent server crashes not here.
To move things forward, I just fixed the tiny whitespace bug in your patch, and pushed 37a81345 to 7.x-2.x.
Thanks for all your work on this!
-Derek
p.s. tagging for sprint 3 since this bled over into there...
Comment #11
rgristroph commentedThanks for committing, as I think even with the heavy-handed way of entity_loading everything, this is needed to make progress on some other issues.
We should have a separate discussion about a better way to deal with this problem; I have talked with other people about doing some kind of extension of the EntityFieldQuery stuff and/or an "entity_partial_load()" function that would be more performant, it could be a module, no need for any core modifications (I think).
--Rob