Added check for backend's checkDependencies method to OC_Mount_Config::getBackends() when backend is configured to have some instead of blindly calling it and crashing
Conflicts:
apps/files_external/lib/config.php
apps/files_external/lib/google.php
'configured' => '#configured',
'token' => '#token',
'token_secret' => '#token secret'),
- 'custom' => 'google'));
+ 'custom' => 'google',
+ 'has_dependencies' => true));
OC_Mount_Config::registerBackend('\OC\Files\Storage\SWIFT', array(
'backend' => 'OpenStack Swift',
'user' => 'Username',
'password' => '*Password',
'root' => '&Root',
- 'secure' => '!Secure https://')));
+ 'secure' => '!Secure https://'),
+ 'has_dependencies' => true));
OC_Mount_Config::registerBackend('\OC\Files\Storage\SFTP', array(
'backend' => 'SFTP',
foreach (OC_Mount_Config::$backends as $class => $backend) {
if (isset($backend['has_dependencies']) and $backend['has_dependencies'] === true) {
- if ($class::checkDependencies() !== true) {
+ if (!method_exists($class, 'checkDependencies')) {
+ \OCP\Util::writeLog('files_external', "Backend class $class has dependencies but doesn't provide method checkDependencies()", \OCP\Util::DEBUG);
+ continue;
+ } elseif ($class::checkDependencies() !== true) {
continue;
}
}
uasort($backends, $sortFunc);
- return($backends);
+ return $backends;
}
/**
const DRAWING = 'application/vnd.google-apps.drawing';
const PRESENTATION = 'application/vnd.google-apps.presentation';
+ /**
+ * check if curl is installed
+ */
+ public static function checkDependencies() {
+ if (function_exists('curl_init')) {
+ return true;
+ } else {
+ $l = new \OC_L10N('files_external');
+ return $l->t('<b>Warning:</b> The cURL support in PHP is not enabled or installed. Mounting of Google Drive is not possible. Please ask your system administrator to install it.');
+ }
+ }
+
public function __construct($params) {
if (isset($params['configured']) && $params['configured'] === 'true'
&& isset($params['client_id']) && isset($params['client_secret'])
private static $tempFiles = array();
+ /**
+ * check if curl is installed
+ */
+ public static function checkDependencies() {
+ if (function_exists('curl_init')) {
+ return true;
+ } else {
+ $l = new \OC_L10N('files_external');
+ return $l->t('<b>Warning:</b> The cURL support in PHP is not enabled or installed. Mounting of ownCloud / WebDAV is not possible. Please ask your system administrator to install it.');
+ }
+ }
+
public function __construct($params) {
if (isset($params['host']) && isset($params['user']) && isset($params['password'])) {
$host = $params['host'];