• Resolved david101design

    (@david101design)


    version 3.59.10

    Upgrading to WordPress 6.8 produces this 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 wp_posts WHERE 1=1 AND ((wp_posts.post_type = ‘post’ AND (wp_pos…’ at line 2

    == Problem Query:

    SELECT SQL_CALC_FOUND_ROWS all
    FROM wp_posts
    WHERE 1=1
    AND ((wp_posts.post_type = 'post'
    AND (wp_posts.post_status = 'publish'
    OR wp_posts.post_status = 'acf-disabled'
    OR wp_posts.post_status = 'future'
    OR wp_posts.post_status = 'draft'
    OR wp_posts.post_status = 'pending'
    OR wp_posts.post_status = 'private')))
    ORDER BY wp_posts.post_date DESC
    LIMIT 0, 10

    That ‘all’ in the query seems off.

    == Stack trace:

    1. WP_Query->get_posts()
      wp-includes/class-wp-query.php:3429
    2. WP_Query->query()
      wp-includes/class-wp-query.php:3949
    3. WP_Query->__construct()
      wp-includes/class-wp-query.php:4081
    4. Imagely\N\D\WPPostDriver->run_query()
      wp-content/plugins/nextgen-gallery/src/DataMapper/WPPostDriver.php:418
    5. Imagely\N\D\DriverBase->find_all()
      wp-content/plugins/nextgen-gallery/src/DataMapper/DriverBase.php:174
    6. M_Marketing->{closure}()
      wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/marketing/module.marketing.php:171
    7. do_action('init')
      wp-includes/plugin.php:517

    Thanks.

Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter david101design

    (@david101design)

    This seems to work as a fix:

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

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

    Thanks for this, I’m having the same problem. I’ll update WPPostDriver.php and let you know if it fixes it for me too.

    Yes, thats fixed it for me too. Thank you @david101design

    Hi @david101design ,

    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.

    Temporary workaround:

    Thanks for suggesting the temporary solution. We truly appreciate you taking the time to explore this issue and offer a solution for the NextGEN community.

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

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

    Please let me know if you have any questions.

    Thanks!

    same issue

    Hi, @david101design !

    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.

    That update works for me! Thank you @cecarmona

    Thread Starter david101design

    (@david101design)

    @cecarmona Updated now. All good so far. Thanks.

    Same issue.

    I did upgrade to 3.59.12 and one error log seems to have stopped but this one in WP-ADMIN keeps growing:

    14-Jun-2025 19:22:30 UTC] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘FROM wp_posts
    WHERE 1=1 AND ((wp_posts.post_type = ‘post’ AND (wp_posts.’ at line 2 for query SELECT SQL_CALC_FOUND_ROWS all
    FROM wp_posts
    WHERE 1=1 AND ((wp_posts.post_type = ‘post’ AND (wp_posts.post_status = ‘publish’ OR wp_posts.post_status = ‘future’ OR wp_posts.post_status = ‘draft’ OR wp_posts.post_status = ‘pending’
    OR wp_posts.post_status = ‘private’)))

                     ORDER BY wp_posts.post_date DESC
                     LIMIT 0, 12 made by require_once('wp-admin/admin.php'), require_once('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), do_action('init'), WP_Hook->do_action, WP_Hook->apply_filters, M_Marketing->{closure}, Imagely\NGG\DataMapper\DriverBase->find_all, Imagely\NGG\DataMapper\WPPostDriver->run_query, WP_Query->__construct, WP_Query->query, WP_Query->get_posts

    [14-Jun-2025 19:22:40 UTC] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘FROM wp_posts
    WHERE 1=1 AND ((wp_posts.post_type = ‘post’ AND (wp_posts.’ at line 2 for query SELECT SQL_CALC_FOUND_ROWS all
    FROM wp_posts
    WHERE 1=1 AND ((wp_posts.post_type = ‘post’ AND (wp_posts.post_status = ‘publish’ OR wp_posts.post_status = ‘future’ OR wp_posts.post_status = ‘draft’ OR wp_posts.post_status = ‘pending’
    OR wp_posts.post_status = ‘private’)))

                     ORDER BY wp_posts.post_date DESC
                     LIMIT 0, 12 made by require_once('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), do_action('init'), WP_Hook->do_action, WP_Hook->apply_filters, M_Marketing->{closure}, Imagely\NGG\DataMapper\DriverBase->find_all, Imagely\NGG\DataMapper\WPPostDriver->run_query, WP_Query->__construct, WP_Query->query, WP_Query->get_posts

    Thanks for the help!

    Actually, may have to take that back. I did check the mentioned php line 418 and it is correct. Since then, the error only occurred once and now seems to have stopped building up. I’ll keep an eye on it.

    Same issue on v3.59.12 except error is coming from a different file:

    /wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/datamapper/package.module.datamapper.php:1529

    It’s the same line of code and switching it to the “Temporary workaround” version fixed it. https://ww.wp.xz.cn/support/topic/wordpress-6-8-database-error/#post-18422379

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

The topic ‘WordPress 6.8 database error’ is closed to new replies.