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 theme → Gin
- This covers a WSOD when a negotiation does Gin → some 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
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
Comment #3
penyaskitoComment #4
penyaskitoMoved MR to this new issue for avoiding confusion.
Comment #5
phenaproximaI have one stylistic suggestion, but it's a nit. The fix (and excellent comment) otherwise make sense to me.
Comment #8
jurgenhaasThx @phenaproxima and @penyaskito, this is now fixed.
Comment #10
mrshowermanAm I the only one for whom this change broke the sticky action buttons?
This code
always returns
falsebecausegetBaseThemeExtensions()returns onlyclaro, notgin, with Gin as the active theme.Comment #11
strykaizerExperiencing the same issue since 5.0.7 as #10
5.0.5 does not have this issue
Visible on e.g. /admin/people/create
Comment #12
jurgenhaasSorry for the inconvenience, I'll investigate.
Comment #14
jurgenhaasI'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.Comment #15
mrshowermanNice, the dev branch brings back the sticky action buttons.
Thanks for jumping in so quickly, @jurgenhaas!
Comment #17
jurgenhaasOK, we've now also added an ugly approach to ensure that include files always get loaded. Another release just got tagged.