SQL Error on /admin/reports/paragraphs-stats-report due to ONLY_FULL_GROUP_BY SQL mode

Created on 2 November 2023, about 1 year ago
Updated 15 January 2024, 12 months ago

Problem/Motivation

While using the Paragraphs Stats module on a Drupal 10.1.5 site with PHP 8.1.17, an SQL error related to the ONLY_FULL_GROUP_BY SQL mode is encountered when visiting the URL /admin/reports/paragraphs-stats-report. This restricts the functionality and usability of the module.

Steps to reproduce

Install and enable the Paragraphs Stats module on a Drupal 10 site running with PHP 8.1.
Ensure your MySQL database is running with sql_mode including ONLY_FULL_GROUP_BY.
Visit the URL /admin/reports/paragraphs-stats-report.
The SQL error will be displayed.

Proposed resolution

An alternative solution would be to simplify the SELECT statement by removing columns that are not necessary for the result. This way, we avoid potential issues with the ONLY_FULL_GROUP_BY SQL mode and simplify the query:

  1. Adjust the SQL query within the module to remove t.parent_type and t.entity_type from the SELECT clause since they aren't required for grouping or aggregation.
  2. Ensure the modified query produces the desired output and meets the module's requirements.

By implementing this solution, we can make the module compatible with databases that have the ONLY_FULL_GROUP_BY mode enabled without introducing complexity into the query.

Remaining tasks

  1. Confirm the issue in different environments.
  2. Modify the SQL query within the module by removing t.parent_type and t.entity_type from the SELECT clause.
  3. Validate that the simplified query produces accurate and expected results.
  4. Test the adjusted query across various setups and configurations to ensure compatibility.
  5. Review module functionality to ensure no other parts of the module rely on the removed columns.
  6. Update any related documentation or help files if changes are impactful.

User interface changes

No anticipated UI changes as the adjustments are focused on backend SQL queries.

API changes

No API changes are expected since the changes are within an internal SQL query.

Data model changes

No data model changes are required, as the modification is limited to a SELECT statement within a query.

🐛 Bug report
Status

Needs work

Version

1.0

Component

Code

Created by

🇫🇷France m.anoune

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

Comments & Activities

  • Issue created by @m.anoune
  • @manoune opened merge request.
  • Status changed to Needs work 12 months ago
  • 🇵🇱Poland azovsky

    With this fix I have new error:

    Drupal\Component\Plugin\Exception\PluginNotFoundException: The "" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition() (line 139 of core/lib/Drupal/Core/Entity/EntityTypeManager.php).

Production build 0.71.5 2024