Cart field needs to be installed

Created on 29 April 2020, over 4 years ago
Updated 13 June 2022, over 2 years ago

I have set up a dev D8 site on my linux desktop and come across an issue that has perplexed me and I need some advice. This problem may have arisen from my learning to set up the site with composer, and going through an update from core pre-8.8 and I suspect this is a problem to do with that rather than a problem with the code or my setup.

The admin status report says:

Entity/field definitions
Mismatched entity and/or field definitions
The following changes were detected in the entity type and field definitions.
Order
    The Cart field needs to be installed.

If I visit admin/commerce/orders I get:

The website encountered an unexpected error. Please try again later.

Drupal\Core\Database\DatabaseExceptionWrapper: Exception in Orders[commerce_orders]: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'cart' in 'where clause': SELECT COUNT(*) AS expression FROM (SELECT 1 AS expression FROM {commerce_order} commerce_order WHERE cart <> :db_condition_placeholder_0) subquery; Array ( [:db_condition_placeholder_0] => 1 ) in Drupal\views\Plugin\views\query\Sql->execute() (line 1543 of core/modules/views/src/Plugin/views/query/Sql.php).

Drupal\views\ViewExecutable->execute(NULL) (Line: 1454)
Drupal\views\ViewExecutable->render() (Line: 183)
Drupal\views\Plugin\views\display\Page->execute() (Line: 1630)
Drupal\views\ViewExecutable->executeDisplay('page_1', Array) (Line: 77)
Drupal\views\Element\View::preRenderViewElement(Array)
call_user_func_array(Array, Array) (Line: 100)
Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. Support for this callback implementation is deprecated in 8.8.0 and will be removed in Drupal 9.0.0. See https://www.drupal.org/node/2966725', 'silenced_deprecation', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 781)
Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 372)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 200)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 226)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 573)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 227)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 117)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object) (Line: 156)
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: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 708)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

I tried to uninstall Commerce Cart in the web admin interface but received a similar error preventing me from progressing further.

I don't really want to rebuild this site from scratch, so if anyone is able to give me some suggestions about the cause and how to get round it, I'd be most grateful.

Thanks
Martin

💬 Support request
Status

Active

Version

2.17

Component

Cart

Created by

🇬🇧United Kingdom nattyweb

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇪🇸Spain aleix

    I found the same when it was half installed because faulty php settings, timeout or so. This must not happen when using "drush en", I suspect that the problem here is not in commerce module but in server environment, so it's a support request rather than a commerce issue.

    Anyway, I need to reinstall the 'cart' field definition existing in commerce_cart_entity_base_field_info , using the method:

    https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21...

    To call this, one can call it just before the uninstallFieldStorageDefinition called in core/lib/Drupal/Core/Extension/ModuleInstaller.php:497 uninstall method:

    +$update_manager->uninstallFieldStorageDefinition('cart', $entity_type->id(), 'commerce_cart, $storage_definition);
    $update_manager->uninstallFieldStorageDefinition($storage_definition);
    

    If trying to reinstall commerce_cart complains about existing core.entity_view_mode.commerce_product_attribute_value.add_to_cart, then the conf may need to be deleted (drush cdel can do it)

  • 🇮🇱Israel jsacksick

    Closing this as what you're describing seems more of a general Drupal core problem...

Production build 0.71.5 2024