[ 
https://issues.apache.org/jira/browse/WW-5767?focusedWorklogId=1047074&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1047074
 ]

ASF GitHub Bot logged work on WW-5767:
--------------------------------------

                Author: ASF GitHub Bot
            Created on: 12/Oct/26 18:03
            Start Date: 12/Oct/26 18:03
    Worklog Time Spent: 10m 
      Work Description: lukaszlenart opened a new pull request, #352:
URL: https://github.com/apache/struts-site/pull/352

   Refs [WW-5767](https://issues.apache.org/jira/browse/WW-5767), 
[WW-5766](https://issues.apache.org/jira/browse/WW-5766)
   
   ## Summary
   
   Follow-up to #351, for two 7.5.0 changes merged in apache/struts:
   
   - **WW-5767** (apache/struts#2007): `<scoped-constant>` values now go 
through the same `${...}` value substitution as `<constant>`. 
`package-configuration.md` said substitution is not supported. It now describes 
the behavior and shows an example. The note in `constant-configuration.md` that 
substitution "works only for `constant`s" now includes `scoped-constant` since 
7.5.0.
   - **WW-5766** (apache/struts#2006): Java-based configuration can now select 
`struts.scopedConstantProvider` with 
`ConstantConfig.setScopedConstantProvider(...)`. The "XML or properties 
configuration only" note is replaced.
   
   The warning that Struts core declares no scopable constant yet stays. No 
adopter has merged.
   
   ## Verification
   
   `bundle exec jekyll build` succeeds, and the new text renders on both pages.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)




Issue Time Tracking
-------------------

    Worklog Id:     (was: 1047074)
    Time Spent: 50m  (was: 40m)

> Apply value substitution to scoped-constant values, as for constant
> -------------------------------------------------------------------
>
>                 Key: WW-5767
>                 URL: https://issues.apache.org/jira/browse/WW-5767
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: XML Configuration
>            Reporter: Lukasz Lenart
>            Priority: Major
>             Fix For: 7.5.0
>
>          Time Spent: 50m
>  Remaining Estimate: 0h
>
> h2. Background
> [WW-3476|https://issues.apache.org/jira/browse/WW-3476] adds the 
> {{scoped-constant}} element to {{package}} (struts-7.5.dtd). Its values are 
> stored exactly as written: 
> {{XmlDocConfigurationProvider.loadScopedConstants}} passes the raw {{value}} 
> attribute to {{PackageConfig.Builder.addScopedConstant}}.
> The global {{constant}} element is different. Since 2.5.6 its value goes 
> through the injected {{ValueSubstitutor}} (default {{EnvsValueSubstitutor}}) 
> in {{XmlDocConfigurationProvider}} before it is registered, which resolves 
> environment variables and system properties once, at load time:
> {code:xml}<constant name="some.constant" value="${env.SOME_VALUE}"/>
> {code}
> The same expression in a scoped constant is kept literally:
> {code:xml}<package name="admin" extends="struts-default">
>     <scoped-constant name="some.scopable.constant" value="${env.SOME_VALUE}"/>
> </package>
> {code}
> h2. Why this looks unintended
> The WW-3476 design ruled out per-request expression evaluation of scoped 
> constants, because their values are static. Value substitution is something 
> else: it runs once while the configuration loads and produces a static 
> string, exactly like for {{constant}}. Leaving it out makes the two elements 
> behave differently for no design reason.
> h2. Proposal
> * In {{XmlDocConfigurationProvider.loadScopedConstants}}, run the value 
> through {{valueSubstitutor}} when one is set, the same way global constants 
> are handled.
> * No change to {{PackageConfig}}, the startup validation or 
> {{ScopedConstantProvider}}. They receive the substituted string.
> h2. Tests
> * {{XmlConfigurationProviderPackagesTest}}: a fixture with a scoped constant 
> whose value refers to a system property set by the test resolves to the 
> property's value.
> * A literal value without an expression is kept unchanged.
> h2. Documentation
> The struts-site page {{core-developers/package-configuration.md}} currently 
> says value substitution is not supported for scoped constants 
> ([apache/struts-site#351|https://github.com/apache/struts-site/pull/351]). 
> Update that sentence once this lands.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to