Problem/Motivation
Currently TextItemBase::generateSampleValue() sets the summary value to be identical to the full text value:
if (empty($settings['max_length'])) {
// Textarea handling
$value = $random->paragraphs();
}
else {
// Textfield handling.
$value = substr($random->sentences(mt_rand(1, $settings['max_length'] / 3), FALSE), 0, $settings['max_length']);
}
$values = array(
'value' => $value,
'summary' => $value,
'format' => filter_fallback_format(),
);
This makes it useless for testing the behavior of the summary. No trimmed summary will ever appear for generated content, because it is always overridden with the full text. So (e.g.) article content generated with a tool like devel will never have teasers.
Proposed resolution
Simply remove the line that sets summary and let the field summary behavior itself be tested too.
Since this involves changing the behavior of an existing API method, it is disruptive and therefore targeted for the next development minor (8.2.x).
Remaining tasks
Patch needs tests and review.
User interface changes
N/A
API changes
TextItemBase::generateSampleValue() no longer sets the summary to be the full text of the field.
Data model changes
N/A
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | 2685065-nr-bot.txt | 137 bytes | needs-review-queue-bot |
| give-me-teasers.patch | 556 bytes | xjm |
Comments
Comment #2
xjmComment #3
dawehnerWhat about generating sometimes a custom summary and sometimes not? This would allow you to test both potential usecases.
Comment #4
JvE commentedI agree with this patch.
Only
TextWithSummaryItemhas asummaryproperty.TextItemandTexLongtItemdo not, but thegenerateSampleValue()currently returns a'summary'value for them as well.How about also overriding
generateSampleValue()inTextWithSummaryItemto add a summary there?Comment #18
smustgrave commentedIs this a duplicate of #2774445: Text field summary should be filled with short text ?
Comment #19
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.