Posted by Crell on January 14, 2009 at 7:16am
| Project: | CSS |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | task |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
The current implementation does not support node versions at all. It needs to, as otherwise there is no way to roll back CSS changes along with a revision.
Comments
#1
I agree. I'm working on this one.
#2
The attached patch implements support for node revisions in css module.
Please test this patch. These are the tests I'm interested:
#3
The above patch change the behaviour of using @import "?q=css/get/x"; to reference the CSS rules of other nodes.
Before x was the nid (node id) while it is now the vid (version id).
I'm not sure if it could be useful also a way to reference the latest CSS version of a css attached to a node.
With the implementation in the patch if one reference a CSS attached to a specified version of a node, and then a new version of the referenced css is available, nodes referencing the old version will be not updated with the new versions.
Probably the best workaround would be provide another hook (eg. css/get_nid/x) where x is now the nid. This hook would always returns the latest revision of the CSS.
Any other idea?
#4
I'd actually argue that we should move away from the dynamic call, as that results in two hits against Drupal. Instead, do what imagecache does a and feed in a path to drupal_add_css() (that may need to be uncacheable) that points to $files_dir/nodecss/$nid, which in turn is a menu callback that generates a file at that location. That would avoid the second hit against Drupal itself on subsequent requests. That's probably a separate issue, though.
It probably does make sense to go by vid here, though. I'll try to test this patch when sometime soon.
#5
Hi,
Just chasing this up.. Has this patch been tested yet and if so what feedback if any is there?
- Whispero
#6
Unfortunately I had a number of things explode on me in the past few weeks so I've not been able to do so. I'll let you know when I do. :-/
#7
Ok Crell,
No probs
- Whispero
#8
Still looking for feedback for the patch above. Anyone helps?
#9
Right, well, the patch in #2 no longer applies anyway, so I can't test it.
#10
Right, so it looks like the patch in #2 was written for Drupal 5 to begin with. Here's a new version for Drupal 6. I also did some documentation cleanup while I was in there to better match Drupal's documentation standards because my brain was having a parse error otherwise. :-)
#11
Thanks Crell. Unfortunately there is a problem in the update routine. Same problem also on my D5 patch.
We both did a simple
UPDATE {css} SET vid = nidWhile this works for nodes where revisions have never been used it fails if there is a revisions: it happens that nid != vid and thus data css is lost (it actually remains attached to the first revision, I think).
#12
Ok Larry, I think I fixed the problems in your patch. Here are the changes I did on your code:
I modified it to be UPDATE css c SET vid = (SELECT vid FROM node n WHERE n.nid = c.nid) which should fix the problem I explained above
Attached patch against D6-dev with the above fixes. Users interested in getting this features into css module please carefully test this.
Thanks,
Fabio Varesano
#13
The only 'bug' (if we want to call it that) that I could find is if the following has happened:
1. A revision for a node (with css) is created (i.e. rev 1 -> rev 2).
2. The patch is applied
3. The node is then reverted back to rev 1.
Rather than the CSS block not being reverted (i.e. the content remains the same as rev 2), it 'reverts' to an empty text box.
Effectively, you lose the CSS info if you revert to a version that was made prior to the patch was created.
Honestly, I am not sure if this is a bug that can be fixed. Perhaps a check could be added to see if a valid css historical revision exists - but that might get complicated.
Other than that, the patch seems to work.
Jack
#14
Of course it won't work doing that.. anyway, I don't think this is something we should take care of.
Thanks for testing the patch, I'm going to include it in the next revision.
#15
Agreed, it would be fairly hard to work out the logic. Although it's probably best we warn folks that reverting back to a node revision prior to installing the update will delete the css.
Jack
#16
Quick question... when can we expect a new revision?
Jack
#17
I have committed #12 along with an update to the install.txt file regarding the edge case noted above. It should be in the 6.x-1.x branch as soon as it regenerates.
fax8, when do you want to roll a new release?
#18
I think we can roll out a release for 6.x right now.. the code has been under testing for quite some time now and I think it's ok for a stable 6.x version. You should have the permissions to roll out a release, please do that if you have time. Otherwise, I'll do that, just let me know.
Regarding 7.x, I think I do agree with the people asking for merging with Code Per Node.
#19
Automatically closed -- issue fixed for 2 weeks with no activity.