Problem/Motivation

Drupal core creates the session table lazy on demand, so it does not always exist. When a user logs in with the JWT module and logs out and the session table does not exist yet (during automated test runs for example), then there is a database exception:

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'db.sessions' doesn't exist: ...

Steps to reproduce

1) Install Drupal from scratch, do not login via session. Sessions table does not exist.
2) Login in with JWT (or other login provider)
3) Logout from JWT, trigger hook_user_logout()
4) Database exception happens in ContentLockHooks::userLogout().

Proposed resolution

All direct database queries against the session table must be wrapped with try/catch.

Remaining tasks

Merge request

User interface changes

none

API changes

none

Data model changes

none

CommentFileSizeAuthor
#3 content_lock_3568535.patch1.76 KBklausi
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

klausi created an issue. See original summary.

klausi’s picture

Status: Active » Needs review
StatusFileSize
new1.76 KB

Merge request created.

Uploading stable patch file for composer patches.

klausi’s picture

Tests are failing, but only one phpcs error was relevant to this MR.

aurelianzaha’s picture

thanks for the fix @klausi

aurelianzaha’s picture

Status: Needs review » Reviewed & tested by the community
rajab natshah’s picture

RTBC+1

alexpott made their first commit to this issue’s fork.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Thanks @klausi - this one is hard to test so I agree we should merge this without one.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • alexpott committed 36af1b14 on 3.x
    fix: #3568535 SQLSTATE[42S02]: Base table or view not found: 1146 Table...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.