wp-media / backwpup

BackWPup - WordPress Backup Plugin
https://backwpup.com
GNU General Public License v2.0
88 stars 36 forks source link

[Bug]: Add destinations to Backwpup with an addons plugins #127

Open Idealcomm opened 1 year ago

Idealcomm commented 1 year ago

Description of the bug

Hello,

Your plugin has no native Pcloud implementation, so I’m trying to create an addon plugin to do this, I saw you had the “backwpup_register_destination” hook to add a destination, so I did this:

function addPcloud() { if(is_plugin_active( 'backwpup/backwpup.php' )) { require_once 'inc/class-destination-pcloud.php'; function register_destination_pcloud($registered_destinations) { $registered_destinations["PCLOUD"] = [ 'class' => \BackWPup_Destination_Pcloud::class, 'info' => [ 'ID' => 'PCLOUD', 'name' => ('Pcloud', 'backwpup'), 'description' => ('Backup to Pcloud', 'backwpup'), ], 'can_sync' => false, 'needed' => [ 'php_version' => '', 'functions' => ['curl_exec'], 'classes' => [], ], ]; return $registered_destinations; } add_filter('backwpup_register_destination', "register_destination_pcloud"); } }

add_action('admin_init', 'addPcloud');

(it changes nothing to the bug if i change "admin_init" by "init" or if remove the if(is_plugin_active('backwpup/backwpup.php' ) )

I have copy the Dropbox Classes which have similar api connection to Pcloud and i have change all i need to change (for the moment, I have just a connection to Pcloud API and all the others functions are same as Dropbox).

It work, i can configure my job and get my pcloud token but when i launch the job via action : “runnow” (i don’t expect it send file because i don’t modify the function to do this) it don’t find the destination although my jobs is configured…

Bellow the log error :

[INFO] BackWPup 4.0.0; A project of Inpsyde GmbH [INFO] WordPress 5.9.7 [INFO] Log Level: Debug [INFO] BackWPup job: Opération avec l´ID 2; DBDUMP+FILE+WPPLUGIN [INFO] Runs with user: (0) [INFO] BackWPup no automatic job start configured [INFO] BackWPup job started manually [INFO] PHP ver.: 7.3.33 (32bit); cgi-fcgi; Linux [INFO] Maximum PHP script execution time is 165 seconds [INFO] Script restart time is configured to 30 seconds [INFO] MySQL ver.: 5.7.42-log [INFO] Web Server: Apache [INFO] curl ver.: 7.38.0; OpenSSL/1.0.1t [INFO] Temp folder is: /home/clapsoorbe/preprodcria/wp-content/uploads/backwpup-c16906-temp/ [INFO] Logfile is: /home/clapsoorbe/preprodcria/wp-content/uploads/backwpup-c16906-logs/backwpup_log_25fc73_2023-06-14_09-30-03.html [INFO] Backup file is: /home/clapsoorbe/preprodcria/wp-content/uploads/backwpup-c16906-temp/2023-06-14_09-30-03_PXAWSBX202.zip [14-Jun-2023 09:30:03] ERROR: No destination correctly defined for backup! Please correct job settings. [14-Jun-2023 09:30:03] ERROR: Job has ended with errors in 0 seconds. You must resolve the errors for correct execution.

After some research, i found the function create (in class-job.php), and try many test, it seems that my destination don’t exist when BackWPup::get_registered_destinations() is call inside the function “create” (also in start_http which call the create function) but if i call BackWPup::get_registered_destinations() in the html of class-page-jobs.php my destination exist ! Therefore, the verification of the job’s destination don’t match with any listed destination.

I also found my Pcloud Class is not the problem, because i add Dropbox Class to my registered destination and reconfigure the task and it does the same !

Reproduction instructions

1- Create a plugin 2- add destinations (like explain in the description of the bug) 3- code your class based on dropbox 4- add a job and configure it 5- launch the job the jobs page link (action "runnow")

Expected behavior

I expect the code run and found my added destination.

Environment info

BackWPup 4.0.0 WordPress 5.9.7 PHP ver.: 7.3.33 (32bit) Linux MySQL ver.: 5.7.42-log Web Server: Apache curl ver.: 7.38.0

Relevant log output

[INFO] BackWPup 4.0.0; A project of Inpsyde GmbH
[INFO] WordPress 5.9.7
[INFO] Log Level: Debug
[INFO] BackWPup job: Opération avec l´ID 2; DBDUMP+FILE+WPPLUGIN
[INFO] Runs with user: (0)
[INFO] BackWPup no automatic job start configured
[INFO] BackWPup job started manually
[INFO] PHP ver.: 7.3.33 (32bit); cgi-fcgi; Linux
[INFO] Maximum PHP script execution time is 165 seconds
[INFO] Script restart time is configured to 30 seconds
[INFO] MySQL ver.: 5.7.42-log
[INFO] Web Server: Apache
[INFO] curl ver.: 7.38.0; OpenSSL/1.0.1t
[INFO] Temp folder is: /home/clapsoorbe/preprodcria/wp-content/uploads/backwpup-c16906-temp/
[INFO] Logfile is: /home/clapsoorbe/preprodcria/wp-content/uploads/backwpup-c16906-logs/backwpup_log_25fc73_2023-06-14_09-30-03.html
[INFO] Backup file is: /home/clapsoorbe/preprodcria/wp-content/uploads/backwpup-c16906-temp/2023-06-14_09-30-03_PXAWSBX202.zip
[14-Jun-2023 09:30:03] ERROR: No destination correctly defined for backup! Please correct job settings.
[14-Jun-2023 09:30:03] ERROR: Job has ended with errors in 0 seconds. You must resolve the errors for correct execution.

Additional context

No response

Code of Conduct