On 12/19/2011 8:40 AM, Nick Gearls wrote:
> Directive execution order is performed in a very strange way in 
> mod_substitute.
> 
> Look at the following example:
> 
>    Substitute  "s/aaa/global/inq"
>    <Location /test/>
>      Substitute  "s/aaa/local/inq"
>    </Location>
> 
> If I have "aaa" in a page, I expect it to be replaced by "global".
> No luck, it is replaced by "local".

Not a bug.  {global} is broader scope than /test/ URI.  Therefore the
server is performing the narrowest-scope replacements, first.

Otherwise, there would be no way to fine-tune the results in more
narrow contexts!

> Even more crazy:
> 
>    <Location /test/>
>      Substitute  "s/aaa/local1/inq"
>    </Location>
>    <Location /test/>
>      Substitute  "s/aaa/local2/inq"
>      Substitute  "s/aaa/local3/inq"
>    </Location>
> 
> I expect the first directive to execute and see "local1".
> No luck again, it is replaced by "local2" - yes, not "local3".
> 
> The merging of directive by Apache is performed in the following order: 
> global, local1,
> local2, local3
> but directives are executed in the following order: : local2, local3, local1, 
> global
> 
> Am I confused or should we fix that?

I think this is fine.  It certainly should be documented, and we could
process replacements in last-to-first order within the same scope, but
I'm not sure that makes a huge difference (and would be inappropriate
to change this late in 2.2).  Since mod_substitute is gone from 2.4, I
doubt there is really an opportunity to change this anymore.

Reply via email to