I have just updated from 8.x-1.9 to 8.x-1.13. When I try to install a new site from my configuration I get the following error:
Undefined variable: default_filter_format eu_cookie_compliance.install:110
Undefined variable: default_filter_format eu_cookie_compliance.install:114
Undefined variable: default_filter_format eu_cookie_compliance.install:118
Undefined variable: default_filter_format eu_cookie_compliance.install:122

It looks like the code added in 3176439 declares the variable $default_filter_format within the if-statement and my code doesn't go in there.
I tried moving the declaration to outside the if-statement but then I get the error reported in that issue.

CommentFileSizeAuthor
#12 3179133-after.png45.62 KBbaikho
#12 3179133-before.png80.99 KBbaikho
#8 3179133-8.patch503 bytesheddn

Comments

emek created an issue. See original summary.

emek’s picture

In my setup I can get rid of the message by declaring the variable with a format I have before the if-statement. But there might be a better way that could work for everyone?

svenryen’s picture

I see. What text formats do you have in your config?

Can you live with these notices? Does it work otherwise or is functionality missing or broken because the module failed to find a valid text format at install?

emek’s picture

It seems to work, I see the text on the settings page and it shows as Full HTML, but I think that's because I have that value in my configuration.

The formats I have are basic_html and full_html.

Isn't there some way to set some default value for the format, so we can declare the variable and don't get the error message?

svenryen’s picture

In my opinion there's a bug in filter_default_format() that led to the workaround which, although not ideal, seems to work.

I'll check again, though probably not until next week. If you could send me your config, that would be great.

Patches are also welcome.

svenryen’s picture

Isn't there some way to set some default value for the format, so we can declare the variable and don't get the error message?

We have no way of knowing in advance what formats are available, so we can't really set some default value for the format.

emek’s picture

I did create a patch for our environment but that will only work for sites with the same format we have.
If anyone else has this problem and finds this issue, then the patch basically looks like this:

diff --git a/eu_cookie_compliance.install b/eu_cookie_compliance.install
index c324a4f..64019e7 100644
--- a/eu_cookie_compliance.install
+++ b/eu_cookie_compliance.install
@@ -91,6 +91,8 @@ function eu_cookie_compliance_install() {
 
   $all_filter_formats = filter_formats(\Drupal::currentUser());
 
+  $default_filter_format = 'basic_html';
+
   if (count($all_filter_formats)) {
     // Determine the best default text format to use.
     $default_filter_format = filter_default_format();
heddn’s picture

Status: Active » Needs review
StatusFileSize
new503 bytes

This will get around the issue. See comments on filter_fallback_format().

Status: Needs review » Needs work

The last submitted patch, 8: 3179133-8.patch, failed testing. View results

emek’s picture

The patch in #8 removes the error message for me.

svenryen’s picture

Status: Needs work » Needs review
baikho’s picture

Version: 8.x-1.13 » 8.x-1.14
Status: Needs review » Reviewed & tested by the community
StatusFileSize
new80.99 KB
new45.62 KB

#8 works for me.

Tested on 1.14.0 and core 9.1.4.

Before:

After:

neslee canil pinto’s picture

Status: Reviewed & tested by the community » Fixed

Committed to the dev branch. Don't know but when I had pushed my network connection went down and I can't see the commit list, but it is committed into the dev branch.

neslee canil pinto’s picture

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

Status: Fixed » Closed (fixed)

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