There are two bugs intertwined and fixed in this issue: we call drupal_theme_initialize in TestBase::prepareEnvironment where this makes no sense as the database prefix is not switched yet so this initializes the parent theme. Removing this, however, breaks some Views tests. Some stout and steady detective work revealed that state() is not working during DrupalUnitTestBase. How the two are related is not well understood but certainly fixing state() is a) necessary b) enough to get the Views tests pass again.

Comments

chx’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, no_theme_in.patch, failed testing.

damiankloip’s picture

StatusFileSize
new1.25 KB

There is something going on with ViewExecutable::render calling drupal_theme_initialize() in unit tests. Do we need to call this?

damiankloip’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 1874694-3.patch, failed testing.

chx’s picture

Title: Remove drupal_theme_initialize from prepareEnvironment » DrupalUnitTestBase breaks state()
Priority: Normal » Major
Status: Needs work » Needs review
StatusFileSize
new3.15 KB

Opsie! Every call to state() during DrupalUnitTestBase creates a new memory storage. Great! Erm. Maybe not.

Our code base is so very friendly with error messages. Erm. Maybe not.

chx’s picture

Re #3: yes, we need the theme initialize call there :P

damiankloip’s picture

Yeah, we do :)

damiankloip’s picture

StatusFileSize
new3.59 KB

Yeah, all in all that is some serious digging :)

Docs etc..

Anonymous’s picture

great detective work!

can we fix the drupal_theme_initialize() in another issue? reading the patch, and the comments in the OP make me want to separate what is a straight forward fix (the stupid state() stuff) from what is an unknown, if this is possible.

chx’s picture

let's not do that; we do not have test coverage otherwise. and removing that drupal_theme_initialize is necessary for the clean fix of a critical so i'd rather get it in asap. In #1874562: Upgrade path broken and yet tests pass we need to catch an exception for when drupal_theme_initialize wanders off and tries to find themes on disk. Removing that call makes it so that doesn't happen. This issue is about removing that drupal_theme_initialize really... how long an issue chain you want to fix an upgrade critical?

berdir’s picture

Status: Needs review » Reviewed & tested by the community

I think fixing this together makes sense. The KeyValueMemory changes look good and make sense to me, the memory implementation of course only works as expected if you get the same instance back every time you call it.

We have a similar problem with cache system currently, some cache backends are defined as a separate service, like cache.config, which directly calls into CacheFactory, but the static cache is in cache(). So if you configure cache.config (or any of the other 2-3 defined cache backend services) to use the memory backend ( or another backend that stores some information in the implementation) and then sometimes use cache('config') and sometimes drupal_container()->get('cache.config'), unexpected things will happen.

Which is why I need to get back to the cache in DIC issue :)

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.x, thanks!

chx’s picture

Title: DrupalUnitTestBase breaks state() » Plugins broke mysteriously
Priority: Major » Normal
Status: Fixed » Active

I need to roll this back and understand what went wrong with plugins cos it's not clear to anyone what went wrong here and that can't stand.

sun’s picture

Category: task » bug
Priority: Normal » Major

Also, the removal of drupal_theme_initialize() was not correct. There's a dedicated issue + patch for that for quite some time already:
#1770902: Theme of parent site executing test leaks into all tests

chx’s picture

Category: bug » task
Priority: Major » Normal

The removal was correct from TestBase, I see the other issue adding to other test bases, let's discuss that there. If you want, you can bump the other to major, right now this is kept open to track me trying to debug what is going on with plugins -- I very much dislike bugs I can't understand.

chx’s picture

Issue summary: View changes

Updated issue summary.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

  • catch committed bb2b90a on 8.3.x
    Issue #1874694 by damiankloip, chx: DrupalUnitTestBase breaks state().
    

  • catch committed bb2b90a on 8.3.x
    Issue #1874694 by damiankloip, chx: DrupalUnitTestBase breaks state().
    

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

  • catch committed bb2b90a on 8.4.x
    Issue #1874694 by damiankloip, chx: DrupalUnitTestBase breaks state().
    

  • catch committed bb2b90a on 8.4.x
    Issue #1874694 by damiankloip, chx: DrupalUnitTestBase breaks state().
    

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev
quietone’s picture

Version: 9.3.x-dev » 8.0.x-dev
Issue summary: View changes
Status: Active » Fixed
Issue tags: +Bug Smash Initiative

This was committed to 8.0.x in December 2012 and re-opened for further investigation. In the intervening 9 years there is no evidence that any investigation has happened.

I asked in #bugsmash about this, longwave replied (paraphrased) that the two base classes are in simpletest, which is now a contrib project. The keyvalue fix looks valid as per Berdir in #12 it has been in core for years now.

Based on that I am restoring the fixed status of this and the version to when it was fixed.

Thanks!

Status: Fixed » Closed (fixed)

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