Just tried installing against the latest drupal8, and here is the stack trace

looks like bootstrap_form_alter() needs an update.

here is the change record

https://www.drupal.org/node/2310411

Twig_Error_Runtime: An exception has been thrown during the rendering of a template ("Object of type "Drupal\Core\Page\HtmlPage" cannot be printed.") in "modules/bootstrap/theme/system/html.html.twig" at line 50. in Twig_Template->displayWithErrorHandling() (line 291 of /Users/martin/sites/drupal/core/vendor/twig/twig/lib/Twig/Template.php).

Twig_Template->displayWithErrorHandling(Array, Array)
Twig_Template->display(Array)
Twig_Template->render(Array)
twig_render_template('modules/bootstrap/theme/system/html.html.twig', Array)
_theme('html', Array)
drupal_render(Array)
Drupal\Core\Page\DefaultHtmlPageRenderer->render(Object)
Drupal\Core\Page\DefaultHtmlPageRenderer::renderPage('The website has encountered an error. Please try again later.', 'Error')
_drupal_log_error(Array, 1)
_drupal_error_handler_real(4096, 'Argument 2 passed to bootstrap_form_alter() must be of the type array, object given, called in /Users/martin/sites/drupal/core/lib/Drupal/Core/Theme/ThemeManager.php on line 176 and defined', '/Users/martin/sites/drupal/modules/bootstrap/theme/alter.inc', 107, Array)
_drupal_error_handler(4096, 'Argument 2 passed to bootstrap_form_alter() must be of the type array, object given, called in /Users/martin/sites/drupal/core/lib/Drupal/Core/Theme/ThemeManager.php on line 176 and defined', '/Users/martin/sites/drupal/modules/bootstrap/theme/alter.inc', 107, Array)
bootstrap_form_alter(Array, Object, 'search_block_form')
Drupal\Core\Theme\ThemeManager->alter(Array, Array, Object, 'search_block_form')
Drupal\Core\Form\FormBuilder->prepareForm('search_block_form', Array, Object)
Drupal\Core\Form\FormBuilder->buildForm('Drupal\search\Form\SearchBlockForm', Object)
Drupal\Core\Form\FormBuilder->getForm('Drupal\search\Form\SearchBlockForm')
Drupal\search\Plugin\Block\SearchBlock->build()
Drupal\block\BlockViewBuilder->buildBlock(Array)
Drupal\block\BlockViewBuilder->viewMultiple(Array, 'full', NULL)
Drupal\block\BlockViewBuilder->view(Object)
Drupal\block\Plugin\DisplayVariant\FullPageVariant->build()
block_page_build(Array)
drupal_prepare_page(Array)
Drupal\Core\Page\DefaultHtmlFragmentRenderer->render(Object)
Drupal\Core\EventSubscriber\HtmlViewSubscriber->onHtmlFragment(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object)
Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(Array, 'kernel.view', Object)
Symfony\Component\EventDispatcher\EventDispatcher->dispatch('kernel.view', Object)
Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1)
Drupal\Core\DrupalKernel->handle(Object)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

martin107’s picture

Title: Argument 2 passed to bootstrap_form_alter() must be of the type array, object given, » Keep up to date with form_state changes.
FileSize
1.98 KB

1) HOOK_form_alter now has these function arguments

hook_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id)

In general this module needs some TLC with regard to how it handles forms.

BUT for now I would like to limit the scope of this issue to clearing the errors.

yuradoc’s picture

Hello. I tried to install this theme on D8-beta1.
I've got the mostly the same errors described here.
I use patch listed here and some errors have gone, but this one is still here:

Twig_Error_Runtime: An exception has been thrown during the rendering of a template ("Object of type "Drupal\Core\Page\HtmlPage" cannot be printed.") in "sites/all/themes/bootstrap/theme/system/html.html.twig" at line 46. in Twig_Template->displayWithErrorHandling() (line 291 of /opt/lampp/htdocs/drupal8-beta1/core/vendor/twig/twig/lib/Twig/Template.php).

It happends two times logged in system logs per page load.

martin107’s picture

Issue summary: View changes
Status: Active » Needs review

adding change record.

markhalliwell’s picture

This theme isn't anywhere close to being testable. Modules should be upgraded now that 8.0.0-beta1 is out, not themes (there's still a lot of working being done on the theme system in core).

markhalliwell’s picture

Status: Needs review » Needs work

Also, after briefly looking at the patch I would have to say that this issue needs more work. Just changing the function signatures won't help. $form_state is a class now, not an array so the code inside the functions will not work and possibly even cause fatal errors.

yuradoc’s picture

FileSize
3.57 KB

I made a patch that makes theme working (testable) for me and no errors appears in syslog.
I don't know D8 theme system good, but I used core themes for comparison.

yuradoc’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 6: improvements_that_makes_it_testable-2327907-6.patch, failed testing.

yuradoc’s picture

Sorry, I forget about --relative flag, when made git diff.

yuradoc’s picture

Status: Needs work » Needs review
markhalliwell’s picture

Title: Keep up to date with form_state changes. » Update $form_state array modifications to use the FormStateInterface
Status: Needs review » Needs work
+++ b/theme/settings.inc
@@ -12,7 +13,7 @@
   $theme = !empty($form_state['build_info']['args'][0]) ? $form_state['build_info']['args'][0] : FALSE;

This is what I am talking about: https://www.drupal.org/node/2310411. "$form_state" used to be an array, now it's a classed object.

This line would need to be changed to: $form_state->getBuildInfo()['args'][0], but I'm sure there are others in the alter.inc file like this.

Also, the changes made in the html.html.twig file is not part of this issue.

yuradoc’s picture

I think that changes at html.html.twig is a part of the original pb.
Take a look at the errors stack.

Twig_Error_Runtime: An exception has been thrown during the rendering of a template ("Object of type "Drupal\Core\Page\HtmlPage" cannot be printed.") in "modules/bootstrap/theme/system/html.html.twig" at line 50. in Twig_Template->displayWithErrorHandling() (line 291 of /Users/martin/sites/drupal/core/vendor/twig/twig/lib/Twig/Template.php).

Please make double check of the patch provided. Patch makes changes variables names to correct one like in core themes.
After that I haven't such error messages in the syslog.

The pb you listed about $form_state possibly needs to be resolved, but errors I think that listed here doesn't related to this pb only.

markhalliwell’s picture

It doesn't matter, changing a template file is a separate issue. The very first paragraph or so of the issue summary states:

Just tried installing against the latest drupal8, and here is the stack trace

looks like bootstrap_form_alter() needs an update.

here is the change record

https://www.drupal.org/node/2310411

Any given issue should be about one thing and one thing only. This one is about the form alters and how $form_state changed. If you want to create a separate issue about the html.html.twig page changes, please do. Tracking separate issues is easier for everyone.

yuradoc’s picture

Ok, no metter. I found this issue by this error. And it helped me to resolve the pb.

markhalliwell’s picture

Status: Needs work » Needs review
FileSize
6.58 KB

I'm not entirely sure what you mean by "pb", but here is an updated patch that actually changes the $form_state inside the functions too, not just in the signature.

martin107’s picture

Minor nitpick, I have added a forward slash before Drupal::moduleHandler()

-      if (!Drupal::moduleHandler()->moduleExists($matches[1])) {
+      if (!\Drupal::moduleHandler()->moduleExists($matches[1])) {

So next manual testing, there was a WDOS issue with admin/appearance/settings/bootstrap
which I corrected using the change record.

https://www.drupal.org/node/2346779
l() and url() are deprecated in favor of a routing based URL generation API.

and also

https://www.drupal.org/node/2219113
drupal_json_encode() and drupal_json_decode() moved to \Drupal\Component\Serialization\Json

If you consider this a gross over-extension of this issue then I understand, please let me know ... and will create a separate issue.
I see that as a mild paradox as It is difficult to clear and verify one set of issues without first resolving the other set.

markhalliwell’s picture

Status: Needs review » Closed (duplicate)
Related issues: +#2624420: Restructure code into OO

This related issue has taken care of this. Form alters should now implement the @BootstrapForm annotation plugin.