How to tweak this plugin for PHP 7
-
Hey all– as some have noted, this plugin doesn’t work under PHP 7. Typically it complains that it’s having trouble uploading to Dropbox, and logs show a bad Dropbox API with an unexpected “overwrite” parameter.
Presumably the author will update this sooner or later; for the time being, here’s a quick source code tweak that made it work for me. All paths are relative to
$YOUR_SITE_DIRECTORY/wp-content/plugins/wordpress-backup-to-dropbox
.In file
Dropbox/Dropbox/OAuth/Consumer/Curl.php
: comment out the line:
$options[CURLOPT_SAFE_UPLOAD] = false;
(this option is no longer valid in PHP 7)In file
Dropbox/Dropbox/OAuth/Consumer/ConsumerAbstract.php
: replace the testif (isset($value[0]) && $value[0] === '@')
withif ($value instanceof CURLFile)
In file
Dropbox/Dropbox/API.php
: replace'file' => '@' . str_replace('\\', '/', $file) . ';filename=' . $filename
with'file' => new CURLFile(str_replace('\\', '/', $file), "application/octet-stream", $filename)
This replaces the long-deprecated, now-disabled support for uploading files with “@/file/to/upload” with the replacement “CURLFile” class. Also a note to the author (and optional patch for the reader): check the return value for
curl_setopt_array
, as this was failing unnoticed, leading to confusing behaviour downstream.
- The topic ‘How to tweak this plugin for PHP 7’ is closed to new replies.