Repository navigation
fix(content): keep widget field values as text unless the widget allows field scripting - #38282
Conversation
…ws field scripting The content endpoints that render field values (/api/content/render/true/..., _search with "render":"true", and the GraphQL field fetchers) evaluated a widget's field values regardless of who last saved the widget, while the page render path already decided this through WidgetRenderer. Both now ask the same question through RenderFieldStrategy.rendersFieldValues, which defers to WidgetRenderer.rendersFieldVelocity for WIDGET content and leaves every other base type as it was. widgetCodeJSON follows the same rule when the caller asked for rendered fields: a widget whose field values stay as text reports an empty map, the same answer a widget that wrote no $dotJSON already gives. Fixes dotCMS/private-issues#707 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Claude finished @fabrizzio-dotCMS's task in 1m 56s —— View job Code Review
I traced the new New IssuesNo correctness, security, or convention bugs found. Notes (non-blocking, all appear intentional and are already covered by review/approval):
The Verdict: No blocking issues. Clean, well-documented, and well-tested. |
ihoffmann-dot
left a comment
There was a problem hiding this comment.
Approved ✅
Widget field values now follow the same rule as the widget endpoint: Velocity runs only when the feature flag is on and the widget's last modifier has the Scripting Developer role, otherwise the values come back as text.
The content REST endpoints, widgetCodeJSON and the GraphQL field helper all share that rule through RenderFieldStrategy.rendersFieldValues, and non-widget content types render as before.
ContentMapWidgetFieldRenderTest covers the main cases (no role, role, flag off, system user, widgetCodeJSON, GraphQL helper) and is registered in MainSuite2a, so CI runs it.
…g-content-render # Conflicts: # dotcms-integration/src/test/java/com/dotcms/MainSuite2a.java
bd3eaf5 to
b49d139
Compare
A widget's field values are evaluated as Velocity only when its last modifier holds the Scripting Developer role, so testRenderWidgetCode now checks the widget in as a user that holds it instead of relying on the data generator's default modifier. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…g-content-render # Conflicts: # dotcms-integration/src/test/java/com/dotcms/MainSuite2a.java
|
Pull Request Unsafe to Rollback!!!
|
Registering at the end of @SuiteClasses conflicts with every other PR that appends there, so the entry is placed mid-list instead. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
What
RenderFieldStrategydecided on its own whether to evaluate a widget's fieldvalues, so the content endpoints that render fields disagreed with the page
render path, which has always asked
WidgetRendererfirst. The decision nowlives in one place,
RenderFieldStrategy.rendersFieldValues:WidgetRenderer.rendersFieldVelocityWidgetRenderer.rendersFieldVelocitybecame public for that, with its Javadocreworded to say it is now the decision for the content endpoints too.
widgetCodeJSONfollows the same rule, but only when the caller asked forRENDER_FIELDS— a widget whose field values stay as text reports an emptymap, which is the answer a widget that wrote no
$dotJSONalready produces, sothe key never disappears from the response.
DotTransformerBuilder.renderFields(true)now also clearsSKIP_WIDGET_CODE_RENDERING, so the two options cannot contradict each other.Scope
WIDGET base type only. Nothing changes for other content types, for the page
render path, or for
/api/widget/.Testing
New
ContentMapWidgetFieldRenderTest(9 cases) covers both answers of therule, the flag off,
widgetCodeJSONempty vs present, a non-widget stillrendering, type-level fields, a system-user
modUser, and the staticrenderFieldValuehelper. Registered at the end ofMainSuite2a(shortest-running compatible suite: median 23.7 min vs 40-46 min for the
alternatives across PRs 38226, 38219, 38213, 38210, 38206).
Ran locally with the build cache disabled, together with the four neighbouring
classes that exercise the same strategies:
Fixes dotCMS/private-issues#707
🤖 Generated with Claude Code