Problem/Motivation

Gin WSODs when is not active anymore after a custom theme negotiator swaps the theme, and Gin has the "Enable sticky action buttons" option enabled.

This is a Drupal CMS blocker because that option is always enabled if new Navigation in core is enabled + it affects the ability of Drupal Canvas to keep the selection the editor made in the library media selector from the semi-decoupled theme used for forms.

Not to be confused with the related issue #3539391: Gin does not render properly if set as active theme from a custom theme negotiator:

  • #3539391 covers visual issues when a negotiation does some themeGin
  • This covers a WSOD when a negotiation does Ginsome theme

Steps to reproduce

"call_user_func_array(): Argument #1 ($callback) must be a valid callback, function \"gin_form_after_build\" not found or invalid function name"

The reason is that Gin is adding an after_build handler, but the Gin theme is not loaded anymore, but the form is already cached by Drupal though. So the after_build still tries to run.

Proposed resolution

  • Move the after_build handler to the same class that is adding it, which will be loaded.
  • Check Gin (or a sub-theme or Gin) is active or early return the form without modifications.

Remaining tasks

Review.

User interface changes

None, as Gin is not active in that request anymore.

API changes

AFAIK handlers are not considered API.

Data model changes

None.

Issue fork gin-3554265

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

penyaskito created an issue. See original summary.

penyaskito’s picture

Status: Active » Needs review
penyaskito’s picture

Moved MR to this new issue for avoiding confusion.

phenaproxima’s picture

Status: Needs review » Reviewed & tested by the community

I have one stylistic suggestion, but it's a nit. The fix (and excellent comment) otherwise make sense to me.

jurgenhaas made their first commit to this issue’s fork.

jurgenhaas’s picture

Status: Reviewed & tested by the community » Fixed

Thx @phenaproxima and @penyaskito, this is now fixed.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

mrshowerman’s picture

Am I the only one for whom this change broke the sticky action buttons?

This code

    $is_gin_active = array_any(
      \Drupal::theme()->getActiveTheme()->getBaseThemeExtensions(),
      fn ($theme): bool => $theme->getName() === 'gin',
    );

always returns false because getBaseThemeExtensions() returns only claro, not gin, with Gin as the active theme.

strykaizer’s picture

Experiencing the same issue since 5.0.7 as #10
5.0.5 does not have this issue

Visible on e.g. /admin/people/create

jurgenhaas’s picture

Status: Fixed » Active

Sorry for the inconvenience, I'll investigate.

  • jurgenhaas committed 90aa55da on 5.0.x
    bug: #3554265 Fix the active check in Gin WSODs when is not active...
jurgenhaas’s picture

Status: Active » Needs review

I've committed a fix in the 5.0.x-dev branch, please give that a try and provide feedback if that works.

@phenaproxima has there been a reason not to use the existing _gin_is_active() method to determine if Gin is active? The problem is that neither the first nor the "lambda-flavoured" version of that code ever returned TRUE.

mrshowerman’s picture

Nice, the dev branch brings back the sticky action buttons.
Thanks for jumping in so quickly, @jurgenhaas!

jurgenhaas’s picture

Status: Needs review » Fixed

OK, we've now also added an ugly approach to ensure that include files always get loaded. Another release just got tagged.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • jurgenhaas committed f59e9374 on 5.0.x
    bug: #3554265 Also register the Gin namespace with the classloader as it...

Status: Fixed » Closed (fixed)

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