Jump to content

InputfieldCKEditor.module Error


kaz
 Share

Recommended Posts

PHP 8.3
ProcessWire 3.0.229

I get this error message in the CK Editor when I select a page for editing:

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /Users/username/Sites/project.com/wire/modules/Inputfield/InputfieldCKEditor/InputfieldCKEditor.module on line 205

How do I get rid of this message?

Link to comment
Share on other sites

So you go on an admin page that contains a CKEditor and you get this error?
Do you have some hooks that target CKEditor, or some special configuration for the CKEditor? Plugins, other modules that interact with it?...

The code that triggers this error is:

	public function set($key, $value) {
	
		// convert extraPlugins string to array
		// used to be stored as a string in older versions
		if($key == 'extraPlugins' && is_string($value)) {
			$value = str_replace(' ', '', $value); 
			$value = explode(',', $value); 
		} else if($key == 'extraAllowedContent') {
			$value = str_replace(array("\r\n", "\n"), "; ", trim($value)); // trim() here receives a null value
		} else if($key == 'configName') {
			$this->configName = $value;
		}
		
		return parent::set($key, $value); 
	}

So this error happens when using "extraAllowedContent" and passing null as value.

What you could do is editing this code and add a throw and look at the stacktrace to see what is calling this function with a null value (if $config->debug = true stack trace is directly shown on page):

	public function set($key, $value) {
	
		// convert extraPlugins string to array
		// used to be stored as a string in older versions
		if($key == 'extraPlugins' && is_string($value)) {
			$value = str_replace(' ', '', $value); 
			$value = explode(',', $value); 
		} else if($key == 'extraAllowedContent') {
			$value = str_replace(array("\r\n", "\n"), "; ", trim($value)); // trim() here receives a null value
            if ($value === null) throw new Exception('Check the stack trace!'); // trigger stack trace
		} else if($key == 'configName') {
			$this->configName = $value;
		}
		
		return parent::set($key, $value); 
	}

 

Edited by da²
Link to comment
Share on other sites

@da² Yes, I edit pages in the admin area. In the template I have a textarea field / CKEditor.
I don't have hooks for the editor. I have custom styles, saved in the CKEditor field > extraAllowedContent. The styles are displayed and works fine. I think that's not the problem.

/site/templates/assets/ckeditor/ckeditor.css
ckeditor:/site/templates/assets/ckeditor/ckeditor.js

With a change of the 'public function set($key, $value) …' code I get the same error message, it makes no difference. I cleared the cache, what else can I do?

What more? config: I added own styles to the editor which change the appearance of the RepeaterMatrix links. RepeaterMatrix links doesn't look very nice, so I set them as buttons. No big deal, just CSS, no JS or PHP.

$config->styles->add($config->urls->templates . 'assets/css/admin.css');

I activated and deactivated the ACF settings ... the error message remains. When I delete the field and create a new one, will I probably lose all entries from the database?

Link to comment
Share on other sites

36 minutes ago, kaz said:

I have custom styles, saved in the CKEditor field > extraAllowedContent. The styles are displayed and works fine. I think that's not the problem.

Do you still have the warning when removing this styles?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...