Subject: | Stylesheet mtime comparison broken when using custom ContentProvider |
When a resource's dependencies are checked for changes (mtime) to determine whether to serve cached output, each dependency is initialized with Apache::AxKit::Provider->new(), which calls new_content_provider(). This occurs for both content _and_ style dependencies. Style dependencies, obviously, should use new_style_provider().
The symptom of this bug is that if the ContentProvider uses a method to find the mtime that differs from that of the File provider, the style resource will report a non-accurate mtime. In my case I could modify the stylesheets and their mtime would still be reported as old so the output would not be regenerated.
To fix this we need a way to specify which items in the dependency cache are content and which are style resources. I have attached a patch against current CVS that does this by adding {style} or {content} before each dependency, and that prefix is checked later to use the correct Provider constructor.
Please check this patch to see if it is actually a sound solution (it works for me in my particular usage).
Index: lib/AxKit.pm
===================================================================
RCS file: /home/cvspublic/xml-axkit/lib/AxKit.pm,v
retrieving revision 1.43
diff -u -r1.43 AxKit.pm
--- lib/AxKit.pm 18 Mar 2003 15:20:46 -0000 1.43
+++ lib/AxKit.pm 23 Mar 2003 19:53:33 -0000
@@ -855,8 +855,12 @@
if ($depends_contents) {
DEPENDENCY:
for my $dependency (split(/:/, $depends_contents)) {
- AxKit::Debug(3, "Checking dependency: $dependency for resource ", $provider->key());
- my $dep = Apache::AxKit::Provider->new($r, key => $dependency);
+ $dependency =~ s|^\{(\w+)\}||;
+ my $dep_type = $1;
+ AxKit::Debug(3, "Checking dependency: $dependency of type $dep_type for resource ", $provider->key());
+ my $dep = ($dep_type eq "style") ?
+ Apache::AxKit::Provider->new_style_provider($r, key => $dependency) :
+ Apache::AxKit::Provider->new($r, key => $dependency);
if ( $dep->has_changed( $cache->mtime() ) ) {
AxKit::Debug(4, "dependency: $dependency newer");
return 1;
Index: lib/Apache/AxKit/Provider.pm
===================================================================
RCS file: /home/cvspublic/xml-axkit/lib/Apache/AxKit/Provider.pm,v
retrieving revision 1.13
diff -u -r1.13 Provider.pm
--- lib/Apache/AxKit/Provider.pm 18 Feb 2003 22:37:22 -0000 1.13
+++ lib/Apache/AxKit/Provider.pm 23 Mar 2003 19:53:34 -0000
@@ -20,7 +20,7 @@
$self->init(@_);
- AxKit::add_depends($self->key());
+ AxKit::add_depends("{style}".$self->key());
return $self;
}
@@ -37,7 +37,7 @@
$self->init(@_);
- AxKit::add_depends($self->key());
+ AxKit::add_depends("{content}".$self->key());
return $self;
}