Closed (fixed)
Project:
Drupal core
Version:
11.x-dev
Component:
text.module
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
19 Jan 2026 at 23:34 UTC
Updated:
26 Mar 2026 at 14:50 UTC
Jump to comment: Most recent
Deprecate the text_summary function so the .module can be deleted later.
Deprecate and move to a new service.
TextSummary::class generate
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
smustgrave commentedThis may be ready.
Comment #4
smustgrave commentedTurned to a helper per @mstrelan suggestion
Comment #5
dcam commentedThe helper class looks good to me. I think the last piece of this is to update the change record and issue summary. I suggest that you point out that the new function is internal. It took me a minute to catch on.
Comment #6
smustgrave commentedCompletely forgot about the CR, updated!
Comment #7
nicxvan commentedGot a couple suggestions, we gotta do removals in 13 at this point.
Comment #8
dcam commentedI think this looks good.
Comment #9
berdirI think we can improve this, posted a review.
Comment #10
berdirI only saw now that the suggestion is to make this internal, but I'm not sure. What exactly is internal even in the scope of core? there is a call in node module for example. I'd argue that internal is something that should only be used within the same module or namespace.
It's a very hard thing to search for in contrib, matches lots of strings and module names and what not, but I think there's value in this being a non-internal API.
Comment #11
smustgrave commentedComment #12
smustgrave commentedRemoved the typehints as it caused a test failure. So not sure if it's in scope to add here or not.
Comment #13
berdirThe number of test fail seems pretty limited and a clear indication that the current docs are incomplete and not correct:
TypeError: Drupal\text\SummaryGenerator::generateSummary(): Argument #1 ($text) must be of type string, Drupal\filter\Render\FilteredMarkup given, called in core/modules/text/tests/src/Kernel/TextSummaryTest.php on line 356
I think if you allow string|\Stringable then that should work.
It's much easier to make sure we have the correct type and docs now rather than change an existing method later.
Comment #14
smustgrave commentedPretty sure there’s some bugs opened against this function too
Comment #15
nicxvan commentedComment #16
nicxvan commentedThis is ready again, I converted it to a service removed static, added DI and fixed typing.
Comment #17
berdirI think it's better as a service, thanks. The one remaining bit for me is to decide whether we want to follow my suggestion of the size default config and not support that from the start in the new service. As mentioned, it's easier to define the size parameter as required now and keep the config in the BC layer as opposed to changing it later. As far as I see, there are no tests or calls that rely on the implicit value right now, so there shouldn't be any changes to the current calls?
Comment #18
nicxvan commentedI'm not sure why we would drop the size config, is it to just remove the config dependency?
Comment #19
berdirSee https://git.drupalcode.org/project/drupal/-/merge_requests/14416#note_67..., @smustgrave wants to remove that setting and whole config object entirely. It's unused in core as $size is never NULL and it has no UI. My suggestion might be the easiest way to get there.
Comment #20
nicxvan commentedWhat about this as a compromise here?
We drop passing in null to the new service, we drop reading the config and we handle the config cleanup and dropping it here: #3436677: Remove text.settings config since it's only used in 1 place
Comment #21
smustgrave commentedFYI compromise proposed LGTM!
Comment #22
mstrelan commentedTo bike shed a bit:
What about
TextSummary::generate? Or do we want the word generator in the class? Feel free to ignore this comment as I don't have particularly strong feelings here.Comment #24
nicxvan commentedThat is better naming, I pushed it.
Comment #25
nicxvan commentedComment #26
smustgrave commentedSince I personally didn't work on that last bit of stuff I'm going to stretch it and mark.
Comment #27
godotislateA couple small comments on the MR. I also took a pass at assigning credit and made small edits to the CR.
FYI, in kernel tests,
Drupal::service()is generally safer than$this->container->get(), because$this->container->get()can point at outdated objects after a container rebuild.In Functional tests, the use of either is essentially equivalent since #2066993: Use magic methods to sync container property to \Drupal::getContainer in functional tests.
Comment #28
smustgrave commentedTried to address the feedback but adding delcare=strict broke a bunch of tests is that needed at this moment or could be a follow up?
Comment #29
smustgrave commentedA lot of tests seem to pass markup to
string|\Stringable $text,Comment #30
smustgrave commentedMay be related #3067124: text_summary() returns a plain string, even if passed a MarkupInterface object
Comment #31
godotislateThe thing is that if we don't do it now, it'll be more difficult to do later.
I think we can do it here with a few minor changes. Made the suggestions on the MR.
Comment #32
smustgrave commentedThat seemed to work and still leaves us open to address issue in #30
Comment #33
dcam commentedI did a fresh complete review since a lot has happened since I last looked at this. I commented on a few things. I have a concern about the
generate()function's return type and I left a couple of minor suggestions on the test.Comment #34
dcam commentedThe test failure looks random. LGTM.
Comment #35
mstrelan commentedI had the same failing test, opened #3578666: Fix AssetAggregationAcrossPagesTest
Comment #36
godotislateThe test failure is upstream #3578653: AssetAggregationAcrossPagesTest is broken.
I think this looks good, but will wait for that one to get in.
Comment #37
godotislate#3578653: AssetAggregationAcrossPagesTest is broken is in. Can someone merge in latest main to get the tests run updated?
Comment #38
smustgrave commentedRebased
Comment #39
smustgrave commentedSike @dcam beat me to it!
Comment #43
godotislateCommitted f929b61 and pushed to main and acf3e5f and pushed to 11.x. Thanks!