A 500 error is shown when BibCite keywords are merged using bulk operations

Created on 10 May 2023, over 1 year ago

Problem/Motivation

A 500 error is shown when BibCite keywords are merged using bulk operations (at admin/content/bibcite/keyword)

Steps to reproduce

Step 1: Create a plain Drupal 9 site
Step 2: Install bibcite module: composer require 'drupal/bibcite:^2.0@beta'
Step 3: Enable all submodules of bibcite
Step 4: Go to bibcite/keyword/add to add two keywords (for example: key1 and key2)
Step 5: Go to admin/content/bibcite/keyword, select 'key2', then select 'Merge keyword' in Action, then click 'Apply to selected items'
Step 6: Select target 'key1', then click 'Merge'. It shows error message:
An error has occurred.
Please continue to the error page
An AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: /batch?id=3&op=do_nojs&op=do
StatusText: Internal Server Error
ResponseText: The website encountered an unexpected error. Please try again later.
Step 7: Check admin/reports/dblog, it shows:
Drupal\Core\Entity\Query\QueryException: 'keyword' not found in Drupal\Core\Entity\Query\Sql\Tables->ensureEntityTable() (line 369 of /var/www/html/web/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php).

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada lily.yan

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

Comments & Activities

  • Issue created by @lily.yan
  • πŸ‡¨πŸ‡¦Canada lily.yan

    We still can merge keywords successfully if we run from the operations in the table instead.

    Step 1: Go to admin/content/bibcite/keyword, select 'Merge' under Operations of 'key2'. It goes to admin/content/bibcite/keyword//merge

    Step 2: Select target 'key1', then click 'Merge'. It goes to confirm/cancel page. It shows 'Are you sure you want to merge key2 to key1?', Click 'Confirm'. It shows: 'key2 has been successfully merged and deleted.'

  • πŸ‡ΈπŸ‡ͺSweden thomjjames Sweden

    Hi,

    Also experiencing this on the views bulk action only. I checked the bibcite_keyword database table and from what I can tell it seems the "keyword" field doesn't exist which is why the query fails when it's looking for the "keyword" field. From looking at the database query it looks like it should point to "id" instead.

    It seems like the field_name is passed from the route definition in modules/bibcite_entity/bibcite_entity.routing.yml:

    entity.bibcite_keyword.bibcite_merge_multiple_form:
      path: '/admin/content/bibcite/keyword/merge'
      defaults:
        _form: 'Drupal\bibcite_entity\Form\MergeMultipleForm'
        entity_type_id: 'bibcite_keyword'
        field_name: 'keyword'
      requirements:
        _permission: 'administer bibcite_keyword'
    

    Patch attached against 3.0.x branch or this routeSubscriber seems to fix it too:

    <?php
    
    namespace Drupal\MODULE\Routing;
    
    use Drupal\Core\Routing\RouteSubscriberBase;
    use Symfony\Component\Routing\RouteCollection;
    
    class MODULERouteSubscriber extends RouteSubscriberBase {
    
      public function alterRoutes(RouteCollection $collection) {
        if ($route = $collection->get('entity.bibcite_keyword.bibcite_merge_multiple_form')) {
          // Change the default 'field_name' to 'id'.
          $route->setDefault('field_name', 'id');
        }
      }
    
    }
    

    Cheers
    Tom

  • πŸ‡¨πŸ‡¦Canada lily.yan

    bibcite-keyword-merge-action-3359457-4.patch works for me. Thank you.

Production build 0.71.5 2024