BSOD when accesing hierarchy paragaph report when Xray Audit is enabled before Paragraphs

Created on 16 May 2023, over 1 year ago
Updated 19 June 2024, 3 months ago

Problem/Motivation

The report at /admin/reports/xray-audit/queries_data/queries_data_paragraphs-paragraphs_count_by_hierarchy triggers a fatal error if xray moduel has been enabled before paragraphs module.

This is because XrayAuditQueryTaskParagraphsPlugin::paragraphsIntallActions is called only when Xray Audit is installed through _xray_audit_task_launcher(). That method creates a DB table that this URL is tryng to access. Because Paragrpahs is enabled after Xray audit the table is not created and the error is triggered when trying to access the non-existant table.

Steps to reproduce

  • Install a Drupal site using Umami
  • Enable Xray Audit
  • Enable Paragraphs module
  • Access /admin/reports/xray-audit/queries_data/queries_data_paragraphs-paragraphs_count_by_hierarchy

Teh result is:
Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'drupal.xra_paragraphs_hierarchy_tmp' doesn't exist: TRUNCATE "xra_paragraphs_hierarchy_tmp"; Array ( ) in Drupal\xray_audit\Plugin\xray_audit\tasks\QueryGroup\XrayAuditQueryTaskParagraphsPlugin->paragraphsHierarchyCreateTemporaryTable() (line 235 of /var/www/html/web/modules/contrib/xray_audit/src/Plugin/xray_audit/tasks/QueryGroup/XrayAuditQueryTaskParagraphsPlugin.php).

Proposed resolution

May be implementing hook_modules_installed and acting if paragraph is detected.

A good idea would be to include hook_modules_uninstalled as well, calling XrayAuditQueryTaskParagraphsPlugin::paragraphsUnintallActions.

In those implementations the module should do the same _xray_audit_task_launcher is doing.

Remaining tasks

Implement it.

User interface changes

None.

API changes

Hooks would be implemented, although hthis is not an API change because is the oduel using another API.

Data model changes

None.

🐛 Bug report
Status

Active

Version

1.4

Component

Code

Created by

🇪🇸Spain tunic Madrid

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

Comments & Activities

  • Issue created by @tunic
  • 🇪🇸Spain tunic Madrid

    Becauseteh moduel doens't store data in the databse (apart from some temp data like the talbe of this issue), as a workaround hte module can be uninstalled and installed to fix the issue.

  • 🇪🇸Spain tunic Madrid

    In those implementations the module should do the same _xray_audit_task_launcher is doing.

    This is not so easy. The .module can implement those hooks, but it needs to know to which mdoules react. This means the each report plugin should declare to which modules they want to react. With could just react to any module (aka to any hook_modules_installed and hook_modules_uninstalled calls) but seems an overkill.

  • 🇪🇸Spain tunic Madrid

    Well, I've a very^very ugly code that I'm committing to the issue fork but it needs polishing, review, love and care.

  • Assigned to orodicio
  • Assigned to lpeidro
  • 🇪🇸Spain lpeidro Madrid

    It is possible to build the report with the new service "xray_audit.paragraph_usage_map" that was added in the issue https://www.drupal.org/project/xray_audit/issues/3375018 Report about usage of entity bundles (paragraph, nodes) Fixed .

    With this new service a temporal table in database is not needed.

  • 🇦🇹Austria maxilein

    Is this connected?
    D10.2.7 php 8.3 with xray_audit Version: 1.5.2

    /admin/reports/xray-audit/queries_data/queries_data_paragraphs-paragraphs_count

    The website encountered an unexpected error. Try again later.
    
    Drupal\Core\Database\InvalidQueryException: Query condition 'paragraphs_item_field_data_2.id IN ()' cannot be empty. in Drupal\Core\Database\Query\Condition->condition() (line 106 of core/lib/Drupal/Core/Database/Query/Condition.php).
    
    Drupal\Core\Database\Query\Select->condition() (Line: 77)
    Drupal\Core\Entity\Query\Sql\Condition->compile() (Line: 176)
    Drupal\Core\Entity\Query\Sql\Query->compile() (Line: 27)
    Drupal\Core\Entity\Query\Sql\QueryAggregate->execute() (Line: 179)
    Drupal\xray_audit\Plugin\xray_audit\tasks\QueryGroup\XrayAuditQueryTaskParagraphsPlugin->paragraphsTypes() (Line: 139)
    Drupal\xray_audit\Plugin\xray_audit\tasks\QueryGroup\XrayAuditQueryTaskParagraphsPlugin->getDataOperationResult() (Line: 67)
    Drupal\xray_audit\Controller\XrayAuditTaskController->build()
    call_user_func_array() (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 627)
    Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 58)
    Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
    Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
    Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 106)
    Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
    Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
    Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 704)
    Drupal\Core\DrupalKernel->handle() (Line: 19)
    
    
  • 🇪🇸Spain tunic Madrid

    #17, I'm not sure, but if it is related to this issue you can fix it uninstalling xray audit and installing it again. Try that and if the error is gone you are done, if not please crate a new issue.

  • 🇦🇹Austria maxilein

    did a uninstall.
    cache clear and install.
    Same error.
    I will create a new issue

  • 🇪🇸Spain lpeidro Madrid

    Hello @maxilein, thank very much, I add the link to the new issue: 3455650 🐛 Query condition 'paragraphs_item_field_data_2.id IN Active .

Production build 0.71.5 2024