-
Notifications
You must be signed in to change notification settings - Fork 44
Description
Note: I've posted WordPress.org plugin support forum Multiple issues with version 5.5 but haven't received any responses, probably because I didn't mark it as a support request.
Describe the bug
When editing backup jobs, there are extra entries present in the backwpup_jobs option after deleting the two default and legacy jobs except for one. This is causing inconsistencies – in UI the job has database backup enabled but when running the job it doesn't backup database.
To Reproduce
Steps to reproduce the behavior:
- Install BackWPup and complete initial setup
- Wait for first backup to finish
- Create new backup job
- Check output from
wp option get backwpup_jobs --format=json > backwpup_jobs.json
Expected behavior
Consistency between UI and saved data.
Desktop (please complete the following information):
- OS: Windows 11
- Browser Chrome 140.0.7339.208
- WordPress version: 6.8.3
- PHP version: 8.3.6
Additional context
I went to inspect and exported the jobs as JSON using wp-cli command:
wp option get backwpup_jobs --format=json > backwpup_jobs.jsonThere were two extra entries with only some options present at the end of JSON object. One of them has a "jobid": 4 which matches with entry before it and overrides the "type": ["FILE", "WPPLUGIN"] option from actual job entry but only in UI.
A sample from the exported JSON:
Today I was able to reproduce the issue with a fresh install of BackWPup locally. After initial setup and completion of default job, when I create a new job, the UI shows two jobs but the backwpup_jobs option contains three entries with different jobid properties (1,2,3).
Screenshot of UI after adding new job and reloading page:

Note that "Job ID 1" is not visible but present in the backwpup_jobs.
I've posted the JSON output in a gist: https://gist.github.com/AndisGrossteins/2e44f0b31841c2bdbbaf89a8717dc83a
There's something funky in how the option is updated around here:
Lines 77 to 91 in 39d722a
| $jobids = array_column( $jobs_options, 'jobid' ); | |
| $job_keys = array_keys( $jobs_options ); | |
| $job_index = array_search( $jobid, $jobids, true ); | |
| if ( false !== $job_index ) { | |
| $job_key = $job_keys[ $job_index ]; | |
| } else { | |
| // Prevent collision with existing keys. | |
| $job_key = empty( $job_keys ) ? 0 : max( $job_keys ) + 1; | |
| $jobs_options[ $job_key ] = [ | |
| 'jobid' => $jobid, | |
| ]; | |
| } | |
| $jobs_options[ $job_key ][ $option ] = $value; |
{ "3": { "jobid": 4, "type": ["FILE", "DBDUMP", "WPPLUGIN"], /* {snip} */ }, "4": { "type": ["DBDUMP"], "activetype": "wpcron", "cron": "0 3 * * *" }, "5": { "jobid": 4, "type": ["FILE", "DBDUMP", "WPPLUGIN"] } }