Posted by sun on September 17, 2012 at 5:58pm
14 followers
| Project: | Drupal core |
| Version: | 8.x-dev |
| Component: | base system |
| Category: | bug report |
| Priority: | major |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
| Issue tags: | Dependency Injection (DI), VDC, WSCCI |
Issue Summary
#1535868-40: Change notice: Convert all blocks into plugins
or: http://qa.drupal.org/pifr/test/340923
Many irrelevant test failures:
Undefined index: plid Notice menu.module 198 menu_enable()
A hook_menu() implementation tries to use/retrieve a service that is registered by a module (bundle) -- which causes menu_router_rebuild() to blow up.
menu_router_rebuild() contains a try/catch block, so the actual exception is hidden. As a result, menu_enable() does not find any links in the menu links table.
The actual exception thrown is:
DependencyInjection... "The service definition "plugin.manager.system.plugin_ui" does not exist."However, this service is registered on the container in a SystemBundle in that patch.
SystemBundle::build() gets invoked. But possibly too late or whatever.
Comments
#1
We've been having this problem in Views, as well as #1708692: Simpletest slow and other problems following Bundle services aren't available in the request that enables the module, I think we just assumed it was all the other issue.
#2
@tim.plunkett: Can you post a small patch here that demonstrates the bug with a failing test? I just tried a fresh checkout of Views 8.x-3.x, and tests seem to be passing without the hack in #1708692-19: Simpletest slow and other problems following Bundle services aren't available in the request that enables the module.
#3
Simply add
protected $profile = 'standard';to any Views test.I can work over the next few days to distill it down to a "small patch", but in the meantime, here's this :D
#4
I don't get that. As for the OP, the service is registered by SystemBundle, which is (or should be) available at all times, regardless of install profile.
#5
Perhaps the install profile part is a separate issue. Perhaps not.
But this is not normal:
#0 /var/lib/drupaltestbot/sites/default/files/checkout/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerBuilder.php(338): Symfony\Component\DependencyInjection\ContainerBuilder->getDefinition('plugin.manager....')#1 /var/lib/drupaltestbot/sites/default/files/checkout/core/modules/views/views.module(1460): Symfony\Component\DependencyInjection\ContainerBuilder->get('plugin.manager....')
#2 /var/lib/drupaltestbot/sites/default/files/checkout/core/modules/views/views.module(202): views_get_plugin_definitions()
#3 /var/lib/drupaltestbot/sites/default/files/checkout/core/includes/theme.inc(425): views_theme(Array, 'module', 'views', 'core/modules/vi...')
#4 /var/lib/drupaltestbot/sites/default/files/checkout/core/includes/theme.inc(577): _theme_process_registry(Array, 'views', 'module', 'views', 'core/modules/vi...')
#5 /var/lib/drupaltestbot/sites/default/files/checkout/core/includes/theme.maintenance.inc(95): _theme_build_registry(Object(stdClass), Array, 'phptemplate')
#6 [internal function]: _theme_load_offline_registry(Object(stdClass), Array, 'phptemplate', false)
#7 /var/lib/drupaltestbot/sites/default/files/checkout/core/includes/theme.inc(276): call_user_func_array('_theme_load_off...', Array)
#8 /var/lib/drupaltestbot/sites/default/files/checkout/core/includes/common.inc(2328): theme_get_registry(false)
#9 /var/lib/drupaltestbot/sites/default/files/checkout/core/modules/filter/filter.module(366): l('Filtered HTML', 'admin/config/co...')
#10 [internal function]: filter_permission()
#11 /var/lib/drupaltestbot/sites/default/files/checkout/core/includes/module.inc(901): call_user_func_array('filter_permissi...', Array)
#12 /var/lib/drupaltestbot/sites/default/files/checkout/core/modules/user/user.module(2341): module_invoke('filter', 'permission')
#13 /var/lib/drupaltestbot/sites/default/files/checkout/core/modules/user/user.module(2403): user_permission_get_modules()
#14 /var/lib/drupaltestbot/sites/default/files/checkout/core/modules/user/user.module(3070): user_role_grant_permissions('administrator', Array)
#15 [internal function]: user_modules_installed(Array)
#16 /var/lib/drupaltestbot/sites/default/files/checkout/core/includes/module.inc(925): call_user_func_array('user_modules_in...', Array)
#17 /var/lib/drupaltestbot/sites/default/files/checkout/core/includes/module.inc(515): module_invoke_all('modules_install...', Array)
#18 /var/lib/drupaltestbot/sites/default/files/checkout/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php(718): module_enable(Array, true)
#19 /var/lib/drupaltestbot/sites/default/files/checkout/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php(29): Drupal\simpletest\WebTestBase->setUp()
#20 /var/lib/drupaltestbot/sites/default/files/checkout/core/modules/comment/lib/Drupal/comment/Tests/CommentNodeAccessTest.php(37): Drupal\comment\Tests\CommentTestBase->setUp()
#21 /var/lib/drupaltestbot/sites/default/files/checkout/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php(584): Drupal\comment\Tests\CommentNodeAccessTest->setUp()
#22 /var/lib/drupaltestbot/sites/default/files/checkout/core/scripts/run-tests.sh(381): Drupal\simpletest\TestBase->run()
#23 /var/lib/drupaltestbot/sites/default/files/checkout/core/scripts/run-tests.sh(22): simpletest_script_run_one_test('59', 'Drupal\comment\...')
#24 {main}FATAL Drupal\comment\Tests\CommentNodeAccessTest: test runner returned a non-zero error code (1)
Copying this over from the other issue:
Here's the relevant call stack for one such occurence: https://privatepaste.com/ddf8081988
Note lines 13 and 14. l() is being called, which is calling theme_get_registry(), and then everything goes to hell.
So, I tried putting this into ViewTestBase:
/*** Overrides TestBase::changeDatabasePrefix().
*
* This is the dirtiest hack. It is the only method called in
* WebTestBase::setUp() that is after it resets $conf and before it calls
* module_enable().
*/
protected function changeDatabasePrefix() {
variable_set('theme_link', FALSE);
return parent::changeDatabasePrefix();
}
And it all worked out.
#6
The last submitted patch, views-1786990-3.patch, failed testing.
#7
From #1805996-8: [META] Views in Drupal Core:
Here's a patch that's identical to that one, but with views and views_ui added as dependencies to standard.info. I'm curious what breaks.
#8
The last submitted patch, vdc-test.patch, failed testing.
#9
Will the exact same tests fail on just this?
#10
The last submitted patch, bundle-registration-1786990-9.patch, failed testing.
#11
That has got to be the single best example of narrowing scope I've ever seen. 2.5 MB to less than 2K. ;)
And yep, looks like they're all croaking with:
exception 'Symfony\Component\DependencyInjection\Exception\InvalidArgumentException' with message 'The service definition "views.bundle" does not exist.' in /var/lib/drupaltestbot/sites/default/files/checkout/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerBuilder.php:690#12
Looks like there's 4 ModuleAPI failures in #7 that aren't in #9. Trying to find out what's causing them.
#13
Ah, those were a red herring, just due to standard.info not including 'config', a Views dependency. Ok, looks like registration of [Module]Bundle happening after hook_theme() is the key scope of this issue, as demonstrated in #9.
#14
I suspect we need to turn the conclusion around. Possible causes:
1) theme() may be invoked before full bootstrap, or, before the kernel container is instantiated.
2) hook_theme() may be called by the installer, but the installer may not register bundles of modules.
3) Unlimited variations of 1) and 2) ;)
#15
That's caused by filter_permission()
<?php$format_name_replacement = user_access('administer filters') ? l($format->name, 'admin/config/content/formats/' . $format->format) : drupal_placeholder($format->name);
?>
and then common.inc l()
<?phpif (!isset($use_theme) && function_exists('theme')) {
// Allow edge cases to prevent theme initialization and force inline link
// rendering.
if (variable_get('theme_link', TRUE)) {
drupal_theme_initialize();
$registry = theme_get_registry(FALSE);
?>
#16
That treats the symptom, yes.
But as sun points out in #14, this could happen in other ways as well.
#17
The problem is in WebTestBase::setUp(), we install_drupal() for the profile being tested and then module_enable() any additional modules needed by the test. The module_enable() invokes hooks which could end up calling l(), or any number of other functions that end up expecting services from modules enabled by install_drupal(). Here's a really ugly fix, though I hope we can fix this more robustly in other issues like #1708692: Simpletest slow and other problems following Bundle services aren't available in the request that enables the module and #1784312: Stop doing so much pre-kernel bootstrapping.
#18
+++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php@@ -716,24 +717,9 @@ protected function setUp() {
if ($modules) {
$success = module_enable($modules, TRUE);
$this->assertTrue($success, t('Enabled modules: %modules', array('%modules' => implode(', ', $modules))));
+ $this->rebuildContainer();
}
I think we need the rebuild in all cases, not just when additional modules to install have been specified. That is, because ->kernel and ->container are provided for test classes.
+++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php@@ -779,6 +765,35 @@ protected function refreshVariables() {
+ protected function rebuildContainer() {
Given #1774388: Unit Tests Remastered™, we likely need to move this into TestBase.
#19
Since both patches in #17 are green, I removed the mock Views example from here on out. I don't think we need any test case in this patch, because the real problem still needs to be dealt with in #1708692: Simpletest slow and other problems following Bundle services aren't available in the request that enables the module. The purpose of this issue is just to allow #1805996: [META] Views in Drupal Core to add Views to the Standard install profile.
This implements #18.2. #18.1 is already taken care of: notice there's 2 lines in WebTestBase :).
#20
@sun, if this is what you meant in your first comment, then that's fine.
As to the second part, first to RTBC wins :)
EDIT: Ignore this, go with 19.
#21
Same as #19, but needed to copy the
usestatement to TestBase.#22
The last submitted patch, bundle-registration-1786990-21.patch, failed testing.
#23
#21: bundle-registration-1786990-21.patch queued for re-testing.
#24
I'm OK with this as a temporary stop-gap, so RTBC on the assumption that the testbot comes back green at some point.
#1809248: Enable apc.enable_cli php.ini setting on testbots was deployed on two testbots, right at the time when #21 was in process of testing, so if there won't be results in a 1-2 hours, I'd recommend to re-upload this patch (or manually send it for re-testing).
(@tim.plunkett: The same apparently applies to your VDC sandbox, FWIW.)
#25
Looks straight-forward enough.
Committed and pushed to 8.x. Thanks!
#26
I don't see this in the commit log, can you
git pull --rebase;git push
please?
#27
Pushed now, thanks
#28
Automatically closed -- issue fixed for 2 weeks with no activity.