We shouldn't require the context to work or exist if we're only using tags that don't need to know what node we're on.
There needs to be a way in the list hook to tell dme whether or not they need context, and to require it or not. Or even, to not require context to process.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | 1095014-5.dme-node-context-rewrite.patch | 18.53 KB | dww |
| #4 | 1095014-4.dme-node-context-rewrite.patch | 18.53 KB | dww |
Comments
Comment #1
dwwYes please. ;) This issue is from trouble I'm having trying to upgrade a DME-based site to D6. I upgraded the code, ran the DB update, and even found admin/settings/dme to run the batch process (not that it's documented anywhere in the 6.x-1.0 release notes, project page, nor README). ;) An example body field looks like this:
So, the context tag is there. At jcfiala's suggestion, I re-ordered my filters so DME runs first:
I've cleared the caches after every change:
;)
However, my nodes still render like so:
That's because in dme_filter(), this if() is failing:
If I force that
if()to always pass, my DME tags all start working fine and my insert boxes are getting inserted again.Looking briefly at dme.module D6 vs D5, probably over 1/2 the code in the D6 branch is to monkey with this context stuff. I understand that if you need to know the node you're processing as you're processing a DME tag, we need something (although I'm not convinced this is it). However, in none of my cases do I care about that. All my DME tags are used to slurp in other nodes and position them inline in the body (mostly insert boxes and images (which are in their own nodes for all sorts of good reasons), and a few other custom things).
So yeah, it'd be nice not to require a context unless we have tags that require it. ;) In fact, seems like we should always process the text, and *if* you have a tag that requires context and it's not there, tough luck. We're already forcing the prepare step to happen in this case, why not try to process, too?
Comment #2
dwwAhah! ;) Writing up my last comment and looking more closely at the code, the problem is that dmeEngine::dme_set_context() requires that set_node() be called if you don't pass it any text. However, set_node() is never called. It just appears in the code a few times in commented-out code blocks.
Comment #3
dww#2 is wrong. I missed that dmeEngine::dme_set_context() is both setting and getting context. However, since it sets context by directly touching its own protected members, not using its own API, I was confused by the code path.
The *real* bug on my site is that my body isn't the core body, but a separate CCK text area. I'm not even sure why I did it that way in the first place. ;) But, it demonstrates that the existing context system doesn't work at all on other text areas (or blocks, for that matter). All the more reason to make it optional...
Comment #4
dwwEven better! Instead of making all this node context stuff optional, or in a whole separate module, here's a patch that completely removes all the hacks for the
<dme:context>tag and adds a single hack using treachery from the internals of the node API. ;) The patch looks much bigger than it is, since I wrote a small novel in the PHPDoc to explain WTF is going on here. It'll be easier to read and understand if you apply the patch. Also note that this probably only applies cleanly after committing my patch for #1095056: Remove dead and debugging code instead of commenting it out.The one thing this patch doesn't do is try to go back and remove
<dme:context>tags from existing nodes. I figure that can be in another dme_update_N() function if we want to...Comment #5
dwwSorry, forgot to renumber dme_update_6001(). Try this instead.