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:
- 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.
- 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
- Confirm the issue in different environments.
- Modify the SQL query within the module by removing t.parent_type and t.entity_type from the SELECT clause.
- Validate that the simplified query produces accurate and expected results.
- Test the adjusted query across various setups and configurations to ensure compatibility.
- Review module functionality to ensure no other parts of the module rely on the removed columns.
- 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.