Skip to content

fix(core): [FIX] share addDataToView data with Blade views#2322

Open
middleDuckAi wants to merge 1 commit intoevolution-cms:3.5.xfrom
middleDuckAi:middleDuck/evo-2321-add-data-to-view
Open

fix(core): [FIX] share addDataToView data with Blade views#2322
middleDuckAi wants to merge 1 commit intoevolution-cms:3.5.xfrom
middleDuckAi:middleDuck/evo-2321-add-data-to-view

Conversation

@middleDuckAi
Copy link
Copy Markdown
Collaborator

Summary

Fixes #2321.

evo()->addDataToView() already stored the payload in the internal view-data buffer, but that data was only passed directly to the top-level Blade template render. The data was not also shared through the Laravel view factory, so nested or separately rendered Blade views could miss the values and debugging showed the private dataForView buffer instead of a public access path.

This keeps dataForView encapsulated and exposes the data through the view layer instead of making the property public.

What changed

  • Core::addDataToView() now validates array input, keeps returning the Core instance for chaining, stores the data, and shares it with the bound view factory.
  • Blade document rendering now uses getDataForView() and shares the merged core document data plus added view data with both the main view factory and DLTemplate blade bridge.
  • Added a focused unit test covering stored data, shared view data, and safe non-array input handling.

Verification

  • php -l core/src/Core.php
  • php -l core/tests/Unit/CoreAddDataToViewTest.php
  • ./vendor/bin/pest tests/Unit/CoreAddDataToViewTest.php passed locally after installing dev dependencies for the test run.

Database matrix

Not applicable. This change does not touch schema, migrations, seed data, or update-time database repair.

@middleDuckAi middleDuckAi added Area/Core Type/Bug Status/PR-ready Fix implemented, pull request opened, awaiting review/test labels Apr 28, 2026
@ericfilippi
Copy link
Copy Markdown

I tried your changes locally, it's works great. Thank you !

@middleDuckAi
Copy link
Copy Markdown
Collaborator Author

Always happy to help, and thank you for testing it locally!

If you run into any other bugs, missing pieces, or ideas for things you would like to see improved in Evolution CMS, feel free to open an issue or mention me there. I will be glad to look into it and help get it done.

@ericfilippi
Copy link
Copy Markdown

ericfilippi commented Apr 29, 2026

I also found a bug with DocLister with php, can you tell me who is in charge ? I saw in evo extra that the code hasn't changed since 2020 ...
DLMenu throws and error in the manager when trying to get documents from the root parent (which is id 0) :

when I disconnect from the manager, I don't get the error and the website is loading correctly.
when I'm connected to the manager, I get the following errors :
« Evolution CMS Parse Error »
Error : Undefined array key 0
Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in core/functions/actions/mutate_content.php on line 70
Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in core/functions/actions/mutate_content.php on line 70
Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in core/functions/actions/mutate_content.php on line 70
Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in core/functions/actions/mutate_content.php on line 70
Warning: Undefined array key 0 in core/src/Core.php on line 4981

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area/Core Status/PR-ready Fix implemented, pull request opened, awaiting review/test Type/Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

using evo()->addDataToView($data)

2 participants