Problem/Motivation

Plugin filter process method actually return string.
This generate an error since plugin process should return \Drupal\filter\FilterProcessResult.

To reproduce, enable prism filter in a format and save a content with this format. The error will occur.

Proposed resolution

plugin process should return \Drupal\filter\FilterProcessResult.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

GoZ created an issue. See original summary.

GoZ’s picture

Title: Plugin filter should not return string » Plugin filter process should not return string
Issue summary: View changes
GoZ’s picture

Status: Active » Needs review
FileSize
1.3 KB

Here is a path to fix this issue.

GoZ’s picture

FileSize
1.88 KB

I also add here libraries.
I cannot make another issue since we use FilterProcessResult to add libraries.
So the attached patch is same as comment #3 with libraries (based on fact css and js files are in sites/all/libraries/prism as defined in README.txt)

rooby’s picture

I'm using this patch for the libraries addition and it is working as expected.

From a coding standards point of view the patch is fine too.

I'm not currently using the prism filter though so I haven't actually done testing on that aspect.

GoZ’s picture

Issue summary: View changes
scuba_fly’s picture

Status: Needs review » Reviewed & tested by the community

Confirming #4 works.

This could also work:
$text->setProcessedText(str_replace($search, $replace, $text->getProcessedText()));

if you replace the line return str_replace($search, $replace, $text);with above in PrismFilter.php

moonray’s picture

The patch in #4 fixes a critical error. I didn't try the suggestion in comment #7.

Chroid’s picture

I can also confirm I'm receiving this error after a initial install and enabling of the module:

The website encountered an unexpected error. Please try again later.
Recoverable fatal error: Argument 1 passed to Drupal\Core\Render\BubbleableMetadata::merge() must be an instance of Drupal\Core\Cache\CacheableMetadata, string given, called in ...../core/modules/filter/src/Element/ProcessedText.php on line 113 and defined in Drupal\Core\Render\BubbleableMetadata->merge() (line 26 of core/lib/Drupal/Core/Render/BubbleableMetadata.php).

Applying @GoZ's patch from #4 resolves these issues immediately.

Should/could this be committed against dev so that every new install isn't killing people's sites as soon as it's enabled and used ?

MykolaVeryha’s picture

Version: 8.x-1.x-dev » 8.x-1.0
DuaelFr’s picture

Version: 8.x-1.0 » 8.x-1.x-dev

Nice job here!
Can we get it commited and have a new release to celebrate? <3

eojthebrave’s picture

Status: Reviewed & tested by the community » Fixed

It looks like this was resolved in the 8.x-1.0 branch at some point in the past.

And is also resolved in the 2.0.x branch. So I'm going to go ahead and close this issue. Thanks everyone.

eojthebrave’s picture

Status: Fixed » Closed (fixed)

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