Closed (fixed)
Project:
Project issue tracking
Version:
7.x-2.x-dev
Component:
Miscellaneous
Priority:
Normal
Category:
Task
Assigned:
Issue tags:
Reporter:
Created:
12 Jun 2012 at 06:13 UTC
Updated:
4 Jan 2014 at 02:05 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
iamcarrico commentedI will take this one on.
Comment #2
iamcarrico commentedAdded in the functionality, note: I updated the theme functions that actually do this as well to be more D7 ish.
Comment #3
iamcarrico commentedI should also point out that this changes some of the work that bdragon did for #1624874: Port project issue text filter but that is because some of the bits he did might eventually break, while this focuses in on making it more fool-proof.
Comment #4
dwwThis patch majorly conflicts with the code already in the 7.x-2.x branch from #1624874: Port project issue text filter and doesn't apply at all. Please do a 'git pull' and re-roll this so it applies cleanly to the end of the branch.
Thanks!
-Derek
Comment #5
iamcarrico commentedNote: this intentionally re-writes some of BDragons work... just on the theme function level though.
Comment #6
iamcarrico commentedChanging the status...
Comment #7
rgristroph commentedI walked through this code with @ChinggizKhan and we also tested and ran it together.
I had the following feedback for him:
1) There was still a couple of places where string concatentation didn't have spaces on both sides of the period, I pedantically pointed those out.
2) This patch removed code to prevent an infinite recursion on the grounds that that code wasn't working, but this patch also didn't fix the infinite recursion problem, and I suggested he not remove that code and leave all that to a separate issue, removing but not replacing it here confuses small minds like mine ;)
I will review again after he re-rolls shortly . . . . but it is looking pretty good.
--Rob
Comment #8
rgristroph commentedHmmm, further working on this with @ChinggizKhan and it looks like the recursion problem doesn't pass through the theme function at all, because just putting a return in there does not stop it. So the related code should be removed. That leaves my only feedback on this patch being the string concatentation code style.
Comment #9
dwwGreat, thanks for the patch and the reviews!
Yeah, the recursion problem is in
project_issue_link_filter_callback(), not the theme function. See #1624874-8: Port project issue text filter.That said, (and I'm guessing ChinggizKhan is going to hate me for this), but I'd really rather use #1624874 to fix that stuff, and leave this issue with the (hopefully simple) task of getting the nid file formatter working. Otherwise,
git blamejust gets confusing and weird. Can we focus on fixing the broken filter code over there and then circle back here with a much smaller patch that does what this issue says it's trying to do? My apologies for not doing a more thorough job reviewing and testing at #1624874 before I committed and pushed. I was in a hurry to try to unblock things, and ended up probably creating more work in the process. :( Sorry!If I wasn't going to set this to 'postponed', I'd set it to 'needs work' for the following:
A) It's not clear why
project_issue_theme()is being moved around in this patch. That just adds 32 lines of noise to the patch, making it seem like we're changing the entire function to remove a single line of code (the 'file' attribute from the array).B) In core, the code style convention for try/catch is to treat
catchlike we do theelseinside if/else. Namely, instead of this:it should be this:
C) At first it wasn't even obvious what we were calling that might throw an exception, but I guess that's coming from EntityMetadataWrapper and friends. Is it really worth the complication to use that wrapper abstraction, just to get a single value from a loaded entity? I'm not saying we should undo what you have here. I'm just asking. ;) Seems like an awful lot of trouble and call stacks to avoid just checking if
$node->field_issue_assigned[LANGUAGE_NONE][0]['value']is empty, and if not, touser_load()the result. Keep in mind that the filter and the code it calls are sort of a critical path performance-wise. Even with the filter cache, this stuff gets called a lot and I'd rather not add extra call frames and layers of abstraction unless they're really necessary. The whole filter API already requires us to do a lot of that, already -- I don't want to make a bad situation worse.Anyway, most of these comments are off-topic for this issue, they really belong at #1624874 since they're about fixing the filter. But, since the patch was here, I wanted to comment on this before you re-roll anything and post it over there.
Thanks!
-Derek
Comment #10
iamcarrico commenteda) Yeah, I will change that. It was just a mistake (I added it twice, deleted the wrong one)
b) will update today
c) I used the EntityMetadataWrapper because the $node->field_issue_assigned[LANGUAGE_NONE][0]['value'] is sketchy to use. Sometimes it will indeed have a language tag, sometimes now... and that is not always related to the language of the node, but sometimes whether or not the field can be translated (so you cant use $node->language either.) Now, this entire thing provides an interesting question, as the node_load in the filter is causing the recursion issues in #1624874: Port project issue text filter.
Overall, I will update the minor code errors within this patch, and to keep the data separate, I think we should push this code base, then we can work on the debugging in #1624874: Port project issue text filter.
Comment #11
dwwRight. Please don't post another patch here now. Let's first get the filter itself cleaned up and working at #1624874, just touching the filter. I don't want to push this as-is since it's a confusion between partial debugging and fixing #1624874, mixed in with the field formatter changes. Let's forget about the field formatter entirely for right now and just focus on getting the filter and related code working. And let's discuss those details at #1624874 not here. Then this patch will be trivial and easy and only touching the field formatter.
Thanks!
-Derek
Comment #12
klonos...coming from #44162: Relationships between issues: support for parent issue and related issues
Comment #13
iamcarrico commentedThis can be worked on now, I will port my old patch into it.
Comment #14
iamcarrico commentedThis is exactly what was before, but changed to allow for the proper theme function work, etc.
Comment #15
rgristroph commentedWhen I use this, the title displayed is that of the node the field is on, not the one that the field references. I will consult with ChingizKhan and work through this with him.
Comment #16
iamcarrico commentedYup, I was being stupid. Fixed it, fairly simple.
Comment #17
iamcarrico commentedChange status
Comment #18
senpai commentedTagging for Sprint 6.
Comment #19
dwwLooks like the status got clobbered during tagging, and that #16 is still awaiting review. I'll circle back when I get a chance if no one else beats me to it. ;)
Cheers,
-Derek
Comment #20
dwwSorry for the delays here. This was much better, thanks for putting up with my requests to keep the issues and patches isolated and clean.
When I tested this, #16 didn't work at all, due to this code block:
I had added a "Known issues" field to project nodes on my dev box. The $entity passed into
hook_field_formatter_view()is the entity that the field is attached to (in this case, a project node), not the entity being referenced by an entity reference field (the issues). Basically, the same bug from #15 but a different manifestation of it.So, I rewrote the logic quite a bit:
- We don't care about the $entity at all. All we care about is what lives in $items.
- Use
entity_load()instead ofnode_load()so we can load all the referenced entities in 1 call (exactly whatnode_load_multiple()does).- Added code so that if the referenced entity is not an issue node, we still do useful things. I might live to regret this, but it seems like a kind way to prevent some WTFs when people use this. Since you *can* configure this formatter to be used on any entity reference, we should try to support any kind of entity you might reference.
See these commits for the full diff:
http://drupalcode.org/project/project_issue.git/commit/34b336c
http://drupalcode.org/project/project_issue.git/commit/748c458
Thanks!
-Derek