I'm aware of #617596: Non-empty Summary and empty Body both become empty when saved.. This actually a follow-on. I was doing some profiling of htmlpurifier and noticed something strange with really short entries in a node's 'value'. So short that there is no 'summary'. It still passed the text value of the body to filter.module. This is unnecessary, since the text is an empty string.

Comments

heddn’s picture

StatusFileSize
new557 bytes
heddn’s picture

Oops, added patch to the wrong issue. Ignore #1.

penyaskito’s picture

Status: Active » Needs review

Go testbot, go!

Status: Needs review » Needs work

The last submitted patch, htmlpurifier-filter_empty_text-1821186.patch, failed testing.

heddn’s picture

Status: Needs work » Needs review

drupal-d8-text_field_load.patch queued for re-testing.

penyaskito’s picture

Status: Needs review » Reviewed & tested by the community

The patch at the summary seems to do the work and tests are green.

catch’s picture

Status: Reviewed & tested by the community » Patch (to be ported)
Issue tags: +Needs backport to D7

This ternary is getting very long:

-          $items[$id][$delta]['safe_summary'] = isset($item['summary']) ? _text_sanitize($instances[$id], $langcode, $item, 'summary') : '';
+          $items[$id][$delta]['safe_summary'] = isset($item['summary'])  && $item['summary'] !== '' ? _text_sanitize($instances[$id], $langcode, $item, 'summary') : '';

Could we split it into an if?

Would also be good to do an xhprof run just to show there's no need to format this. Seems like this one is backportable to 7.x as well.

heddn’s picture

I tried running xhprof on D8, but I couldn't easily port htmlpurifier since the caching mechanism changes so dramatically in D8. Here's a callgraph from xhprof (D7). Its only called from _field_invoke_multiple when I view the content of a node that fires the htmlpurifier filter imediately after clearing cache. And a reformatted patch with if/else clauses.

effulgentsia’s picture

Status: Patch (to be ported) » Needs review

Status: Needs review » Needs work

The last submitted patch, drupal-text_field_load-1821178-8.patch, failed testing.

heddn’s picture

Status: Needs work » Needs review
StatusFileSize
new1.37 KB

Rerolled

Stalski’s picture

Issue tags: -Needs backport to D7

#11: drupal-text_field_load-1821178-11.patch queued for re-testing and if green, bumping this issue

Status: Needs review » Needs work
Issue tags: +Needs backport to D7

The last submitted patch, drupal-text_field_load-1821178-11.patch, failed testing.

heddn’s picture

Version: 8.x-dev » 7.x-dev
Issue tags: -Needs backport to D7

This doesn't need to be applied to D8 in its current state. The logic to handle empty summaries was put in place with a2c2367. So, this simply needs a backport.

heddn’s picture

Status: Needs work » Needs review
StatusFileSize
new1.42 KB

Patch submitted by the Drush iq-submit command.

jenlampton’s picture

Issue summary: View changes
poker10’s picture

StatusFileSize
new581 bytes

There are 8 usages of the _text_sanitize() function in D7 core (plus some usages in tests): https://api.drupal.org/api/drupal/modules%21field%21modules%21text%21text.module/function/calls/_text_sanitize/7.x

Wouldn't it be better to apply the non-empty check directy into the _text_sanitize() function, which would cover all other usages? Otherwise this patch is optimizing only the _text_sanitize() call in the text_field_load() function (not sure if this partial effort is worth the effort). But please correct me if I am wrong or if I missed something.

Attaching a simple patch what I had in mind.

poker10’s picture

Issue tags: +Pending Drupal 7 commit

There are two points to consider:

1. The last patch will not catch NULL values (which can happen on PHP 8+). These NULLs are handled by string conversion in check_markup, see:

$text = (string) $text;

This is not optimal, but changing to patch to catch all possible empty input values will be a bigger change. I think the current change is a safer approach.

2. We can consider moving the empty check even deeper - to the check_markup.

Adding a tag so that another D7 maintainer can have a look.

  • mcdruid committed d8dd20c9 on 7.x
    Issue #1821178 by heddn, poker10: Performance tune text_field_load()
    
mcdruid’s picture

Status: Needs review » Fixed
Issue tags: -Pending Drupal 7 commit

Yeah it's tempting to just check for an empty() value in the column but as you say probably safer to keep to this very straightforward change especially as we're not adding any tests here.

Thanks everyone!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.