• Resolved Eric

    (@ericschuemann)


    Hi NextGEN Team,

    we’re encountering a critical SQL syntax error caused by NextGEN Gallery (version 3.59.10) on our WordPress installation:

    WordPress database error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'FROM xy_posts WHERE 1=1 ...' Query: SELECT SQL_CALC_FOUND_ROWS all FROM xy_posts WHERE ...

    Upon investigation, it seems that the issue originates from the Imagely\NGG\DataMapper\WPPostDriver class. When building the query, the fields parameter is being set to 'all', which is not valid SQL.

    Expected:

    SELECT SQL_CALC_FOUND_ROWS * FROM ...

    But the plugin generates:

    SELECT SQL_CALC_FOUND_ROWS all FROM ...

    We confirmed that:

    • The issue is not caused by the theme (tested with Twenty Twenty-Five 1.2)
    • Other plugins do not interfere
    • The error appears both in the frontend and backend when NextGEN Gallery is active

    Temporary workaround: We tried this filter in functions.php, but it didn’t solve the issue reliably:

    add_filter('posts_fields', function ($fields) { return $fields === 'all' ? '*' : $fields; }, 0);

    We’d appreciate a fix or guidance on how to prevent 'all' from being passed as a field in the query.

    Best regards,
    Eric

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • This seem to work for me:

    /wp-content/plugins/nextgen-gallery/src/DataMapper/WPPostDriver.php, alter line 418:

    $query = new \WP_Query( [ ‘datamapper’ => true, ‘fields’ => ‘*’ ] );

    Looking at the WP Query class, it defaults to ‘all’ if fields is empty.

    Thread Starter Eric

    (@ericschuemann)

    Hi David,

    thank you so much for your help – your solution worked perfectly!

    Changing the line in WPPostDriver.php to explicitly set 'fields' => '*' resolved the SQL syntax error we were encountering. It’s great to know that the 'all' fallback in WP_Query was the root of the issue, and your insight saved us a lot of time.

    I really appreciate your support and quick response.

    Best regards,
    Eric

    Hi @ericschuemann ,

    Thanks for your patience while we looked into the issue.

    It looks like there’s a bug affecting the SQL syntax!

    WA report has been created about this issue to notify our development team about it. I apologize for the inconvenience in the meantime. I can’t currently provide an ETA for when a fix will be released. However, I’m taking note of this thread and I’ll make sure to send you an update when an update that fixes this issue is released.

    @david101design, thank you so much for your invaluable contribution! We truly appreciate you taking the time to explore this issue and offer a solution for the NextGEN community, We are grateful for your support.

    Please let me know if you have any questions.

    Thanks!

    Hi @ericschuemann ,

    Thanks for your patience while we looked into the issue.

    It looks like there’s a bug affecting the SQL syntax!

    A report has been created about this issue to notify our development team about it. I apologize for the inconvenience in the meantime. I can’t currently provide an ETA for when a fix will be released. However, I’m taking note of this thread and I’ll make sure to send you an update when an update that fixes this issue is released.

    @david101design, thank you so much for your invaluable contribution! We truly appreciate you taking the time to explore this issue and offer a solution for the NextGEN community, we are grateful for your support.

    Please let me know if you have any questions.

    Thanks!

    Thanks for the fix David. This plugin’s coding was destroying my error logs making them useless. That stopped the error spam.

    Hi, @ericschuemann !

    I just wanted to give you an update on the issue you reported earlier. Good news! Our team has addressed it in the latest release of NextGEN Gallery v3.59.11, so you should be good to go. 

    To make sure everything is working smoothly, could you please update to the latest version of NextGEN and let us know if you’re still encountering any issues? We really appreciate your help in identifying this problem and your patience as we worked to fix it. 

    If you have any questions or need further assistance, don’t hesitate to reach out.

    Thread Starter Eric

    (@ericschuemann)

    Hi Carlos,

    thanks a lot for the update!

    I just tested the new release (v3.59.11) and can confirm that everything is working smoothly now – no more SQL errors or unexpected behavior. Really appreciate the quick fix and your communication throughout the process.

    Thanks again to you and the team for resolving this so efficiently!

    Best regards,

    Eric

    Hello,

    we had the exact same issue today, and after updating from 3.59.10 to 3.59.11 the error seems to be gone 🙂

    Thanks a lot, and greetings from Palatia to Thuringia / Landau to Erfurt 🙂

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘SQL Syntax Error caused by SELECT SQL_CALC_FOUND_ROWS all in WPPostDriver’ is closed to new replies.