Closed (fixed)
Project:
Rules
Version:
6.x-1.x-dev
Component:
Rules Engine
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
15 Jul 2009 at 13:15 UTC
Updated:
3 Jan 2014 at 00:29 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
fagoHere is an initial patch - not ready yet.
Problem:
Rules is exporting both rules + rules sets. Features seems to be built for selecting only initial component. We could go and just show "Rule: Label" and "Rule Set: Label" in the list, but two separate sections would be definitely nicer. As first start, the patch only deals with rules.
So far:
* Module dependencies + revert is missing.
* Exports only rules, no sets.
As alternative we could also rely on the rule categories and only allow to export by category - as rules + rule sets implementing a feature should be ideally in the same category nevertheless. Opinions?
Comment #2
amitaibuYou forgot the patch :)
Comment #3
fagoouch, thanks. Here it is.
Comment #4
fagosee #522820: allow multiple components per module
Comment #5
amitaibuCool, I see some of the code from the 'export to module' issue is used :)
Comment #6
amitaibu> As alternative we could also rely on the rule categories and only allow to export by category - as rules + rule sets implementing a feature should be ideally in the same category nevertheless.
I think that's a good practice but I don't think we should force users to do it. Ideally we should have 3 sections like in the current rules export for rules/ rules-sets/category
btw, I have noticed that the rules name aren't renamed.
Comment #7
fagoGreat, it's in!! :)
So I did some further work on this patch. This work depends on the patch in #524160: Allow one default hook to contain multiple components.
Status:
* Added feature components: rules, rule sets, rule items by category
* Fixed rule-renaming to be actually used.
* Improved rule-renaming to not collide with existing rule-names of an already existing feature. (If you add new rules during feature-update.)
Though there is still an issue with rule renaming - features doesn't cope with that currently. One possibility would be to rename the rule in rules_features_export(). So I wonder if it's ok to put the rule item in features $data keyed by the new name.
Also I wonder whether I should mark the exported tags as actually exported components? I tend to think it would be better to not do so, as working "overridden" detection won't work right for them.
TODO:
* Make sure that features default/overridden detection works right.
* Implement revert
* Rename rule-sets to fit the feature's namespace.
* Add dependencies on required modules
However I think for now we could also go without the last point.
Comment #8
fagoAlso TODO:
* Only show triggered rules in the "rules part". So best also rename to that component to "Triggered rules".
Comment #9
amitaibu> Add dependencies on required modules
#524834: Add module dependency information to item
Comment #10
fagoThanks to some further input from yhahn I think we shouldn't rename rule-sets but allow the user to change the prefix, which currently is enforced to be "rules_" for custom-sets. Thus all possible references to the rule-set will be alive.
For triggered rules itself I think renaming is best - as there is no manual name yet and referencing triggered rules somewhere doesn't look like making much sense to me.
Comment #11
dagmarHi.
I'm triying to modify this patch but I have a problem with the cvs versions.
This is what i'm doing.
But i'm getting more diferences that I made. For example:
I didn't change these lines ¬¬
What I'm doing wrong?
Comment #12
dagmarOk, I discovered the problem. part of #350881: Make exporting to module easier was commited and for this reason the patch is a bit diferent.
Well, this patch add a way to get the module dependencies for rules.
Maybe there is a better way to do this, but this works.
It seems that there isn't a way to get the module for the "event" for the rules, but actions and conditions are covered.
Comment #13
fagooh, the 'module' property contains the readable module name which might differ - so it's better if we just check which module provides the _info. Then we can also cover events.
The features views integration does it already that way, see views_plugin_dependencies() (in the features module). It should work the same way for rules.
Comment #14
yhahn commentedJust a quick heads up that in features HEAD
hook_features_api()has been refactored -- the new format is cleaner and easier to understand. It should return an array of keyed component information, so that each component can define its own options separately:We'll try to get a stable-ish tag of features HEAD out soon.
Comment #15
klausiNew patch:
* added module dependency retrieval
* switched to new features_api()
TODO:
* rename rules to avoid collisions
* Implement revert
Comment #16
klausiAnother patch:
* added revert()
* removed rules within rule sets from the rules export selection
I removed renaming of rules for now, because I haven't found a satisfying solution yet. rules_features_export() may be called twice, so prefixing rule names there is also done twice. But we need to prefix them there, because that information is written to the .info file. Then we also need to rename the rules during the actual export, where the $data parameter comes in renamed already and must be named back to the original name to find the rule. Afterwards the rule names must be renamed again.
All in all very ugly .... ideas welcome, maybe I missed something.
Comment #17
dagmarI have made some testing for this patch:
It seems to work fine, however there is a interesting thing to fix.
If diff module is installed, features allows users to see the differences between an unchanged rule and a overwritten rule.
For this example I only have changed the value of the condition "User has role" to 'Negated' and diff shows a lot of changes.
Well, in fact the only change that matters is
But instead of that I'm getting something else (the code attached in this issue).
Maybe the solution for this is include all the values for a rule when it is exported, for example, even if users didn't check in an options, export it with its default value
What do you think?
Comment #18
fago@dagmar: If this are all changes the right side looks broken too me as the removed lines are necessary.
@rule renaming: hm we need to find a solution for that, as we can't go without it. Else users would end up with rule-name clashes and might overwrite the default rules with newly added ones - ouch.
Comment #19
fagoI thought a bit about the renaming problem and I think best would be something like a hook_features_export_alter() - where every module can inspect the export and apply any final changes. Thus we could rename the rules there and change $data to use the new rule names as keys and the old ones as values.
Comment #20
dagmar@fago: The removed lines are added again at the bottom of the file. I think that rules is rebuilding the export in a different way.
Comment #21
amitaibuJust a remark #419644: Use CTools to export . Features module already supports CTools export, so maybe our effort should be towards integration with CTools? (for Rules 2 of course).
Comment #22
klausi@fago: Posted a hook request in the features issue queue: #551490: Allow renaming of components
Comment #23
crizsubscribe...
Desperately waiting for the features integration feature!
Comment #24
fagoI tackled this one again and finally I got it working right! :)
-> It's depending on the patch from #551490: Allow renaming of components
I took the work from klausi and improved it further. So now when an exported rule invokes a rule-set, this is detected and it's added in now too! Also the exported rules and sets get tagged by the feature name automatically now. However detection of the used input evaluators is missing.
Comment #25
amitaibuVery cool! we'll check it out soon :)
Comment #26
fagoI just refactored it a bit:
>refactored features integration to allow actions to add further components to the export by implementing rules_action_callback_features_export().
-> So e.g. the cck integration could add in required fields.
Comment #27
fago>However detection of the used input evaluators is missing.
I just added that too, so it should be basically complete now :)
Comment #28
fagoHm, setting back to needs work, as it's still open how to solve the problem in features. The current code works fine with the patch from http://drupal.org/node/551490#comment-1966640 however we probably should improve it to only store a rule name mapping in $data in the first place.
Comment #29
fagoYeppie, it's in -> It's already usable now, so I close this issue. Let's handle the remaining stuff in #573586: Fix features integration.
Comment #30
JacobSingh commentedAwesome! I'm a very excited beta tester :)
I'll try it out next week.