BoldGrid / boldgrid-inspirations

The BoldGrid Inspirations core plugin for WordPress.
https://www.boldgrid.com/
GNU General Public License v2.0
11 stars 12 forks source link

[Bug] PHP 8 Warning: mysqli_query(): The regular expression contains an unclosed bracket expression. #123

Open jessecowens opened 3 years ago

jessecowens commented 3 years ago

Describe the bug Running PHP 8, the following warnings are thrown when BoldGrid Inspirations is active on every administration screen:

Warning: mysqli_query(): (HY000/3696): The regular expression contains an unclosed bracket expression. in /home/jesseo/Local Sites/inspirations80/app/public/wp-includes/wp-db.php on line 2056
--
1 | 16821136119.5229 | 367296 | {main}( ) | .../post.php:0
2 | 16821136119.5229 | 15586720 | require( '/home/jesseo/Local Sites/inspirations80/app/public/wp-admin/edit-form-advanced.php ) | .../post.php:206
3 | 16821136119.5229 | 15649624 | require_once( '/home/jesseo/Local Sites/inspirations80/app/public/wp-admin/admin-header.php ) | .../edit-form-advanced.php:425
4 | 16821136119.5229 | 16160840 | do_action( ) | .../admin-header.php:252
5 | 16821136119.5229 | 16161216 | WP_Hook->do_action( ) | .../plugin.php:484
6 | 16821136119.5229 | 16161216 | WP_Hook->apply_filters( ) | .../class-wp-hook.php:316
7 | 16821136119.5229 | 16162344 | wp_admin_bar_render( ) | .../class-wp-hook.php:292
8 | 16821136119.5229 | 16163128 | do_action_ref_array( ) | .../admin-bar.php:95
9 | 16821136119.5229 | 16163128 | WP_Hook->do_action( ) | .../plugin.php:551
10 | 16821136119.5229 | 16163128 | WP_Hook->apply_filters( ) | .../class-wp-hook.php:316
11 | 16821136119.5229 | 16197744 | Boldgrid_Inspirations_Purchase_For_Publish->toolbar_link_to_mypage( ) | .../class-wp-hook.php:292
12 | 16821136119.5229 | 16198120 | Boldgrid_Inspirations_Purchase_For_Publish->get_total_cost_to_purchase_for_publishing( ) | .../class-boldgrid-inspirations-purchase-for-publish.php:683
13 | 16821136119.5229 | 16199312 | Boldgrid_Inspirations_Purchase_For_Publish->create_array_assets_needing_purchase( ) | .../class-boldgrid-inspirations-purchase-for-publish.php:189
14 | 16821136119.5229 | 16277896 | Boldgrid_Inspirations_Purchase_For_Publish->asset_needs_purchase( ) | .../class-boldgrid-inspirations-purchase-for-publish.php:868
15 | 16821136119.5229 | 16278984 | wpdb->get_var( ) | .../class-boldgrid-inspirations-purchase-for-publish.php:1310
16 | 16821136119.5229 | 16278984 | wpdb->query( ) | .../wp-db.php:2581
17 | 16821136119.5229 | 16261272 | wpdb->_do_query( ) | .../wp-db.php:1945
18 | 16821136119.5229 | 16261272 | mysqli_query ( ) | .../wp-db.php:2056

To Reproduce Steps to reproduce the behavior:

  1. Enable debug display on PHP 8
  2. Install and activate BoldGrid Inspirations

Additional context These warnings were reported by DreamHost, and replicated on a local installation using PHP 8

jessecowens commented 3 years ago

@bwmarkle This isn't causing any known major issues, but it has been blamed for unrelated issues when examining debug logs

jessecowens commented 1 year ago

@bwmarkle another hit in support about this warning https://www.boldgrid.com/feedback/helpdesks/14/tickets/21022-error-missing-bracket

bwmarkle commented 1 year ago

@jamesros161 can you help out with this one?

jamesros161 commented 1 year ago

@jamesros161 can you help out with this one?

Looking into it

looscrew commented 1 year ago

Getting the same. (w/ DreamHost, PHP 8) Will there be a fix? Admin area is polluted with these warnings.

jessecowens commented 1 year ago

Getting the same. (w/ DreamHost, PHP 8) Will there be a fix? Admin area is polluted with these warnings.

Hi @looscrew - The best immediate fix is to disable WP_DEBUG_DISPLAY in your wp_config.php file. The message itself is just a warning, and doesn't affect operation of the site. Keeping WP_DEBUG_DISPLAY set to false is a good idea in general, because it can show errors to your visitors too. Check out this article on WP_DEBUG.

looscrew commented 1 year ago

Hi @jessecowens, thanks for the response. I'm on a staging site. Debug is on and as I'm in development. The warnings go into the log file too, getting mixed with the real errors. Kind of a pain. I hope this gets resolved.

jessecowens commented 1 year ago

Hi @looscrew - Thanks for the additional info! I spoke to @jamesros161 and we have a potential fix for the problem. We're doing a little testing to make sure it's the right fix, and should have a release ready soon.

If you'd like to help us test the fix, change line 1300 of includes/class-boldgrid-inspirations-purchase-for-publish.php to the following:

        $regexp = '[\\[][^\\]]+[\'\", ]' . $attachment_id . '[^0-9]+.*[\\]]';

If you'd rather just clean up your logs and admin screen, and you've already installed an Inspiration on your staging site, you could also temporarily deactivate the plugin to clean up your logs, the only functionality you'll be missing is the Connect Search stock photo library.

looscrew commented 1 year ago

Hi @jessecowens. I changed line 1300 as suggested. Unfortunately the warnings continue. In addition I killed the PHP process, deleted cache and did hard refresh. To no avail.

I appreciate the care.