Better DX/UX on "Base table or view not found" exception

Created on 28 October 2015, about 9 years ago
Updated 16 January 2024, 11 months ago

Problem/Motivation

The developer experience in case of a missing base table is pretty ugly. (See below.) If you're trying to access the site via Drush or don't have error display enabled, all you get is the "Fatal error: Call to a member function get() on a non-object" bit, which is next to worthless. There are certain common situations--e.g., when Drupal's not installed at all--that seem like they should be detected and handled more elegantly.

The website encountered an unexpected error. Please try again later.
Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'drupal.sessions' doesn't exist: SELECT session FROM {sessions} WHERE sid = :sid LIMIT 0, 1; Array ( [:sid] => PVgbX4ihVYdcR0Qy7AUiDsmRG7sr9mTcmHVnCM9Cubw ) in Drupal\Core\Session\SessionHandler->read() (line 66 of core/lib/Drupal/Core/Session/SessionHandler.php).

Drupal\Core\Session\SessionHandler->read('tU1JRHeOON-HVquwCBSfaLcPCLz2h8SjufQB_qweKJk')
Symfony\Component\HttpFoundation\Session\Storage\Handler\WriteCheckSessionHandler->read('tU1JRHeOON-HVquwCBSfaLcPCLz2h8SjufQB_qweKJk')
Drupal\Core\Session\WriteSafeSessionHandler->read('tU1JRHeOON-HVquwCBSfaLcPCLz2h8SjufQB_qweKJk')
Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy->read('tU1JRHeOON-HVquwCBSfaLcPCLz2h8SjufQB_qweKJk')
session_start()
Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->start()
Drupal\Core\Session\SessionManager->startNow()
Drupal\Core\Session\SessionManager->start()
Symfony\Component\HttpFoundation\Session\Session->start()
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1)
Stack\StackedHttpKernel->handle(Object, 1, 1)
Drupal\Core\DrupalKernel->handle(Object)


Fatal error: Call to a member function get() on a non-object in /var/www/core/lib/Drupal/Core/Session/SessionHandler.php on line 81

Proposed resolution

Identify the common cases (e.g., there are no tables in the database at all--Drupal's plain not installed!) and handle them specially.

Remaining tasks

  • Identify common special cases.
  • Determine a better DX/UX.
  • Write automated tests and implement.

User interface changes

N/A

API changes

TBD

Data model changes

N/A

πŸ“Œ Task
Status

Closed: outdated

Version

7.0 ⚰️

Component
DatabaseΒ  β†’

Last updated 2 days ago

  • Maintained by
  • πŸ‡³πŸ‡±Netherlands @daffie
Created by

πŸ‡ΊπŸ‡ΈUnited States traviscarden

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.

Production build 0.71.5 2024