On a development site, with all current modules, I am having an issue with trying to get views exposed form fields to stick.

I can build the view, preview it, save it, seeing the exposed filters. 

After cache clear they are gone. 

Rinse, repeat, same problem.

The dblog shows 2 line entries relevant:

Warning: Array to string conversion in _views_data_process_entity_types() (line 109 of /var/www/clients/client1/web1/web/core/modules/views/includes/cache.inc).


Warning: Trying to access array offset on value of type null in _field_info_prepare_instance_display() (line 385 of /var/www/clients/client1/web1/web/core/modules/field/field.info.inc).

PHP 8.0-fpm, Nginx, on Ubuntu

Accepted answer

This issue (duplication of views definitions) has been reported in the issues queue for Registration (see https://github.com/backdrop-contrib/registration/issues/33).

A workaround is to download the DEV version of Registration at:

https://github.com/backdrop-contrib/registration/archive/refs/heads/1.x-...

The DEV version includes a fix for this.

You'll need to trash the current Registration folder, unzip the above, and RENAME it to registration.

The drawback of doing this is that Backdrop won't detect new releases of Registration if any. But you can make a note to yourself to check Registration periodically, and when a new release comes out, replace the dev version with the latest version. 

Most helpful answers

Great! 

Regarding the other warning: let's try some debugging.

Can you add the following to line 386 of the file field.info.inc? The line right after where the warning happens.

if (empty($formatter_type['module'])) {dpm($field, 'field'); dpm($display, 'display');}

By the way, don't forget to remove all those debugging lines after you are done.

 

Thanks for posting, onyx. The view looks fine. I see that there are a couple of exposed filters: field_id (which looks like a numeric field), field_organisation (entity reference) and field_sector (term).

What is the target entity of field_organisation? Nodes?

In order to debug this, can you try the following? 

1. Install Devel

2. In a text or IDE editor open core/modules/views/includes/cache.inc

3. In line 108 insert the following after the opening brace:

if(is_array($table_info['table']['entity type'])) {dpm($table_name, 'table_name'); dpm($table_info['table']['entity type'], 'entity type');}

 So, line 108 should look like:

if (!empty($table_info['table']['entity type'])) { if(is_array($table_info['table']['entity type'])) {dpm($table_name, 'table_name'); dpm($table_info['table']['entity type'], 'entity type');}

4. Clear caches. If you get any output in the message area of the page, copy and paste that output here.

I've seen this before for some views fields for custom entities that do not declare 'entity_type' in their hook_views_data(). But the strange part is that this is not happening consistently - only on cache clear. 

Can you paste an export of the view here? Also, a list of the contrib modules?

Comments

I've seen this before for some views fields for custom entities that do not declare 'entity_type' in their hook_views_data(). But the strange part is that this is not happening consistently - only on cache clear. 

Can you paste an export of the view here? Also, a list of the contrib modules?

Thanks for posting, onyx. The view looks fine. I see that there are a couple of exposed filters: field_id (which looks like a numeric field), field_organisation (entity reference) and field_sector (term).

What is the target entity of field_organisation? Nodes?

In order to debug this, can you try the following? 

1. Install Devel

2. In a text or IDE editor open core/modules/views/includes/cache.inc

3. In line 108 insert the following after the opening brace:

if(is_array($table_info['table']['entity type'])) {dpm($table_name, 'table_name'); dpm($table_info['table']['entity type'], 'entity type');}

 So, line 108 should look like:

if (!empty($table_info['table']['entity type'])) { if(is_array($table_info['table']['entity type'])) {dpm($table_name, 'table_name'); dpm($table_info['table']['entity type'], 'entity type');}

4. Clear caches. If you get any output in the message area of the page, copy and paste that output here.

Thanks!
Line 109 because I commented 108 for ease...
So Registration module looks to be the issue?

Interesting. I'm not sure it's just Registration. I've enabled it and I'm not getting that array. There may be another module that's causing the duplication for this. And I'm not sure this issue is related to the disappearing form.  I'll keep looking.

BTW, that entity reference field field_organisation - was that referencing  registration entities? Or nodes?  

Bingo! Disable Registration Views and try again. That module creates duplicates for some views definitions. 

This issue (duplication of views definitions) has been reported in the issues queue for Registration (see https://github.com/backdrop-contrib/registration/issues/33).

A workaround is to download the DEV version of Registration at:

https://github.com/backdrop-contrib/registration/archive/refs/heads/1.x-...

The DEV version includes a fix for this.

You'll need to trash the current Registration folder, unzip the above, and RENAME it to registration.

The drawback of doing this is that Backdrop won't detect new releases of Registration if any. But you can make a note to yourself to check Registration periodically, and when a new release comes out, replace the dev version with the latest version. 

Once again, you've done it. Thank you @argiepiano!

The view's exposed forms now survive a cache flush.

It took 3 tries, but I got it to accept a Dropdown with Show Hierarchy, for field_sector, which is a Term Reference field of node Role.

Should I be concerned with this:

Warning: Trying to access array offset on value of type null in _field_info_prepare_instance_display() (line 385 of /var/www/clients/client1/web1/web/core/modules/field/field.info.inc).

Great! 

Regarding the other warning: let's try some debugging.

Can you add the following to line 386 of the file field.info.inc? The line right after where the warning happens.

if (empty($formatter_type['module'])) {dpm($field, 'field'); dpm($display, 'display');}

By the way, don't forget to remove all those debugging lines after you are done.

 

And those exposed fields are gone again from the Roles view!

Ditching the Registration module as it seems to be the issue right now...

will handle registering via webforms

OK, I found the issue with that second notice and have filed a report.

One quick solution to get rid of that notice is to go to Manage Display for the node that has the Registration field, select a different formatter for that field and then save. There is a problem with the default formatter chosen for these Registration fields - it doesn't exist, which is why you get the notice.

That said, I don't know if this will fix the issue with the disappearing exposed form.