Problem/Motivation

We want to make Classy depend on Stable.

Currently, fatal errors occur when you try to visit update.php after we remove base theme: false from Classy's .info.yml. For update.php to work the theme displaying it needs to work.

Proposed resolution

If Stable is missing in theme initialization, ignore it.

Remaining tasks

None

User interface changes

n/a

API changes

n/a

Data model changes

None

Files: 
CommentFileSizeAuthor
#41 interdiff.txt1.78 KBCottser
#41 make_classy_extend_from-2581443-41.patch7.74 KBCottser
#40 make_classy_extend_from-2581443-40.patch7.86 KBCottser
#36 2581443-36.patch7.86 KBalexpott
#36 35-36-interdiff.txt798 bytesalexpott
#35 2581443-35.patch7.68 KBalexpott
#35 32-35-interdiff.txt1.44 KBalexpott
#32 2581443-32.patch6.98 KBalexpott
#32 28-32-interdiff.txt7.96 KBalexpott
#28 2581443-28.patch9.64 KBalexpott
#28 25-28-interdiff.txt642 bytesalexpott
#25 2581443-25.patch9.21 KBalexpott
#25 18-25-interdiff.txt6.75 KBalexpott
#18 interdiff.txt8.56 KBlauriii
#18 make_classy_extend_from-2581443-18.patch8.96 KBlauriii
#15 interdiff.txt1.36 KBlauriii
#15 make_classy_extend_from-2581443-15.patch11.37 KBlauriii
#14 make_classy_extend_from-2581443-14.patch12.88 KBlauriii
#13 interdiff-7-13.txt69.7 KBlauriii
#13 make_classy_extend_from-2581443-13.patch73.43 KBlauriii
#10 interdiff.txt1.33 KBCottser
#10 make_classy_extend_from-2581443-10.patch7.38 KBCottser
#7 interdiff.txt511 byteslauriii
#7 make_classy_extend_from-2581443-7.patch6.05 KBlauriii
PASSED: [[SimpleTest]]: [PHP 5.5 MySQL] 116,811 pass(es). View
#3 make_classy_extend_from-2581443-3.patch5.41 KBCottser
FAILED: [[SimpleTest]]: [PHP 5.5 MySQL] 116,826 pass(es), 89 fail(s), and 0 exception(s). View

Comments

Cottser created an issue. See original summary.

Cottser’s picture

Title: Unable to add a base theme dependency to the theme used for updates (update.php) » Make Classy extend from the new Stable base theme
Issue summary: View changes

We can maybe make Classy extend from Stable in this issue as well. Let's see how it goes, we can split later if needed.

Cottser’s picture

Status: Active » Needs review
FileSize
5.41 KB
FAILED: [[SimpleTest]]: [PHP 5.5 MySQL] 116,826 pass(es), 89 fail(s), and 0 exception(s). View

I think we need something better than this because as soon as someone calls something like getActiveTheme() on ThemeManager or ThemeInitialization during updates things will probably go wrong. But here is something @lauriii and myself have been kicking around, he did the fancy things.

Originally I wanted to just put this stuff right into ThemeInitialization but I guess that's not good.

alexpott’s picture

Issue tags: +rc target

Discussed with @catch and we agreed that this is an RC target since if we don't fix this then we'll have to copy all templates to Classy and Stable.

Status: Needs review » Needs work

The last submitted patch, 3: make_classy_extend_from-2581443-3.patch, failed testing.

The last submitted patch, 3: make_classy_extend_from-2581443-3.patch, failed testing.

lauriii’s picture

Status: Needs work » Needs review
FileSize
6.05 KB
PASSED: [[SimpleTest]]: [PHP 5.5 MySQL] 116,811 pass(es). View
511 bytes
Cottser’s picture

@lauriii mentioned in the frontend meeting today maybe doing something that's hanging off of UpdateKernel, that seemed sensible to me.

alexpott’s picture

Status: Needs review » Needs work
Related issues: +#2547507: Consider adding hook_update_early_N() support

This is the first proper use case for #2547507: Consider adding hook_update_early_N() support. I'm not sure that it means we should do the issue though.

There are a number of ways to go here... one possibility is to use a theme other than seven as the maintenance theme - but I think that this is a lot of work. Since we're in favour of doing the smallest possible changes during RC I think doing something special in the update controller might be a good idea.

Cottser’s picture

Status: Needs work » Needs review
FileSize
7.38 KB
1.33 KB

Just want to make sure we don't forget this interdiff, moving from #2575737-21: Copy templates, CSS, and related assets to Stable and override core libraries' CSS with an additional change I caught. Any themes extending from Classy or Stable should not reference core libraries/templates/assets/etc. because they may change.

Cottser’s picture

Although that type of change may need to be follow-up to both of these issues unless #2575737: Copy templates, CSS, and related assets to Stable and override core libraries' CSS gets in first. So maybe roll that back for now because it will make tests fail.

Status: Needs review » Needs work

The last submitted patch, 10: make_classy_extend_from-2581443-10.patch, failed testing.

lauriii’s picture

Status: Needs work » Needs review
FileSize
73.43 KB
69.7 KB

Lets see what happens

lauriii’s picture

Removed system.module.orig

lauriii’s picture

Cottser’s picture

Status: Needs review » Needs work

Thanks @lauriii!

  1. +++ b/core/includes/theme.maintenance.inc
    @@ -6,6 +6,7 @@
    +use Drupal\Core\Theme\MissingThemeDependencyException;
    

    Minor: I think this use is no longer needed.

  2. +++ b/core/lib/Drupal/Core/Theme/MissingThemeDependencyException.php
    @@ -0,0 +1,37 @@
    + * @see \Drupal\Core\Theme\ThemeInitialization::getActiveThemeByName().
    

    Update @see to point to the relevant spot.

  3. +++ b/core/modules/system/src/Controller/DbUpdateController.php
    @@ -101,8 +126,12 @@ class DbUpdateController extends ControllerBase {
    +   * @param \Drupal\Core\Theme\ThemeInitializationInterface $theme_initialization
    +   *   The theme initialization.
    +   * @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler
    +   *   The theme handler.
    ...
    -  public function __construct($root, KeyValueExpirableFactoryInterface $key_value_expirable_factory, CacheBackendInterface $cache, StateInterface $state, ModuleHandlerInterface $module_handler, AccountInterface $account, BareHtmlPageRendererInterface $bare_html_page_renderer, UpdateRegistry $post_update_registry) {
    +  public function __construct($root, KeyValueExpirableFactoryInterface $key_value_expirable_factory, CacheBackendInterface $cache, StateInterface $state, ModuleHandlerInterface $module_handler, AccountInterface $account, BareHtmlPageRendererInterface $bare_html_page_renderer, UpdateRegistry $post_update_registry, ThemeInitializationInterface $theme_initialization, ThemeHandlerInterface $theme_handler, ThemeInstallerInterface $theme_installer) {
    
    @@ -111,6 +140,9 @@ public function __construct($root, KeyValueExpirableFactoryInterface $key_value_
    +    $this->themeInitialization = $theme_initialization;
    +    $this->themeHandler = $theme_handler;
    +    $this->themeInstaller = $theme_installer;
    

    Minor: Missing @param for $theme_installer.

How can we test this code?

The last submitted patch, 15: make_classy_extend_from-2581443-15.patch, failed testing.

lauriii’s picture

Status: Needs review » Needs work

The last submitted patch, 18: make_classy_extend_from-2581443-18.patch, failed testing.

The last submitted patch, 18: make_classy_extend_from-2581443-18.patch, failed testing.

Cottser’s picture

Cottser’s picture

The last submitted patch, 18: make_classy_extend_from-2581443-18.patch, failed testing.

The last submitted patch, 18: make_classy_extend_from-2581443-18.patch, failed testing.

alexpott’s picture

Status: Needs work » Needs review
FileSize
6.75 KB
9.21 KB

So in order to get this to work we need to clear both the system list in state and the system list in cache - if you only clear the cache it uses state to rebuild the cache and if you only clear state then it'll read from the cache.

Status: Needs review » Needs work

The last submitted patch, 25: 2581443-25.patch, failed testing.

The last submitted patch, 25: 2581443-25.patch, failed testing.

alexpott’s picture

Status: Needs work » Needs review
FileSize
642 bytes
9.64 KB

Fixing the remaining fails.

Status: Needs review » Needs work

The last submitted patch, 28: 2581443-28.patch, failed testing.

alexpott’s picture

Hmmm...

/**
 * Initializes blocks for installed themes.
 *
 * @param $theme_list
 *   An array of theme names.
 */
function block_themes_installed($theme_list) {
  foreach ($theme_list as $theme) {
    block_theme_initialize($theme);
  }
}

This behaviour of copying blocks around is completely incorrect for base themes. We need #2574975: Allow (base-)themes to be excluded from the UI (e.g. blocks, Appearance). and then adjust block_theme_initialize() to not copy blocks for hidden themes.

alexpott’s picture

alexpott’s picture

Status: Needs work » Needs review
FileSize
7.96 KB
6.98 KB

A different approach and one that is not dependent at all on doing early update stuff. Basically it just ignores the missing stable base theme if it is not present because it is very special situation. In this way the update can proceed and enable stable as required.

Also I'm not that sure that the original update actually worked because of the way theme data is cached in cache and state (the system list is persisted across cache rebuilds here). We should have used ThemeHandler::refreshInfo() and not ThemeHandler::rebuildThemeData().

Cottser’s picture

Manual testing seems to check out, bot is happy, and this approach seems sensible to me. I could only find these minor points on review:

  1. +++ b/core/lib/Drupal/Core/Theme/MissingThemeDependencyException.php
    @@ -0,0 +1,48 @@
    + * @see \Drupal\system\Controller\DbUpdateController::ensureActiveThemeDependencies().
    

    Minor: I think this line can be removed now since we don't throw the exception there any more.

  2. +++ b/core/lib/Drupal/Core/Theme/ThemeInitialization.php
    @@ -109,6 +109,16 @@ public function getActiveThemeByName($theme_name) {
    +          // regressions on the update.php
    

    Minor: Missing period at the end.

lauriii’s picture

Thanks a lot for figuring this out @alexpott. I tried figure out this personally for a long time but didn't make any progress. This looks pretty much RTBC beside this:

+++ b/core/modules/system/system.install
@@ -1847,3 +1849,32 @@ function system_update_8013() {
+ * Ensure Classy can use the Stable base theme.
...
+  // Ensure we have fresh info.

Is these docs copy paste from tests?

alexpott’s picture

@lauriii nope. But looking at these docs again makes me think we should just remove system_update_8012() and use the same one-liner. The // Ensure we have fresh info. is just unnecessary documentation.

alexpott’s picture

Here's a patch to show why we need to postpone this on #2574975: Allow (base-)themes to be excluded from the UI (e.g. blocks, Appearance).. Once that has landed installing stable will no longer automatically place blocks for it.

alexpott’s picture

Status: Needs review » Postponed

Doing the postponing for realz.

Status: Postponed » Needs work

The last submitted patch, 36: 2581443-36.patch, failed testing.

alexpott’s picture

Status: Needs work » Postponed
Cottser’s picture

Status: Postponed » Needs review
FileSize
7.86 KB
Cottser’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
FileSize
7.74 KB
1.78 KB

Okay so the only things I can see that need work are #33 (and removing the reference in that chunk of docs to system_update_8012() which is being removed now).

Since it's docs only, rolling in here and RTBC'ing – based on my previous reviews and @lauriii's in #34. I think @alexpott, @lauriii, and me are all happy with this now :)

lauriii’s picture

RTBC++

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.0.x, thanks!

  • catch committed 2358408 on 8.0.x
    Issue #2581443 by alexpott, lauriii, Cottser: Make Classy extend from...

  • catch committed 2358408 on 8.1.x
    Issue #2581443 by alexpott, lauriii, Cottser: Make Classy extend from...

Status: Fixed » Closed (fixed)

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