Long field names which are shortened by Drupal doesn't work.

Created on 2 September 2020, over 4 years ago
Updated 23 May 2023, over 1 year ago

Problem/Motivation

For fields that have really long names, you get this error:

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'drupal8.field_collection_item__field_test_a_really_long_text_f' doesn't exist: SELECT t.* FROM {field_collection_item__field_test_a_really_long_text_f} t; Array ( ) in Drupal\security_review\Checks\Field->run() (line 86 of /app/web/modules/contrib/security_review/src/Checks/Field.php).

Steps to reproduce

  1. Install Field collection module.
  2. Create a field collection field for any content type.
  3. Under that field collection field, create a Long text field with a very long field name.
  4. Run the "Content" check.

Proposed resolution

Attached patch.

Remaining tasks

Test coverage?

πŸ› Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

πŸ‡΅πŸ‡­Philippines dsdeiz

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.

  • πŸ‡·πŸ‡΄Romania claudiu.cristea Arad πŸ‡·πŸ‡΄

    Yes, the bug is still there and the patch is fixing the issue. Long field name dedicated tables are built by using a hash to avoid going beyond the max table name length. This was spotted also in πŸ› Missing Table? Closed: works as designed

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Can you verify if this is happening in the 2.x branch?

  • Status changed to Postponed: needs info over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    If this can be tested on 2.x branch.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Following up if this can be tried on 2.x branch before closing?

  • Status changed to Needs review over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Scratch that found a dup that seems to have gotten this a week ago.

  • πŸ‡²πŸ‡ΎMalaysia akmalfikri

    This also happened on database with table prefix in them.

    Example : The website encountered an unexpected error. Please try again later.Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'db.block_content__body' doesn't exist: SELECT `entity_id`, `body_value` FROM block_content__body while the table should be db.drupal_block_content__body instead.

  • πŸ‡ΊπŸ‡ΈUnited States greggles Denver, Colorado, USA

    @akmalfikri thanks for the report. Does the proposed patch solve the problem?

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    @akmalfikri following up if you tested the patch?

  • Status changed to Postponed: needs info 12 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave
  • Status changed to Fixed 12 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    This is in the 3.x branch

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

  • πŸ‡¬πŸ‡§United Kingdom czollli

    Hello,
    This is still an issue with latest version (3.1.1)
    on Drupal 10.3.9 + CiviCRM
    although it does not look due to the long field name.

    2024/12/12 11:38:44 [error] 401842#401842: *383659 FastCGI sent in stderr: "PHP message: Uncaught PHP Exception Drupal\Core\Database\DatabaseExceptionWrapper: "SQLSTATE[42S02]: Base table or view not found: 1146 Table 'i9_drupal10.civicrm_action_schedule' doesn't exist: SELECT COUNT(*) AS "expression"
    FROM
    (SELECT 1 AS "expression"
    FROM
    "civicrm_action_schedule" "t") "subquery"; Array
    (
    )
    " at /var/www/html/circle/drupal10/web/core/modules/mysql/src/Driver/Database/mysql/ExceptionHandler.php line 56" while reading response header from upstream, client:
    

    Is it possible the problem is that we use separate database for drupal and civicrm?

  • πŸ‡²πŸ‡ΎMalaysia akmalfikri

    @smustgrave Prefix issue is fixed on latest patch. Thanks!

Production build 0.71.5 2024