sifr_render_css_screen() prints all rules, without checking to make sure it's a sIFR rule. Not an issue now, but it will be if someone adds a new rendering plugin.
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | render.rules_.patch | 2.14 KB | sun |
| #16 | render-DRUPAL-5.rules_.patch | 2.15 KB | sun |
| #14 | render_module_2.patch | 2.02 KB | q0rban |
| #11 | render.module.patch | 1.6 KB | sun |
| #8 | render_module_1.patch | 1.89 KB | q0rban |
Comments
Comment #1
q0rban commentedOn further study, it appears that the real issue occurs in
render_get_rules()of the render.module.I'm guessing that it's returning the $rules without running the query that selects only rules by
$plugin. Maybe this would be a better solution? :Comment #2
q0rban commentedComment #3
q0rban commentedSo I've figured out the problem, but am not sure about the solution. Declaring
$rulesas static insiderender_get_rules()essentially sends all the rules to each plugin.That would seem simple enough to fix, but the real problem is that
render_get_rules()also sets the sitewide 'render_plugins' variable by recursing through each rule and creating an array of each plugin name, which I'm assuming is why you've set the rules static in the first place.So, the only solution I came up with would be to declare
$active_pluginsstatic instead. Let me know what you think.Comment #4
q0rban commentedComment #5
sunSounds reasonable. However, you have removed the rule cache by removing those lines:
$rules should be $active_plugins[$plugin] then.
Comment #6
q0rban commentedI'm not sure I understand. If by rule cache you mean the names of each plugin, then that is being stored in the
static $active_plugins. If you mean something else, then it's probably beyond the scope of what I understand is happening in the function.By my understanding the function is performing 3 separate tasks:
In my testing, all the above tasks are being accomplished with the patch. Let me know what I'm missing.
Comment #7
sun$rules has been a static variable before. This means that its content cached locally for this function; see http://de2.php.net/manual/en/language.variables.scope.php for further information. Once the current rules are fetched from the database, we can early-return the rules from the already filled $rules array. Since this patch changes $rules to $active_plugins[$plugin], the code in #5 needs to be re-inserted with the changed variable name.
Comment #8
q0rban commentedAhh, ok, I think I understand. You are setting
$rulesstatic so that there will be minimal database calls, correct? If that's the case, then yes I can understand why the above patch would be a bad idea.I've attached a new patch that puts each plugin's rules in
$rules['plugin_name'], and also stores all rules in$rules['all']. It will return$rules['all']unless a specific plugin's rules are requested. Let me know what you think.Comment #9
sunerrr... yes and no ;)
I think the patch in #3 was great so far. The only thing missing was the early-return I outlined in #5. If you implement it the same way as it was before, we don't need extra indentation. Furthermore, we don't need an additional
'all'array containing all rules from all plugins, because we can iterate over the whole array where needed.btw: Please read http://drupal.org/patch/create (at least use
-uparguments, please).Comment #10
q0rban commentedWell, I see that, but the problem I noticed with that method is that it's not actually storing all the rules from the initial database call, so the early return is kind of useless since the static $active_plugins variable is only storing the plugins' name, not the parameters of the each rule.
Encapsulating the database call within
if (isset($rules))means we only need one instance of this:otherwise we'd need it up at the top with the
if (!isset($rules)) {and at the bottom after the database call. So that's why everything's getting the extra indentation.I agree that we can iterate elsewhere, but I was trying to come up with a solution that only modified the code within the render_get_rules() function.
I'm sorry, I was being lazy just viewing the unsaved changes within my IDE.
Let me know how you want to proceed.
Comment #11
sunI thought of doing it this way. Let me know what you think.
Comment #12
sun@q0rban: Any updates?
Comment #13
q0rban commentedSorry, I don't know why I wasn't sent an e-mail on #11: I didn't realize you had responded with a new patch. I don't have time to patch and test this week, but from just reading the patch, I think it looks like a good idea.
I'll test next week and get back to you..
thanks!
Comment #14
q0rban commentedThat patch (#11) gave me all sorts of problems. None of my rules were coming up, when I cleared the cache only one file was created, named
_rules.js, there were some foreach errors as if some arrays weren't getting populated, and another error saying that the plugins had no javascript creation function.I really think #8 is the way to go, I've been using it on a site since I first posted it and it's been working with no problems. I've re-rolled and attached it.
Comment #15
q0rban commentedThoughts?
Comment #16
sunSo, after a recent change that added the $reset parameter to render_get_rules() - does attached patch work for you?
Comment #17
q0rban commentedHi sun,
I'm sorry I haven't replied sooner. I don't have time right now to test this patch.
Thanks..