diff options
author | Simon McVittie <smcv@debian.org> | 2014-03-03 11:30:36 +0000 |
---|---|---|
committer | Simon McVittie <smcv@debian.org> | 2014-03-03 11:30:36 +0000 |
commit | 24599e3cc9acf801caa0be6c2428dd86f21b53c3 (patch) | |
tree | 40c1abd9a5c79e980cd99be99bf712cb9145eb2c /IkiWiki | |
parent | 8142406c3121967289c38152c5bed5141780be48 (diff) | |
download | ikiwiki-24599e3cc9acf801caa0be6c2428dd86f21b53c3.tar ikiwiki-24599e3cc9acf801caa0be6c2428dd86f21b53c3.tar.gz |
In all=no conditionals, depend on the influences, not the test pagespec
Previously, if a page like `plugins/trail` contained a conditional like
[[!if test="backlink(plugins/goodstuff)" all=no]]
(which it gets via `templates/gitbranch`), then the
[[plugins/conditional]] plugin would give `plugins/trail` a dependency on
`(backlink(plugins/goodstuff)) and plugins/trail`. This dependency is
useless: that pagespec can never match any page other than
`plugins/trail`, but if `plugins/trail` has been modified or deleted,
then it's going to be rendered or deleted *anyway*, so there's no point
in spending time evaluating match_backlink for it.
Conversely, the influences from the result were not taken into account,
so `plugins/trail` did not have the
`{ "plugins/goodstuff" => $DEPEND_LINKS }` dependency that it should.
Invert that, depending on the influences but not on the test.
Bug: http://ikiwiki.info/bugs/editing_gitbranch_template_is_really_slow/
Diffstat (limited to 'IkiWiki')
-rw-r--r-- | IkiWiki/Plugin/conditional.pm | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/IkiWiki/Plugin/conditional.pm b/IkiWiki/Plugin/conditional.pm index 0a3d7fb4c..b450f1a0a 100644 --- a/IkiWiki/Plugin/conditional.pm +++ b/IkiWiki/Plugin/conditional.pm @@ -33,11 +33,15 @@ sub preprocess_if (@) { # An optimisation to avoid needless looping over every page # for simple uses of some of the tests. $params{test} =~ /^([\s\!()]*((enabled|sourcepage|destpage|included)\([^)]*\)|(and|or))[\s\!()]*)+$/) { - add_depends($params{page}, "($params{test}) and $params{page}"); $result=pagespec_match($params{page}, $params{test}, location => $params{page}, sourcepage => $params{page}, destpage => $params{destpage}); + my $i = $result->influences; + foreach my $k (keys %$i) { + # minor optimization: influences are always simple dependencies + $IkiWiki::depends_simple{$params{page}}{lc $k} |= $i->{$k}; + } } else { $result=pagespec_match_list($params{page}, $params{test}, |