Slowly, very slowly start OOPifying the render system

Created on 19 May 2025, 11 days ago

Problem/Motivation

It's 2025. The render API suspiciously looks like form API when we added it 20 years ago.

Steps to reproduce

Proposed resolution

For now, add an object wrapper around the render array.

  1. ElementInfoManager::fromRenderArray() creates an ElementInterface plugin from a render array and stores a reference to said render array.
  2. Add __set and __get to RenderElementBase allow using the render properties as object properties.
  3. Add @property documentation on the render element plugins.
  4. Add a few child methods addChild, removeChild, getChildren to allow manipulating children of render element plugins.

Nothing more for now. Small moves.

Remaining tasks

  1. fromRenderArray is now not the best name. Or is it?
  2. Write tests.
  3. Credit andypost and kingdutch on the issue for their valuable insights in Slack.
  4. Convert all core and contrib to the new API and drop render arrays. (Should be an easy, simple followup.)

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

📌 Task
Status

Needs review

Version

11.0 🔥

Component

render system

Created by

🇨🇦Canada Charlie ChX Negyesi 🍁Canada

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @Charlie ChX Negyesi
  • Pipeline finished with Success
    11 days ago
    Total: 542s
    #501154
  • Pipeline finished with Failed
    11 days ago
    Total: 193s
    #501221
  • Pipeline finished with Success
    11 days ago
    Total: 595s
    #501367
  • Pipeline finished with Success
    10 days ago
    Total: 743s
    #501561
  • Pipeline finished with Failed
    9 days ago
    Total: 142s
    #502921
  • Pipeline finished with Failed
    9 days ago
    Total: 788s
    #503313
  • Pipeline finished with Failed
    9 days ago
    Total: 126s
    #503351
  • Pipeline finished with Canceled
    9 days ago
    Total: 135s
    #503359
  • Pipeline finished with Failed
    9 days ago
    Total: 442s
    #503364
  • Pipeline finished with Success
    9 days ago
    Total: 3300s
    #503405
  • Pipeline finished with Failed
    9 days ago
    Total: 180s
    #503423
  • Pipeline finished with Failed
    9 days ago
    #503424
  • Pipeline finished with Canceled
    9 days ago
    #503443
  • Pipeline finished with Success
    8 days ago
    Total: 2531s
    #503450
  • Pipeline finished with Success
    8 days ago
    Total: 600s
    #503472
  • 🇺🇸United States moshe weitzman Boston, MA
  • 🇺🇸United States dww
  • 🇺🇸United States dww
  • 🇫🇷France andypost

    It looks great idea to git in for D12!

    btw it will raise a question of DI for elements as related still)

  • Pipeline finished with Success
    8 days ago
    Total: 743s
    #503779
  • Pipeline finished with Canceled
    8 days ago
    Total: 314s
    #503931
  • Pipeline finished with Failed
    8 days ago
    #503940
  • Pipeline finished with Success
    8 days ago
    Total: 513s
    #504351
  • First commit to issue fork.
  • 🇺🇸United States nicxvan

    I converted FieldThirdPartyTestHooks as well so we convert something that isn't a form_alter.

    I think a couple of examples outside of tests would be good too.

  • Pipeline finished with Failed
    7 days ago
    Total: 816s
    #504389
  • 🇺🇸United States nicxvan

    The functional JS test was failing, in hindsight it was kind of obvious what I missed.

    I passed the objects back into the array assuming that toRenderArray would be called as necessary upstream. The idea that @moshe had to add a key property we can set and return the object directly would be nice too.

    I got InvalidArgumentException: "field_test_field_formatter_third_party_settings_form" is an invalid render array key. Value should be an array but got a object. in Drupal\Core\Render\Element::children() (line 97 of /var/www/html/core/lib/Drupal/Core/Render/Element.php).
    when running through the test manually.

    For this particular test: https://git.drupalcode.org/project/drupal/-/merge_requests/12173/diffs?c... fixes it by converting back to the render array.

  • Pipeline finished with Success
    7 days ago
    #504404
  • Pipeline finished with Failed
    7 days ago
    Total: 560s
    #504642
  • Pipeline finished with Failed
    7 days ago
    Total: 603s
    #504800
  • 🇺🇸United States dww

    By request from chx in Slack, adding more credits

  • One test failure:
    Drupal\Tests\system\Functional\Form\ArbitraryRebuildTest::testUserRegistrationRebuild
    Behat\Mink\Exception\ElementNotFoundException: Button with id|name|label|value "Rebuild" not found.

    Don't think I've seen this one as an intermittent failure.

  • Pipeline finished with Failed
    7 days ago
    #505004
  • 🇺🇸United States nicxvan
  • 🇺🇸United States dww

    First real look at the MR. Mostly nits. A few questions of substance. Out of time for now. More later...

  • Pipeline finished with Success
    7 days ago
    Total: 624s
    #505072
  • Pipeline finished with Failed
    7 days ago
    Total: 274s
    #505228
  • Pipeline finished with Failed
    6 days ago
    Total: 353s
    #505503
  • Pipeline finished with Failed
    6 days ago
    Total: 265s
    #505528
  • Pipeline finished with Failed
    6 days ago
    Total: 517s
    #505550
  • Pipeline finished with Failed
    6 days ago
    Total: 140s
    #505576
  • Pipeline finished with Failed
    6 days ago
    Total: 462s
    #505594
  • 🇨🇦Canada Charlie ChX Negyesi 🍁Canada

    phpcs won, I am done.

  • 🇺🇸United States dww

    @chx: really? Please. The drama is helping no one. phpcs is a tool. It’s not hard to use. You can configure your IDE to get it right. You don’t need to take it so personally and get so worked up and angry over it. Please take some deep breaths, and maybe a day off, but spare us the public agony and tantrum over how having standards is an impediment to velocity.

    We’ve been in this together for nearly 2 decades now. You know how much respect I have for you and your abilities. Please know I’m only writing this out of love and care. I invite you to relax and have some perspective.

    Thanks,
    -Derek

  • 🇺🇸United States nicxvan

    I've added skip rules for a bunch of jobs while we continue to work on architecture, maybe it's worth configuring this so draft MRs don't run these tests by default so that the actual architecture can happen unimpeded, then once the MR is no longer draft we can fix phpcs etc.

    I've also added the fix for the fromClass work. I tried running the test locally but for some reason they wouldn't start.

  • Pipeline finished with Failed
    5 days ago
    Total: 635s
    #505757
  • 🇺🇸United States nicxvan

    Turns out core seems to ignore these flags, I just set them to allow failure.

  • Pipeline finished with Failed
    5 days ago
    Total: 486s
    #505767
  • Pipeline finished with Failed
    5 days ago
    Total: 1628s
    #505946
  • Pipeline finished with Running
    5 days ago
    Total: 754s
    #505965
  • Pipeline finished with Failed
    4 days ago
    Total: 495s
    #506324
  • 🇺🇸United States nicxvan
  • Pipeline finished with Failed
    4 days ago
    Total: 167s
    #506372
  • 🇺🇸United States nicxvan

    Added a test that swaps out a class and added something to attempt to make the standalone wrappers nicer.

    There are several failures, we could possibly revert that, but let's think on it a bit.

    I updated the IS as well with some next steps, this could use a pass on comments, and we need to finish tests and tidy up the deprecations.

  • 🇫🇷France nod_ Lille

    Adding just in case

  • Pipeline finished with Failed
    4 days ago
    Total: 1369s
    #506757
  • Pipeline finished with Failed
    4 days ago
    Total: 582s
    #506781
  • Pipeline finished with Success
    4 days ago
    Total: 602s
    #507038
  • 🇺🇸United States nicxvan

    Thanks @nod_

    I removed the skip since it doesn't work anyway here is the issue to track: 📌 Consider allowing first stage tests to fail when an MR is in draft. Active

  • Pipeline finished with Success
    4 days ago
    Total: 2057s
    #507054
  • Pipeline finished with Failed
    3 days ago
    Total: 219s
    #507082
  • Pipeline finished with Failed
    3 days ago
    Total: 135s
    #507558
  • Pipeline finished with Failed
    3 days ago
    Total: 756s
    #507582
  • Pipeline finished with Success
    3 days ago
    Total: 681s
    #507612
  • 🇺🇸United States nicxvan

    Ok this needs some additional tests, but we are in a good spot for another review.

  • 🇺🇸United States nicxvan
  • Pipeline finished with Failed
    3 days ago
    Total: 158s
    #507775
  • Pipeline finished with Failed
    3 days ago
    Total: 145s
    #507777
  • Pipeline finished with Success
    3 days ago
    Total: 2012s
    #507789
  • Pipeline finished with Success
    3 days ago
    Total: 472s
    #507823
  • 🇺🇸United States nicxvan

    I think this is ready for review again, we've added tests and addressed most of the feedback.

    I also added the deprecation.

    Beyond review it might be worth identifying a few more things to convert.

  • 🇺🇸United States nicxvan
  • 🇺🇸United States nicxvan
  • Pipeline finished with Success
    2 days ago
    Total: 769s
    #508033
  • 🇺🇸United States nicxvan
  • Pipeline finished with Failed
    2 days ago
    Total: 152s
    #508472
  • 🇺🇸United States nicxvan

    Thank you for the reviews! The latest round of comments should all be addressed. I left a few open that still need confirmation that the answers are acceptable.

  • Pipeline finished with Failed
    2 days ago
    Total: 144s
    #508549
  • Pipeline finished with Failed
    2 days ago
    Total: 852s
    #508584
  • Pipeline finished with Success
    2 days ago
    Total: 397s
    #508610
  • Merge request !12263Apply 2 suggestion(s) to 1 file(s) → (Open) created by nicxvan
  • Pipeline finished with Failed
    1 day ago
    Total: 287s
    #509015
  • Pipeline finished with Failed
    about 23 hours ago
    Total: 604s
    #509503
  • Pipeline finished with Failed
    about 21 hours ago
    Total: 463s
    #509595
  • Pipeline finished with Failed
    about 1 hour ago
    #510256
  • Pipeline finished with Failed
    28 minutes ago
    #510305
Production build 0.71.5 2024