Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I am getting error:
TypeError: Argument 1 passed to twig_init() must be an instance of Drupal\Core\Extension\Extension, string given in twig_init() (line 34 of core/themes/engines/twig/twig.engine).
Full output:
twig_init('css/core/dialog/off-canvas.layout.css')
call_user_func('twig_init', 'css/core/dialog/off-canvas.layout.css') (Line: 144)
Drupal\Core\Theme\ThemeInitialization->loadActiveTheme(Object) (Line: 74)
Drupal\Core\Theme\ThemeInitialization->initTheme('og_admin_theme') (Line: 406)
Drupal\Core\Theme\ThemeManager->initTheme(Object) (Line: 96)
Drupal\Core\Theme\ThemeManager->getActiveTheme() (Line: 74)
Drupal\Core\Render\ElementInfoManager->getInfo('form') (Line: 806)
Drupal\Core\Form\FormBuilder->prepareForm('views_exposed_form', Array, Object) (Line: 272)
Drupal\Core\Form\FormBuilder->buildForm('views_exposed_form', Object) (Line: 135)
Drupal\views\Plugin\views\exposed_form\ExposedFormPluginBase->renderExposedForm() (Line: 1235)
Drupal\views\ViewExecutable->build('page_1') (Line: 1388)
Drupal\views\ViewExecutable->execute('page_1') (Line: 2537)
Drupal\views\ViewExecutable->__wakeup()
unserialize('....') (Line: 71)
Drupal\Core\Batch\BatchStorage->load('16') (Line: 75)
Drupal\Core\ProxyClass\Batch\BatchStorage->load('16') (Line: 43)
_batch_page(Object) (Line: 55)
Drupal\system\Controller\BatchController->batchPage(Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 657)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
(unserialize text is removed)
This might have something to do with Drupal 8.5
Comments
Comment #2
Graber CreditAttribution: Graber as a volunteer commentedAs always: please provide steps to reproduce, best on a clean install, there are 1000s of possible config options and other modules or themes you may have installed and we have no idea about, that can cause such an issue.
Comment #3
JonMcL CreditAttribution: JonMcL commentedMy apologies.
After doing a clean install of 8.5 and a quick test with VBO, the problem appears to be localized to my installation.
Comment #4
Graber CreditAttribution: Graber as a volunteer commentedPossible, but it may still be something that should be fixed in VBO, you never know until the actual cause is found.
Comment #5
easp CreditAttribution: easp commentedI am getting the same error. It seems to only happen when I add an exposed filter that is a taxonomy term.
Comment #6
Graber CreditAttribution: Graber as a volunteer commentedReopening until we know what's the cause of the issue and how to address it, external or not.
Comment #7
JonMcL CreditAttribution: JonMcL commentedI still haven't been able to track down a reliable way to test/reproduce, but I think it has something to do with my admin theme (a custom theme with adminimal_theme as base theme, which then uses classy as it's base theme). If I switch back to 'Seven' as my admin theme, all works fine.
There is possibly a discussion of cause and fix here: #2701829: Extension objects should not implement \Serializable, but the patch there didn't seem to solve the issue for me.
I am still investigating when I can find time. Solution for me, for now, is to disable batch processing.
Comment #8
ariane CreditAttribution: ariane commentedI can confirm the same issue using adminimal as admin theme.
I tried to put vbo operations in core view /admin/content and with adminimal, the batch fails, with bartik works ok.
Comment #9
joelpittetFor those who are confirming having this exact problem. Is it the same file? "twig_init('css/core/dialog/off-canvas.layout.css')" in the error output?
adminimal_theme
extends fromseven
and most every theme in core and contrib extends fromclassy
.Comment #10
ariane CreditAttribution: ariane commentedThis is the error I get
Comment #11
socketwench CreditAttribution: socketwench at TEN7 commentedGetting the same error here, removing the exposed filter seems to fix it (also makes my view useless).
Comment #12
Graber CreditAttribution: Graber as a volunteer commentedJust tried to execute a VBO operation using adminimal and still can't reproduce the problem.
Comment #13
Asacolips CreditAttribution: Asacolips commentedI've been encountering this issue in our D8 sites, and I've been able to reproduce on a clean install. To reproduce:
/admin/content
, select several nodes, and attempt to unpublish them with Views Bulk Operations.Log message for the whitescreen that triggers for me. In my case, my vagrant box has the Drupal install in
/var/www/docroot
. It's also worth noting that I'm running this on Scotchbox 2.5 (which still uses PHP 5.6), but my composer config has accounted for that with a php version config setting.Location: http://drupal.test/batch?id=3&op=start
Referrer: http://drupal.test/admin/content
Message:
Comment #14
Graber CreditAttribution: Graber as a volunteer commentedOk, reproduced. Worth adding that the problem only occurs with actions that have no confirm and/or config step implemented.
Comment #15
Graber CreditAttribution: Graber as a volunteer commentedThe passed extension is exactly:
Comment #16
Graber CreditAttribution: Graber as a volunteer commented.. and that in turn is defined in:
/core/themes/stable/stable.info.yml
Comment #17
ordermind CreditAttribution: ordermind commentedThis forum post points to APC as the source of the problem. Could it be the same issue?
Comment #18
mstiTo reproduce the issue:
Global: Views bulk operations
withSave content
actionContent: ID (exposed)
)I am running php 7.0.24.
Visit the view page in the frontend and try to execute the action.
The following error is displayed:
Edited the comment with some extra info about theming
Comment #19
mstiComment #20
Graber CreditAttribution: Graber as a volunteer commentedIs there a corresponding issue on Adminimal project?
Comment #21
interdruper CreditAttribution: interdruper at Interdruper commentedAdditional info to delimit the issue:
Hope it helps.
Comment #22
megadesk3000 CreditAttribution: megadesk3000 at Unic commentedI have the exact same issue described above, but i don't use Views Bulk Operations. So the problem has to be somewhere else.
I use a views reference field inside a paragraph, and the view is displayed in the backend then inside the paragrah. When i try to save the node, the error in the issue description happens.
- I use Adminimal (as described above, the error does not happen when i switch to seven for example)
- The view has an exposed filter for a taxonomy term
Comment #23
skorzhDuring a quick debugging I noticed that the issue can be reproduced only for simple actions without configuration (confirmation) step. Just for testing purposes I added an empty `buildConfigurationForm` method to the few simple actions (like block/unblock users) and everything worked without errors.
So I created a patch with workaround that shows confirmation step for every action, which isn’t a bad idea in general, but I think it requires an additional discussion.
Patch works well in my case, but I didn’t test it for all possible cases, so use it on your own risk.
Hope it will help someone or can be used as an idea for more robust solution.
Comment #24
seanBI think the workaround in #23 is good enough as a temp fix. Maybe this could be added to the module with a @todo to remove that again when we find a proper fix?
Comment #25
Graber CreditAttribution: Graber as a volunteer commentedYes, that is a good suggestion, but it'd be good if we had at least a blocking issue to address before this issue is fixed and the patch can be reverted, otherwise the "temporary" fix will stay there forever because we'll have no knowledge the bug was actually fixed by something.
In the meanwhile, patch review:
There's a route to execute an operation available, so there's no need to enforce a confirmation step if not configured:
views_bulk_operations.execute_batch
, it can be used in such a case.Thanks!
Comment #26
sunAdding the related Drupal Core issue.
Comment #27
Graber CreditAttribution: Graber as a volunteer commentedQuick patch, please test. Looks like we're back to always redirecting due to another core issue :/
Comment #29
Graber CreditAttribution: Graber as a volunteer commentedRight, the controller needed an update for non-batch case.
Comment #30
benjifisherI finally updated from VBO 8.x-1.0-beta4 to 8.x-2.4, and I ran into this issue while testing my (very simple) custom actions. Thanks to all for making my job easy!
The problem goes away after I apply the patch in #29. I consider this (not reviewed, but) tested by the community.
Comment #32
Graber CreditAttribution: Graber as a volunteer commentedPushed the last patch, setting this to postponed so we can watch the related issue and hopefully get rid of the workaround.
Comment #33
khiminrm CreditAttribution: khiminrm at Lemberg Solutions commentedHi! Thanks for a patch! It fixes error, but I've received another.
After submission of form the batch doesn't work and page is redirected to wrong path http://mysite.local/views-bulk-operations/confirm/test_view/page_1
I tried patch with 8.x-2.4 and tried to use last dev version. The result is the same.
I've tried default 'Publish selected content' and 'Unpublish selected content' actions and have the same behavior.
What I've missed to check in settings or in code of custom action?
I use relations with groups in custom view.
I've tried to create new simple view and default actions works. I'll check if relations with groups are source of problem.
I've found source of problem but I don't know hot to fix it yet.
I have settings "Access:Group permission | Access group node overview" in views and it breaks batch.
Any ideas how to fix it?
I've found that ViewsBulkOperationsAccess::access returns AccessResult::forbidden() and it's for user '1'.
$view->access($parameters['display_id'], $account) returns FALSE, because GroupPermission object doesn't receive group object from contexts.
Is there a way to provide context from current views for route 'views_bulk_operations.execute_batch'?
For now I've found only one solution to comment/remove line with '$redirect_route = 'views_bulk_operations.execute_batch';', but with exposed filter in view I receive again "Argument 1 passed to twig_init() must be an instance of " (((
Patch from https://www.drupal.org/project/drupal/issues/2701829#comment-12613145 helped me for VBO 8.x-2.4 without patch from current issue.
If using 'confirm = TRUE' in custom plugin's annotations and group persmission in view's settings, we have also access error on 'views_bulk_operations.confirm' route.
Comment #34
mherchelComment #35
mherchelThe patch in #29 resolved the issue for me on a custom administrative theme that was based off of Seven. I did not run into the issues described in #33. It looks like this hasn't made it to a stable release yet.
Comment #36
heddnBump, I see we are pending this on something. But it isn't clear what or when this can be unpostponed.
Comment #37
Graber CreditAttribution: Graber as a volunteer commentedWell, the related core issue is solved so we can change the status. I'll set this to active so others that experience the problem can investigate if needed.
Comment #38
Graber CreditAttribution: Graber as a volunteer commentedComment #39
ivnish CreditAttribution: ivnish commentedComment #40
benjifisher@ivnish:
Can you explain why you moved this issue to Fixed?
For example, if you tested and the problem is no longer reproducible, then please say so, and give some detail about how you tested. (In this case, it might be better to change the status to "Closer (outdated)" instead of Fixed.)
Comment #41
ivnish CreditAttribution: ivnish commented@benjifisher
1. There is commit #31
2. Core patch #38 was fixed. See comment #37
Comment #42
benjifisherFrom Comment #32:
I think the point of keeping this issue open is to test whether the problem goes away after #2701829: Extension objects should not implement \Serializable was fixed. Drupal 8.6.8 was the first version to include the fix for that issue.
I tested this issue with various old versions:
views_bulk_operations
8.x-2.4 and 8.x-2.5adminimal_theme
8.x-1.5I pretty much followed the steps to reproduce from Comment #13, with a few changes. I installed the Umami demo profile so that there were already some nodes for testing. Instead of changing the view for
/admin/content/
, I added a new Page display at/admin/content-vbo
. To clarify: I removed the existing (core) bulk operations field and added the one from VBO.problem. But the bulk action failed: Access denied.
problem. But the bulk action failed: Access denied.
problem. But the bulk action failed: Access denied.
I think the Access denied is because the Umami demo uses content moderation, so even admin is not allowed to unpublish a node without also changing the moderation state.
Based on that, I am setting the issue status to NW. We should try reverting the fix and see whether the problem comes back.
Comment #43
benjifisherI tried reverting the patch from Comment #29, using the default branch (4.2.x).
There are changes to two files:
src/Controller/ViewsBulkOperationsController.php
andsrc/Plugin/views/field/ViewsBulkOperationsBulkForm.php
. There have been too many changes to the controller since 8.x-2.5, and I do not see how to revert that part. I tried deleting the line indicated by the comment in the plugin:but that led to a new error:
Instead, I decided to keep that line and remove the comments. Then I did some code cleanup:
$redirect_route
is defined in all cases, remove theif (...)
line and the entireelse
clause.$redirect_route
part of theif ... elseif ... else
block.I am attaching a patch for review.
Comment #44
benjifisherThe 4.1.x branch is closer to 8.x-2.5, and I made an almost-clean revert of the patch from #29. In my testing, this works fine.