Problem/Motivation

When saving the view, we see the following error:

Deprecated function: mb_strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\Core\Config\Entity\Query\Condition->compile() (line 39 of core/lib/Drupal/Core/Config/Entity/Query/Condition.php).

This is because the UUID for the configured view is empty.

Also the new data_table property was preventing custom fields from appearing as options in section template views.

Steps to reproduce

Edit the section library view and save.

Create a new field on section templates. That field does not appear as an option to insert into the section library view.

Proposed resolution

Originally the new field UI was going to have the section library view as the parent so it was important for it to exist. That is no longer the case, so this MR removes the portion of the update hook that overwrote the entire config for the section library view.

Additionally, the associated post update hook to set the field_ui_base_route and wasn't updated when the field UI was moved.

This MR adds conditional post-update hooks for folks who already updated to a dev version of the module. If someone is upgrading from the latest release, those post-update hooks will just return "No changes needed to section library view." and "No changes needed to section template entity." respectively.

Testing

Three scenarios to test:

  • Installing section library with this MR on a fresh site that did not previously have section library. (No updates should run.)
  • Updating a site that was running the 1.2.2 release of section library is updated straight to the dev version + this MR (4 post-update hooks run but two will have no impact and simply return "No changes needed to section library view." and "No changes needed to section template entity." respectively)
  • Updating a site that updated to the latest 1.2.x dev branch and subsequently added this MR. (Should run the two new post-update hooks.)

In all cases, the section library view should be editable and not display an error on save. Custom fields added to the section template entity should appear as options in section template views.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

jastraat created an issue. See original summary.

jastraat’s picture

Issue summary: View changes

jastraat’s picture

Issue summary: View changes
jastraat’s picture

Status: Active » Needs review
jastraat’s picture

Issue summary: View changes
jastraat’s picture

Attached patch must be applied to the dev branch of section library.

jastraat’s picture

Found out something super obscure:
"Turns out you shouldn't set data_table in the entity type annotation if translatable is FALSE. Otherwise views associates all of the fields with the data_table, but data_table is never associated with base_table due to translations being disabled."

Removing the data_table property from the entity allows custom fields to appear as options in section library views.

Updated patch attached.

jastraat’s picture

Title: Adjust post update hooks based on the current version of the module » Adjust post update hooks and allow custom fields in views
Issue summary: View changes
jastraat’s picture

jastraat’s picture

jastraat’s picture

grimreaper’s picture

Assigned: jastraat » grimreaper
grimreaper’s picture

Assigned: grimreaper » Unassigned
Status: Needs review » Reviewed & tested by the community

Hi,

Thanks @jastraat for your work in this.

I confirm:
- I no more see the error message when saving the view
- I now have access to the additional fields set through the UI

  • jastraat committed 5bf17c2e on 1.2.x
    Issue #3507843 by jastraat: Adjust post update hooks and allow custom...
jastraat’s picture

Status: Reviewed & tested by the community » Fixed

Thank you for testing!

  • jastraat committed 5bf17c2e on 2.0.x
    Issue #3507843 by jastraat: Adjust post update hooks and allow custom...
jastraat’s picture

Version: 1.2.x-dev » 2.0.x-dev

Updating this to the relevant major version.

Status: Fixed » Closed (fixed)

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