Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eZContentClass::fetchAllClassses returns no results on MySQL 8+ #225

Open
benkmugo opened this issue Jun 17, 2024 · 0 comments
Open

eZContentClass::fetchAllClassses returns no results on MySQL 8+ #225

benkmugo opened this issue Jun 17, 2024 · 0 comments

Comments

@benkmugo
Copy link
Member

benkmugo commented Jun 17, 2024

Noting this here until I can test and create a PR

When calling eZContentClass::fetchAllClasses(true, false, false); on a MySQL 8+ based install, no results are returned.
On MariaDB installs, the method works as expected.

The cause is the ORDER BY clause in the query the method constructs when $asObject is set to true (first arg).

The query

SELECT DISTINCT cc.* FROM ezcontentclass cc, ezcontentclass_name WHERE cc.version = 0 AND cc.id = ezcontentclass_name.contentclass_id AND
                                        cc.version = ezcontentclass_name.contentclass_version AND
 ( ezcontentclass_name.language_id & cc.language_mask > 0 AND
     ( (   cc.language_mask - ( cc.language_mask & ezcontentclass_name.language_id ) ) & 1 )
   + ( ( ( cc.language_mask - ( cc.language_mask & ezcontentclass_name.language_id ) ) & 2 ) )
   <
     ( ezcontentclass_name.language_id & 1 )
   + ( ( ezcontentclass_name.language_id & 2 ) )
 )
ORDER BY ezcontentclass_name.name ASC

The error

ERROR 3065 (HY000): Expression #1 of ORDER BY clause is not in SELECT list, references column 'ezpub_2023.ezcontentclass_name.name' which is not in SELECT list; this is incompatible with DISTINCT

The cause
The $asObject ternary does not contain the ezcontentclass_name.name field in the true condition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant