Skip to content

[DatabaseQueryException] should...gracefully handle insufficient arguments #7863

Open
@garrettds11

Description

@garrettds11

User Story

As a site admin, I'd like to see the plugin patched so that it doesn't produce a fatal error in the site/plugin.

Details

When logging into my site admin console (.wpengine.com), i get a message that says there has been a critical failure and to check my site admin email. Also, donation processing using GiveWP forms on my site are not working correctly, for instance, I am not getting confirmation emails anymore.

Once logged in via recovery mode with the faulty plugin paused, i can see that the GiveWP plugin is crashing with a fatal error. I get 2 error messages that could be helpful. One error message is on the plugins screen. I also get another error message in the site logs.

Error message 1:
An error of type E_ERROR was caused in line 247 of the file /nas/content/live/crosspointb/wp-content/plugins/give/src/Framework/Database/DB.php. Error message: Uncaught Give\Framework\Database\Exceptions\DatabaseQueryException: Database Query in /nas/content/live/crosspointb/wp-content/plugins/give/src/Framework/Database/DB.php:247 Stack trace: #0 /nas/content/live/crosspointb/wp-content/plugins/give/src/Framework/Database/DB.php(86): Give\Framework\Database\DB::runQueryWithErrorChecking(Object(Closure)) #1 /nas/content/live/crosspointb/wp-content/plugins/give/src/Framework/QueryBuilder/Concerns/CRUD.php(103): Give\Framework\Database\DB::__callStatic('get_row', Array) #2 /nas/content/live/crosspointb/wp-content/plugins/give/src/FormBuilder/FormBuilderRouteBuilder.php(84): Give\Framework\QueryBuilder\QueryBuilder->get() #3 /nas/content/live/crosspointb/wp-content/plugins/give/src/FormBuilder/ServiceProvider.php(57): Give\FormBuilder\FormBuilderRouteBuilder->getUrl() #4 /nas/content/live/crosspointb/wp-includes/class-wp-hook.php(324): Give\FormBuilder\ServiceProvider::Give\FormBuilder{closure}('index.php') #5 /nas/content/live/crosspointb/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) #6 /nas/content/live/crosspointb/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #7 /nas/content/live/crosspointb/wp-admin/admin-header.php(118): do_action('admin_enqueue_s...', 'index.php') #8 /nas/content/live/crosspointb/wp-admin/index.php(137): require_once('/nas/content/li...') #9 {main} thrown

Error message 2:
WordPress database error Table 'wp_crosspointb.wp_give_campaigns' doesn't exist for query SELECT * FROM wp_give_campaigns WHERE form_id = 'new' AND campaign_type != 'core' /* From [crosspointb.wpengine.com/wp-admin/plugins.php?plugin_status=paused] in [/nas/content/live/crosspointb/wp-content/plugins/give/src/Framework/Database/DB.php:94

Expected Behavior

I should have been able to login without my site telling me there was a critical error.
Donation form processing should send confirmation emails as configured and as before.

Steps to Reproduce

  1. Go to...
  2. Select...
  3. Scroll down to...
  4. View error

Visuals

Additional Context

On March 31, auto-updates updated my site's GiveWP plugin to v4.0.0.
I understand the latest version 4.0.0 has a new campaigns feature.
I believe bugs in this version are causing a fatal error within GiveWP plugin code on my site.
I believe the failing plugin is not processing GiveWP forms that haven't been configured with the new features.
I used ChatGPT to analyze the two error messages and summarize the issue:

ChatGPT says this, "Based on the GiveWP 4.0.0 update changelog and the timing of the issue, I’m confident this problem is directly related to the new Campaigns architecture introduced in that release.
...
The critical part of the stack trace is this: Give\FormBuilder\FormBuilderRouteBuilder->getUrl()
This strongly suggests that a form was expected to be part of a campaign, but something failed — likely a missing relationship between forms and campaigns in the database.
...
The 4.0.0 Change That Likely Broke Things
"All donation forms belong to a campaign, and each campaign can have multiple forms."
...
This is a breaking schema change — older installations that had forms but no campaign associations are now required to adapt to this new structure.
...
A class (DatabaseQueryException) was changed in the GiveWP 4.0.0 update to require more constructor arguments — but older parts of the plugin or custom code still call it with only one argument.
...
The class DatabaseQueryException was changed to require at least two arguments, so when only one argument is passed, PHP throws a fatal ArgumentCountError.
...
This is GiveWP's bug to fix: they updated a core exception class without updating every reference to it (or adding a backwards-compatible constructor).
Once GiveWP pushes a patch, your local change may get overwritten, so consider reporting this upstream.

System Information

Details

My site: https://crosspointb.wpengine.com/give/
...
WordPress Version: 6.7.1 (Latest version: 6.7.2)
Server architecture: Linux 5.4.0-1129-gcp x86_64
Web server: Apache
PHP version: 8.2.27 (Supports 64bit values)
...
GiveWP Plugin Version: 4.0.0
Author: GiveWP
Last Updated: 5 days ago
Requires WordPress Version: 6.5 or higher
Compatible up to: 6.7.2
Requires PHP Version: 7.4 or higher

Acceptance Criteria

If additional information is needed from my system to analyze this error, contact me at [email protected].
My expectation is that a patch for the new major release will emerge soon that fixes this issue.
In the meantime, a hotfix suggestion would be nice, like a try-catch workaround i can manually edit in the plugin source code. I won't be using any of ChatGPT's code suggestions, however.

THANKS!!!

  • Something happens when an action is taken.
  • Something does not happen when an action is taken.
  • Fixing behavior in Component A does not affect existing behavior in Component B.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugExisting functionality is broken

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions