We're running Drupal 7.17. We've updated core multiple times thoughout the project and have noticed that we can never access safe_value. If we try using safe_value nothing prints out for this value. It's blank. If we use Devel to inspect the object (such as body field or another field) the safe_value is never present. This is only happening on this one install/site. Any suggestions/ideas on where to look to debug this?

-Trevor

Comments

ambientdrup’s picture

I've figured this out!

If I change the text processing on the Body field in the content type to "Plain Text" (vs. filtered text) then the safe_value shows up on the Body object in Devel.

So there's something causing the issue with the text processing when it's set to filtered text (user selects format). It works fine with plain text. Or is this by design in Drupal 7.x core?

So this shows that it is working with our core install. It's just that our text processing is messing it up somewhere when we have filtered text selected as the text processing. It works when plain text is selected.

Does this make sense?

-Trevor

ambientdrup’s picture

But I still have a question here - why does safe_value not show up in Devel when you have another text processing like Full HTML set on the field? Shouldn't that also be available to the array in Devel when you inspect the element?

-Trevor

h3rj4n’s picture

The safe_value should always popup. Tested on a site of mine and there the safe_value is set even with plain_text.

But you are saying that the safe_value doesn't popup when the text processing is set to Full HTML?

Is it possible that when there are no filters present in '/admin/config/content/formats' one of these filters there isn't a safe_value?

ambientdrup’s picture

So I checked my formats. I have the Node Embed module installed and this adds a checkbox to the formats to allow for an additional filter called "Insert Node". When I save the format with the Insert Node filter, then I can't get safe_value to show/work. So there's some conflict going on with the Node Embed module. I've verified this both on my local dev site and our staging site.

-Trevor

ajdonnison’s picture

This appears to be when you have multiple filters (or modules that silently implement filters) that extensively use preg_replace_callback or preg_replace with the 'e' modifier. If you edit php.ini and update the pcre.backtrack_limit to a higher value this should resolve the issue. The default value is 100000, adding two more zeroes fixed the problem for me, ymmv.

pivanov’s picture

Issue summary: View changes

The value key "save_value" of "Long Text" fields is set given either of these two is true:
1) text processing is NOT enabled,
2) text processing is enabled and all filters associated with the format are cachable (see the filter info hook)
See https://api.drupal.org/api/drupal/modules%21field%21modules%21text%21tex...
Note that this applies to fields being attached to the node when the node is loaded.

For display purposes, such as printing the values from the node template, see the field_attach_prepare_view() function which will actually prepare a renderable array, that will apply the proper text format.

Version: 7.17 » 7.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.

Status: Active » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.