@@ -36,91 +36,91 @@ |
||
36 | 36 | */ |
37 | 37 | interface IRouter { |
38 | 38 | |
39 | - /** |
|
40 | - * Get the files to load the routes from |
|
41 | - * |
|
42 | - * @return string[] |
|
43 | - * @since 7.0.0 |
|
44 | - * @deprecated 9.0.0 |
|
45 | - */ |
|
46 | - public function getRoutingFiles(); |
|
39 | + /** |
|
40 | + * Get the files to load the routes from |
|
41 | + * |
|
42 | + * @return string[] |
|
43 | + * @since 7.0.0 |
|
44 | + * @deprecated 9.0.0 |
|
45 | + */ |
|
46 | + public function getRoutingFiles(); |
|
47 | 47 | |
48 | - /** |
|
49 | - * @return string |
|
50 | - * @since 7.0.0 |
|
51 | - * @deprecated 9.0.0 |
|
52 | - */ |
|
53 | - public function getCacheKey(); |
|
48 | + /** |
|
49 | + * @return string |
|
50 | + * @since 7.0.0 |
|
51 | + * @deprecated 9.0.0 |
|
52 | + */ |
|
53 | + public function getCacheKey(); |
|
54 | 54 | |
55 | - /** |
|
56 | - * Loads the routes |
|
57 | - * |
|
58 | - * @param null|string $app |
|
59 | - * @since 7.0.0 |
|
60 | - * @deprecated 9.0.0 |
|
61 | - */ |
|
62 | - public function loadRoutes($app = null); |
|
55 | + /** |
|
56 | + * Loads the routes |
|
57 | + * |
|
58 | + * @param null|string $app |
|
59 | + * @since 7.0.0 |
|
60 | + * @deprecated 9.0.0 |
|
61 | + */ |
|
62 | + public function loadRoutes($app = null); |
|
63 | 63 | |
64 | - /** |
|
65 | - * Sets the collection to use for adding routes |
|
66 | - * |
|
67 | - * @param string $name Name of the collection to use. |
|
68 | - * @return void |
|
69 | - * @since 7.0.0 |
|
70 | - * @deprecated 9.0.0 |
|
71 | - */ |
|
72 | - public function useCollection($name); |
|
64 | + /** |
|
65 | + * Sets the collection to use for adding routes |
|
66 | + * |
|
67 | + * @param string $name Name of the collection to use. |
|
68 | + * @return void |
|
69 | + * @since 7.0.0 |
|
70 | + * @deprecated 9.0.0 |
|
71 | + */ |
|
72 | + public function useCollection($name); |
|
73 | 73 | |
74 | - /** |
|
75 | - * returns the current collection name in use for adding routes |
|
76 | - * |
|
77 | - * @return string the collection name |
|
78 | - * @since 8.0.0 |
|
79 | - * @deprecated 9.0.0 |
|
80 | - */ |
|
81 | - public function getCurrentCollection(); |
|
74 | + /** |
|
75 | + * returns the current collection name in use for adding routes |
|
76 | + * |
|
77 | + * @return string the collection name |
|
78 | + * @since 8.0.0 |
|
79 | + * @deprecated 9.0.0 |
|
80 | + */ |
|
81 | + public function getCurrentCollection(); |
|
82 | 82 | |
83 | - /** |
|
84 | - * Create a \OCP\Route\IRoute. |
|
85 | - * |
|
86 | - * @param string $name Name of the route to create. |
|
87 | - * @param string $pattern The pattern to match |
|
88 | - * @param array $defaults An array of default parameter values |
|
89 | - * @param array $requirements An array of requirements for parameters (regexes) |
|
90 | - * @return \OCP\Route\IRoute |
|
91 | - * @since 7.0.0 |
|
92 | - * @deprecated 9.0.0 |
|
93 | - */ |
|
94 | - public function create($name, $pattern, array $defaults = [], array $requirements = []); |
|
83 | + /** |
|
84 | + * Create a \OCP\Route\IRoute. |
|
85 | + * |
|
86 | + * @param string $name Name of the route to create. |
|
87 | + * @param string $pattern The pattern to match |
|
88 | + * @param array $defaults An array of default parameter values |
|
89 | + * @param array $requirements An array of requirements for parameters (regexes) |
|
90 | + * @return \OCP\Route\IRoute |
|
91 | + * @since 7.0.0 |
|
92 | + * @deprecated 9.0.0 |
|
93 | + */ |
|
94 | + public function create($name, $pattern, array $defaults = [], array $requirements = []); |
|
95 | 95 | |
96 | - /** |
|
97 | - * Find the route matching $url. |
|
98 | - * |
|
99 | - * @param string $url The url to find |
|
100 | - * @throws \Exception |
|
101 | - * @return void |
|
102 | - * @since 7.0.0 |
|
103 | - * @deprecated 9.0.0 |
|
104 | - */ |
|
105 | - public function match($url); |
|
96 | + /** |
|
97 | + * Find the route matching $url. |
|
98 | + * |
|
99 | + * @param string $url The url to find |
|
100 | + * @throws \Exception |
|
101 | + * @return void |
|
102 | + * @since 7.0.0 |
|
103 | + * @deprecated 9.0.0 |
|
104 | + */ |
|
105 | + public function match($url); |
|
106 | 106 | |
107 | - /** |
|
108 | - * Get the url generator |
|
109 | - * |
|
110 | - * @since 7.0.0 |
|
111 | - * @deprecated 9.0.0 |
|
112 | - */ |
|
113 | - public function getGenerator(); |
|
107 | + /** |
|
108 | + * Get the url generator |
|
109 | + * |
|
110 | + * @since 7.0.0 |
|
111 | + * @deprecated 9.0.0 |
|
112 | + */ |
|
113 | + public function getGenerator(); |
|
114 | 114 | |
115 | - /** |
|
116 | - * Generate url based on $name and $parameters |
|
117 | - * |
|
118 | - * @param string $name Name of the route to use. |
|
119 | - * @param array $parameters Parameters for the route |
|
120 | - * @param bool $absolute |
|
121 | - * @return string |
|
122 | - * @since 7.0.0 |
|
123 | - * @deprecated 9.0.0 |
|
124 | - */ |
|
125 | - public function generate($name, $parameters = [], $absolute = false); |
|
115 | + /** |
|
116 | + * Generate url based on $name and $parameters |
|
117 | + * |
|
118 | + * @param string $name Name of the route to use. |
|
119 | + * @param array $parameters Parameters for the route |
|
120 | + * @param bool $absolute |
|
121 | + * @return string |
|
122 | + * @since 7.0.0 |
|
123 | + * @deprecated 9.0.0 |
|
124 | + */ |
|
125 | + public function generate($name, $parameters = [], $absolute = false); |
|
126 | 126 | } |
@@ -36,27 +36,27 @@ |
||
36 | 36 | * @since 7.0.0 |
37 | 37 | */ |
38 | 38 | class LockNotAcquiredException extends \Exception { |
39 | - /** @var string $path The path that could not be locked */ |
|
40 | - public $path; |
|
39 | + /** @var string $path The path that could not be locked */ |
|
40 | + public $path; |
|
41 | 41 | |
42 | - /** @var integer $lockType The type of the lock that was attempted */ |
|
43 | - public $lockType; |
|
42 | + /** @var integer $lockType The type of the lock that was attempted */ |
|
43 | + public $lockType; |
|
44 | 44 | |
45 | - /** |
|
46 | - * @since 7.0.0 |
|
47 | - */ |
|
48 | - public function __construct($path, $lockType, $code = 0, \Exception $previous = null) { |
|
49 | - $message = \OC::$server->getL10N('core')->t('Could not obtain lock type %d on "%s".', [$lockType, $path]); |
|
50 | - parent::__construct($message, $code, $previous); |
|
51 | - } |
|
45 | + /** |
|
46 | + * @since 7.0.0 |
|
47 | + */ |
|
48 | + public function __construct($path, $lockType, $code = 0, \Exception $previous = null) { |
|
49 | + $message = \OC::$server->getL10N('core')->t('Could not obtain lock type %d on "%s".', [$lockType, $path]); |
|
50 | + parent::__construct($message, $code, $previous); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * custom string representation of object |
|
55 | - * |
|
56 | - * @return string |
|
57 | - * @since 7.0.0 |
|
58 | - */ |
|
59 | - public function __toString() { |
|
60 | - return __CLASS__ . ": [{$this->code}]: {$this->message}\n"; |
|
61 | - } |
|
53 | + /** |
|
54 | + * custom string representation of object |
|
55 | + * |
|
56 | + * @return string |
|
57 | + * @since 7.0.0 |
|
58 | + */ |
|
59 | + public function __toString() { |
|
60 | + return __CLASS__ . ": [{$this->code}]: {$this->message}\n"; |
|
61 | + } |
|
62 | 62 | } |
@@ -28,39 +28,39 @@ |
||
28 | 28 | * @since 8.2.0 |
29 | 29 | */ |
30 | 30 | interface ICompositeExpression { |
31 | - /** |
|
32 | - * Adds multiple parts to composite expression. |
|
33 | - * |
|
34 | - * @param array $parts |
|
35 | - * |
|
36 | - * @return ICompositeExpression |
|
37 | - * @since 8.2.0 |
|
38 | - */ |
|
39 | - public function addMultiple(array $parts = []); |
|
31 | + /** |
|
32 | + * Adds multiple parts to composite expression. |
|
33 | + * |
|
34 | + * @param array $parts |
|
35 | + * |
|
36 | + * @return ICompositeExpression |
|
37 | + * @since 8.2.0 |
|
38 | + */ |
|
39 | + public function addMultiple(array $parts = []); |
|
40 | 40 | |
41 | - /** |
|
42 | - * Adds an expression to composite expression. |
|
43 | - * |
|
44 | - * @param mixed $part |
|
45 | - * |
|
46 | - * @return ICompositeExpression |
|
47 | - * @since 8.2.0 |
|
48 | - */ |
|
49 | - public function add($part); |
|
41 | + /** |
|
42 | + * Adds an expression to composite expression. |
|
43 | + * |
|
44 | + * @param mixed $part |
|
45 | + * |
|
46 | + * @return ICompositeExpression |
|
47 | + * @since 8.2.0 |
|
48 | + */ |
|
49 | + public function add($part); |
|
50 | 50 | |
51 | - /** |
|
52 | - * Retrieves the amount of expressions on composite expression. |
|
53 | - * |
|
54 | - * @return integer |
|
55 | - * @since 8.2.0 |
|
56 | - */ |
|
57 | - public function count(); |
|
51 | + /** |
|
52 | + * Retrieves the amount of expressions on composite expression. |
|
53 | + * |
|
54 | + * @return integer |
|
55 | + * @since 8.2.0 |
|
56 | + */ |
|
57 | + public function count(); |
|
58 | 58 | |
59 | - /** |
|
60 | - * Returns the type of this composite expression (AND/OR). |
|
61 | - * |
|
62 | - * @return string |
|
63 | - * @since 8.2.0 |
|
64 | - */ |
|
65 | - public function getType(); |
|
59 | + /** |
|
60 | + * Returns the type of this composite expression (AND/OR). |
|
61 | + * |
|
62 | + * @return string |
|
63 | + * @since 8.2.0 |
|
64 | + */ |
|
65 | + public function getType(); |
|
66 | 66 | } |
@@ -32,60 +32,60 @@ |
||
32 | 32 | */ |
33 | 33 | abstract class Provider { |
34 | 34 | |
35 | - /** |
|
36 | - * @since 8.0.0 |
|
37 | - */ |
|
38 | - const OPTION_APPS = 'apps'; |
|
35 | + /** |
|
36 | + * @since 8.0.0 |
|
37 | + */ |
|
38 | + const OPTION_APPS = 'apps'; |
|
39 | 39 | |
40 | - /** |
|
41 | - * List of options |
|
42 | - * @var array |
|
43 | - * @since 7.0.0 |
|
44 | - */ |
|
45 | - protected $options; |
|
40 | + /** |
|
41 | + * List of options |
|
42 | + * @var array |
|
43 | + * @since 7.0.0 |
|
44 | + */ |
|
45 | + protected $options; |
|
46 | 46 | |
47 | - /** |
|
48 | - * Constructor |
|
49 | - * @param array $options as key => value |
|
50 | - * @since 7.0.0 - default value for $options was added in 8.0.0 |
|
51 | - */ |
|
52 | - public function __construct($options = []) { |
|
53 | - $this->options = $options; |
|
54 | - } |
|
47 | + /** |
|
48 | + * Constructor |
|
49 | + * @param array $options as key => value |
|
50 | + * @since 7.0.0 - default value for $options was added in 8.0.0 |
|
51 | + */ |
|
52 | + public function __construct($options = []) { |
|
53 | + $this->options = $options; |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * get a value from the options array or null |
|
58 | - * @param string $key |
|
59 | - * @return mixed |
|
60 | - * @since 8.0.0 |
|
61 | - */ |
|
62 | - public function getOption($key) { |
|
63 | - if (is_array($this->options) && isset($this->options[$key])) { |
|
64 | - return $this->options[$key]; |
|
65 | - } else { |
|
66 | - return null; |
|
67 | - } |
|
68 | - } |
|
56 | + /** |
|
57 | + * get a value from the options array or null |
|
58 | + * @param string $key |
|
59 | + * @return mixed |
|
60 | + * @since 8.0.0 |
|
61 | + */ |
|
62 | + public function getOption($key) { |
|
63 | + if (is_array($this->options) && isset($this->options[$key])) { |
|
64 | + return $this->options[$key]; |
|
65 | + } else { |
|
66 | + return null; |
|
67 | + } |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * checks if the given apps and the apps this provider has results for intersect |
|
72 | - * returns true if the given array is empty (all apps) |
|
73 | - * or if this provider does not have a list of apps it provides results for (legacy search providers) |
|
74 | - * or if the two above arrays have elements in common (intersect) |
|
75 | - * @param string[] $apps |
|
76 | - * @return bool |
|
77 | - * @since 8.0.0 |
|
78 | - */ |
|
79 | - public function providesResultsFor(array $apps = []) { |
|
80 | - $forApps = $this->getOption(self::OPTION_APPS); |
|
81 | - return empty($apps) || empty($forApps) || array_intersect($forApps, $apps); |
|
82 | - } |
|
70 | + /** |
|
71 | + * checks if the given apps and the apps this provider has results for intersect |
|
72 | + * returns true if the given array is empty (all apps) |
|
73 | + * or if this provider does not have a list of apps it provides results for (legacy search providers) |
|
74 | + * or if the two above arrays have elements in common (intersect) |
|
75 | + * @param string[] $apps |
|
76 | + * @return bool |
|
77 | + * @since 8.0.0 |
|
78 | + */ |
|
79 | + public function providesResultsFor(array $apps = []) { |
|
80 | + $forApps = $this->getOption(self::OPTION_APPS); |
|
81 | + return empty($apps) || empty($forApps) || array_intersect($forApps, $apps); |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * Search for $query |
|
86 | - * @param string $query |
|
87 | - * @return array An array of OCP\Search\Result's |
|
88 | - * @since 7.0.0 |
|
89 | - */ |
|
90 | - abstract public function search($query); |
|
84 | + /** |
|
85 | + * Search for $query |
|
86 | + * @param string $query |
|
87 | + * @return array An array of OCP\Search\Result's |
|
88 | + * @since 7.0.0 |
|
89 | + */ |
|
90 | + abstract public function search($query); |
|
91 | 91 | } |
@@ -30,200 +30,200 @@ |
||
30 | 30 | * @package OC\App |
31 | 31 | */ |
32 | 32 | class PlatformRepository { |
33 | - public function __construct() { |
|
34 | - $this->packages = $this->initialize(); |
|
35 | - } |
|
36 | - |
|
37 | - protected function initialize() { |
|
38 | - $loadedExtensions = get_loaded_extensions(); |
|
39 | - $packages = []; |
|
40 | - |
|
41 | - // Extensions scanning |
|
42 | - foreach ($loadedExtensions as $name) { |
|
43 | - if (in_array($name, ['standard', 'Core'])) { |
|
44 | - continue; |
|
45 | - } |
|
46 | - |
|
47 | - $ext = new \ReflectionExtension($name); |
|
48 | - try { |
|
49 | - $prettyVersion = $ext->getVersion(); |
|
50 | - $prettyVersion = $this->normalizeVersion($prettyVersion); |
|
51 | - } catch (\UnexpectedValueException $e) { |
|
52 | - $prettyVersion = '0'; |
|
53 | - $prettyVersion = $this->normalizeVersion($prettyVersion); |
|
54 | - } |
|
55 | - |
|
56 | - $packages[$this->buildPackageName($name)] = $prettyVersion; |
|
57 | - } |
|
58 | - |
|
59 | - foreach ($loadedExtensions as $name) { |
|
60 | - $prettyVersion = null; |
|
61 | - switch ($name) { |
|
62 | - case 'curl': |
|
63 | - $curlVersion = curl_version(); |
|
64 | - $prettyVersion = $curlVersion['version']; |
|
65 | - break; |
|
66 | - |
|
67 | - case 'iconv': |
|
68 | - $prettyVersion = ICONV_VERSION; |
|
69 | - break; |
|
70 | - |
|
71 | - case 'intl': |
|
72 | - $name = 'ICU'; |
|
73 | - if (defined('INTL_ICU_VERSION')) { |
|
74 | - $prettyVersion = INTL_ICU_VERSION; |
|
75 | - } else { |
|
76 | - $reflector = new \ReflectionExtension('intl'); |
|
77 | - |
|
78 | - ob_start(); |
|
79 | - $reflector->info(); |
|
80 | - $output = ob_get_clean(); |
|
81 | - |
|
82 | - preg_match('/^ICU version => (.*)$/m', $output, $matches); |
|
83 | - $prettyVersion = $matches[1]; |
|
84 | - } |
|
85 | - |
|
86 | - break; |
|
87 | - |
|
88 | - case 'libxml': |
|
89 | - $prettyVersion = LIBXML_DOTTED_VERSION; |
|
90 | - break; |
|
91 | - |
|
92 | - case 'openssl': |
|
93 | - $prettyVersion = preg_replace_callback('{^(?:OpenSSL\s*)?([0-9.]+)([a-z]?).*}', function ($match) { |
|
94 | - return $match[1] . (empty($match[2]) ? '' : '.' . (ord($match[2]) - 96)); |
|
95 | - }, OPENSSL_VERSION_TEXT); |
|
96 | - break; |
|
97 | - |
|
98 | - case 'pcre': |
|
99 | - $prettyVersion = preg_replace('{^(\S+).*}', '$1', PCRE_VERSION); |
|
100 | - break; |
|
101 | - |
|
102 | - case 'uuid': |
|
103 | - $prettyVersion = phpversion('uuid'); |
|
104 | - break; |
|
105 | - |
|
106 | - case 'xsl': |
|
107 | - $prettyVersion = LIBXSLT_DOTTED_VERSION; |
|
108 | - break; |
|
109 | - |
|
110 | - default: |
|
111 | - // None handled extensions have no special cases, skip |
|
112 | - continue 2; |
|
113 | - } |
|
114 | - |
|
115 | - try { |
|
116 | - $prettyVersion = $this->normalizeVersion($prettyVersion); |
|
117 | - } catch (\UnexpectedValueException $e) { |
|
118 | - continue; |
|
119 | - } |
|
120 | - |
|
121 | - $packages[$this->buildPackageName($name)] = $prettyVersion; |
|
122 | - } |
|
123 | - |
|
124 | - return $packages; |
|
125 | - } |
|
126 | - |
|
127 | - private function buildPackageName($name) { |
|
128 | - return str_replace(' ', '-', $name); |
|
129 | - } |
|
130 | - |
|
131 | - /** |
|
132 | - * @param $name |
|
133 | - * @return string |
|
134 | - */ |
|
135 | - public function findLibrary($name) { |
|
136 | - $extName = $this->buildPackageName($name); |
|
137 | - if (isset($this->packages[$extName])) { |
|
138 | - return $this->packages[$extName]; |
|
139 | - } |
|
140 | - return null; |
|
141 | - } |
|
142 | - |
|
143 | - private static $modifierRegex = '[._-]?(?:(stable|beta|b|RC|alpha|a|patch|pl|p)(?:[.-]?(\d+))?)?([.-]?dev)?'; |
|
144 | - |
|
145 | - /** |
|
146 | - * Normalizes a version string to be able to perform comparisons on it |
|
147 | - * |
|
148 | - * https://github.com/composer/composer/blob/master/src/Composer/Package/Version/VersionParser.php#L94 |
|
149 | - * |
|
150 | - * @param string $version |
|
151 | - * @param string $fullVersion optional complete version string to give more context |
|
152 | - * @throws \UnexpectedValueException |
|
153 | - * @return string |
|
154 | - */ |
|
155 | - public function normalizeVersion($version, $fullVersion = null) { |
|
156 | - $version = trim($version); |
|
157 | - if (null === $fullVersion) { |
|
158 | - $fullVersion = $version; |
|
159 | - } |
|
160 | - // ignore aliases and just assume the alias is required instead of the source |
|
161 | - if (preg_match('{^([^,\s]+) +as +([^,\s]+)$}', $version, $match)) { |
|
162 | - $version = $match[1]; |
|
163 | - } |
|
164 | - // match master-like branches |
|
165 | - if (preg_match('{^(?:dev-)?(?:master|trunk|default)$}i', $version)) { |
|
166 | - return '9999999-dev'; |
|
167 | - } |
|
168 | - if ('dev-' === strtolower(substr($version, 0, 4))) { |
|
169 | - return 'dev-' . substr($version, 4); |
|
170 | - } |
|
171 | - // match classical versioning |
|
172 | - if (preg_match('{^v?(\d{1,3})(\.\d+)?(\.\d+)?(\.\d+)?' . self::$modifierRegex . '$}i', $version, $matches)) { |
|
173 | - $version = $matches[1] |
|
174 | - . (!empty($matches[2]) ? $matches[2] : '.0') |
|
175 | - . (!empty($matches[3]) ? $matches[3] : '.0') |
|
176 | - . (!empty($matches[4]) ? $matches[4] : '.0'); |
|
177 | - $index = 5; |
|
178 | - } elseif (preg_match('{^v?(\d{4}(?:[.:-]?\d{2}){1,6}(?:[.:-]?\d{1,3})?)' . self::$modifierRegex . '$}i', $version, $matches)) { // match date-based versioning |
|
179 | - $version = preg_replace('{\D}', '-', $matches[1]); |
|
180 | - $index = 2; |
|
181 | - } elseif (preg_match('{^v?(\d{4,})(\.\d+)?(\.\d+)?(\.\d+)?' . self::$modifierRegex . '$}i', $version, $matches)) { |
|
182 | - $version = $matches[1] |
|
183 | - . (!empty($matches[2]) ? $matches[2] : '.0') |
|
184 | - . (!empty($matches[3]) ? $matches[3] : '.0') |
|
185 | - . (!empty($matches[4]) ? $matches[4] : '.0'); |
|
186 | - $index = 5; |
|
187 | - } |
|
188 | - // add version modifiers if a version was matched |
|
189 | - if (isset($index)) { |
|
190 | - if (!empty($matches[$index])) { |
|
191 | - if ('stable' === $matches[$index]) { |
|
192 | - return $version; |
|
193 | - } |
|
194 | - $version .= '-' . $this->expandStability($matches[$index]) . (!empty($matches[$index + 1]) ? $matches[$index + 1] : ''); |
|
195 | - } |
|
196 | - if (!empty($matches[$index + 2])) { |
|
197 | - $version .= '-dev'; |
|
198 | - } |
|
199 | - return $version; |
|
200 | - } |
|
201 | - $extraMessage = ''; |
|
202 | - if (preg_match('{ +as +' . preg_quote($version) . '$}', $fullVersion)) { |
|
203 | - $extraMessage = ' in "' . $fullVersion . '", the alias must be an exact version'; |
|
204 | - } elseif (preg_match('{^' . preg_quote($version) . ' +as +}', $fullVersion)) { |
|
205 | - $extraMessage = ' in "' . $fullVersion . '", the alias source must be an exact version, if it is a branch name you should prefix it with dev-'; |
|
206 | - } |
|
207 | - throw new \UnexpectedValueException('Invalid version string "' . $version . '"' . $extraMessage); |
|
208 | - } |
|
209 | - |
|
210 | - /** |
|
211 | - * @param string $stability |
|
212 | - */ |
|
213 | - private function expandStability($stability) { |
|
214 | - $stability = strtolower($stability); |
|
215 | - switch ($stability) { |
|
216 | - case 'a': |
|
217 | - return 'alpha'; |
|
218 | - case 'b': |
|
219 | - return 'beta'; |
|
220 | - case 'p': |
|
221 | - case 'pl': |
|
222 | - return 'patch'; |
|
223 | - case 'rc': |
|
224 | - return 'RC'; |
|
225 | - default: |
|
226 | - return $stability; |
|
227 | - } |
|
228 | - } |
|
33 | + public function __construct() { |
|
34 | + $this->packages = $this->initialize(); |
|
35 | + } |
|
36 | + |
|
37 | + protected function initialize() { |
|
38 | + $loadedExtensions = get_loaded_extensions(); |
|
39 | + $packages = []; |
|
40 | + |
|
41 | + // Extensions scanning |
|
42 | + foreach ($loadedExtensions as $name) { |
|
43 | + if (in_array($name, ['standard', 'Core'])) { |
|
44 | + continue; |
|
45 | + } |
|
46 | + |
|
47 | + $ext = new \ReflectionExtension($name); |
|
48 | + try { |
|
49 | + $prettyVersion = $ext->getVersion(); |
|
50 | + $prettyVersion = $this->normalizeVersion($prettyVersion); |
|
51 | + } catch (\UnexpectedValueException $e) { |
|
52 | + $prettyVersion = '0'; |
|
53 | + $prettyVersion = $this->normalizeVersion($prettyVersion); |
|
54 | + } |
|
55 | + |
|
56 | + $packages[$this->buildPackageName($name)] = $prettyVersion; |
|
57 | + } |
|
58 | + |
|
59 | + foreach ($loadedExtensions as $name) { |
|
60 | + $prettyVersion = null; |
|
61 | + switch ($name) { |
|
62 | + case 'curl': |
|
63 | + $curlVersion = curl_version(); |
|
64 | + $prettyVersion = $curlVersion['version']; |
|
65 | + break; |
|
66 | + |
|
67 | + case 'iconv': |
|
68 | + $prettyVersion = ICONV_VERSION; |
|
69 | + break; |
|
70 | + |
|
71 | + case 'intl': |
|
72 | + $name = 'ICU'; |
|
73 | + if (defined('INTL_ICU_VERSION')) { |
|
74 | + $prettyVersion = INTL_ICU_VERSION; |
|
75 | + } else { |
|
76 | + $reflector = new \ReflectionExtension('intl'); |
|
77 | + |
|
78 | + ob_start(); |
|
79 | + $reflector->info(); |
|
80 | + $output = ob_get_clean(); |
|
81 | + |
|
82 | + preg_match('/^ICU version => (.*)$/m', $output, $matches); |
|
83 | + $prettyVersion = $matches[1]; |
|
84 | + } |
|
85 | + |
|
86 | + break; |
|
87 | + |
|
88 | + case 'libxml': |
|
89 | + $prettyVersion = LIBXML_DOTTED_VERSION; |
|
90 | + break; |
|
91 | + |
|
92 | + case 'openssl': |
|
93 | + $prettyVersion = preg_replace_callback('{^(?:OpenSSL\s*)?([0-9.]+)([a-z]?).*}', function ($match) { |
|
94 | + return $match[1] . (empty($match[2]) ? '' : '.' . (ord($match[2]) - 96)); |
|
95 | + }, OPENSSL_VERSION_TEXT); |
|
96 | + break; |
|
97 | + |
|
98 | + case 'pcre': |
|
99 | + $prettyVersion = preg_replace('{^(\S+).*}', '$1', PCRE_VERSION); |
|
100 | + break; |
|
101 | + |
|
102 | + case 'uuid': |
|
103 | + $prettyVersion = phpversion('uuid'); |
|
104 | + break; |
|
105 | + |
|
106 | + case 'xsl': |
|
107 | + $prettyVersion = LIBXSLT_DOTTED_VERSION; |
|
108 | + break; |
|
109 | + |
|
110 | + default: |
|
111 | + // None handled extensions have no special cases, skip |
|
112 | + continue 2; |
|
113 | + } |
|
114 | + |
|
115 | + try { |
|
116 | + $prettyVersion = $this->normalizeVersion($prettyVersion); |
|
117 | + } catch (\UnexpectedValueException $e) { |
|
118 | + continue; |
|
119 | + } |
|
120 | + |
|
121 | + $packages[$this->buildPackageName($name)] = $prettyVersion; |
|
122 | + } |
|
123 | + |
|
124 | + return $packages; |
|
125 | + } |
|
126 | + |
|
127 | + private function buildPackageName($name) { |
|
128 | + return str_replace(' ', '-', $name); |
|
129 | + } |
|
130 | + |
|
131 | + /** |
|
132 | + * @param $name |
|
133 | + * @return string |
|
134 | + */ |
|
135 | + public function findLibrary($name) { |
|
136 | + $extName = $this->buildPackageName($name); |
|
137 | + if (isset($this->packages[$extName])) { |
|
138 | + return $this->packages[$extName]; |
|
139 | + } |
|
140 | + return null; |
|
141 | + } |
|
142 | + |
|
143 | + private static $modifierRegex = '[._-]?(?:(stable|beta|b|RC|alpha|a|patch|pl|p)(?:[.-]?(\d+))?)?([.-]?dev)?'; |
|
144 | + |
|
145 | + /** |
|
146 | + * Normalizes a version string to be able to perform comparisons on it |
|
147 | + * |
|
148 | + * https://github.com/composer/composer/blob/master/src/Composer/Package/Version/VersionParser.php#L94 |
|
149 | + * |
|
150 | + * @param string $version |
|
151 | + * @param string $fullVersion optional complete version string to give more context |
|
152 | + * @throws \UnexpectedValueException |
|
153 | + * @return string |
|
154 | + */ |
|
155 | + public function normalizeVersion($version, $fullVersion = null) { |
|
156 | + $version = trim($version); |
|
157 | + if (null === $fullVersion) { |
|
158 | + $fullVersion = $version; |
|
159 | + } |
|
160 | + // ignore aliases and just assume the alias is required instead of the source |
|
161 | + if (preg_match('{^([^,\s]+) +as +([^,\s]+)$}', $version, $match)) { |
|
162 | + $version = $match[1]; |
|
163 | + } |
|
164 | + // match master-like branches |
|
165 | + if (preg_match('{^(?:dev-)?(?:master|trunk|default)$}i', $version)) { |
|
166 | + return '9999999-dev'; |
|
167 | + } |
|
168 | + if ('dev-' === strtolower(substr($version, 0, 4))) { |
|
169 | + return 'dev-' . substr($version, 4); |
|
170 | + } |
|
171 | + // match classical versioning |
|
172 | + if (preg_match('{^v?(\d{1,3})(\.\d+)?(\.\d+)?(\.\d+)?' . self::$modifierRegex . '$}i', $version, $matches)) { |
|
173 | + $version = $matches[1] |
|
174 | + . (!empty($matches[2]) ? $matches[2] : '.0') |
|
175 | + . (!empty($matches[3]) ? $matches[3] : '.0') |
|
176 | + . (!empty($matches[4]) ? $matches[4] : '.0'); |
|
177 | + $index = 5; |
|
178 | + } elseif (preg_match('{^v?(\d{4}(?:[.:-]?\d{2}){1,6}(?:[.:-]?\d{1,3})?)' . self::$modifierRegex . '$}i', $version, $matches)) { // match date-based versioning |
|
179 | + $version = preg_replace('{\D}', '-', $matches[1]); |
|
180 | + $index = 2; |
|
181 | + } elseif (preg_match('{^v?(\d{4,})(\.\d+)?(\.\d+)?(\.\d+)?' . self::$modifierRegex . '$}i', $version, $matches)) { |
|
182 | + $version = $matches[1] |
|
183 | + . (!empty($matches[2]) ? $matches[2] : '.0') |
|
184 | + . (!empty($matches[3]) ? $matches[3] : '.0') |
|
185 | + . (!empty($matches[4]) ? $matches[4] : '.0'); |
|
186 | + $index = 5; |
|
187 | + } |
|
188 | + // add version modifiers if a version was matched |
|
189 | + if (isset($index)) { |
|
190 | + if (!empty($matches[$index])) { |
|
191 | + if ('stable' === $matches[$index]) { |
|
192 | + return $version; |
|
193 | + } |
|
194 | + $version .= '-' . $this->expandStability($matches[$index]) . (!empty($matches[$index + 1]) ? $matches[$index + 1] : ''); |
|
195 | + } |
|
196 | + if (!empty($matches[$index + 2])) { |
|
197 | + $version .= '-dev'; |
|
198 | + } |
|
199 | + return $version; |
|
200 | + } |
|
201 | + $extraMessage = ''; |
|
202 | + if (preg_match('{ +as +' . preg_quote($version) . '$}', $fullVersion)) { |
|
203 | + $extraMessage = ' in "' . $fullVersion . '", the alias must be an exact version'; |
|
204 | + } elseif (preg_match('{^' . preg_quote($version) . ' +as +}', $fullVersion)) { |
|
205 | + $extraMessage = ' in "' . $fullVersion . '", the alias source must be an exact version, if it is a branch name you should prefix it with dev-'; |
|
206 | + } |
|
207 | + throw new \UnexpectedValueException('Invalid version string "' . $version . '"' . $extraMessage); |
|
208 | + } |
|
209 | + |
|
210 | + /** |
|
211 | + * @param string $stability |
|
212 | + */ |
|
213 | + private function expandStability($stability) { |
|
214 | + $stability = strtolower($stability); |
|
215 | + switch ($stability) { |
|
216 | + case 'a': |
|
217 | + return 'alpha'; |
|
218 | + case 'b': |
|
219 | + return 'beta'; |
|
220 | + case 'p': |
|
221 | + case 'pl': |
|
222 | + return 'patch'; |
|
223 | + case 'rc': |
|
224 | + return 'RC'; |
|
225 | + default: |
|
226 | + return $stability; |
|
227 | + } |
|
228 | + } |
|
229 | 229 | } |
@@ -30,58 +30,58 @@ |
||
30 | 30 | use OCP\Files\Cache\ICacheEntry; |
31 | 31 | |
32 | 32 | class HomeCache extends Cache { |
33 | - /** |
|
34 | - * get the size of a folder and set it in the cache |
|
35 | - * |
|
36 | - * @param string $path |
|
37 | - * @param array $entry (optional) meta data of the folder |
|
38 | - * @return int |
|
39 | - */ |
|
40 | - public function calculateFolderSize($path, $entry = null) { |
|
41 | - if ($path !== '/' and $path !== '' and $path !== 'files' and $path !== 'files_trashbin' and $path !== 'files_versions') { |
|
42 | - return parent::calculateFolderSize($path, $entry); |
|
43 | - } elseif ($path === '' or $path === '/') { |
|
44 | - // since the size of / isn't used (the size of /files is used instead) there is no use in calculating it |
|
45 | - return 0; |
|
46 | - } |
|
33 | + /** |
|
34 | + * get the size of a folder and set it in the cache |
|
35 | + * |
|
36 | + * @param string $path |
|
37 | + * @param array $entry (optional) meta data of the folder |
|
38 | + * @return int |
|
39 | + */ |
|
40 | + public function calculateFolderSize($path, $entry = null) { |
|
41 | + if ($path !== '/' and $path !== '' and $path !== 'files' and $path !== 'files_trashbin' and $path !== 'files_versions') { |
|
42 | + return parent::calculateFolderSize($path, $entry); |
|
43 | + } elseif ($path === '' or $path === '/') { |
|
44 | + // since the size of / isn't used (the size of /files is used instead) there is no use in calculating it |
|
45 | + return 0; |
|
46 | + } |
|
47 | 47 | |
48 | - $totalSize = 0; |
|
49 | - if (is_null($entry)) { |
|
50 | - $entry = $this->get($path); |
|
51 | - } |
|
52 | - if ($entry && $entry['mimetype'] === 'httpd/unix-directory') { |
|
53 | - $id = $entry['fileid']; |
|
54 | - $sql = 'SELECT SUM(`size`) AS f1 ' . |
|
55 | - 'FROM `*PREFIX*filecache` ' . |
|
56 | - 'WHERE `parent` = ? AND `storage` = ? AND `size` >= 0'; |
|
57 | - $result = \OC_DB::executeAudited($sql, [$id, $this->getNumericStorageId()]); |
|
58 | - if ($row = $result->fetchRow()) { |
|
59 | - $result->closeCursor(); |
|
60 | - list($sum) = array_values($row); |
|
61 | - $totalSize = 0 + $sum; |
|
62 | - $entry['size'] += 0; |
|
63 | - if ($entry['size'] !== $totalSize) { |
|
64 | - $this->update($id, ['size' => $totalSize]); |
|
65 | - } |
|
66 | - } |
|
67 | - } |
|
68 | - return $totalSize; |
|
69 | - } |
|
48 | + $totalSize = 0; |
|
49 | + if (is_null($entry)) { |
|
50 | + $entry = $this->get($path); |
|
51 | + } |
|
52 | + if ($entry && $entry['mimetype'] === 'httpd/unix-directory') { |
|
53 | + $id = $entry['fileid']; |
|
54 | + $sql = 'SELECT SUM(`size`) AS f1 ' . |
|
55 | + 'FROM `*PREFIX*filecache` ' . |
|
56 | + 'WHERE `parent` = ? AND `storage` = ? AND `size` >= 0'; |
|
57 | + $result = \OC_DB::executeAudited($sql, [$id, $this->getNumericStorageId()]); |
|
58 | + if ($row = $result->fetchRow()) { |
|
59 | + $result->closeCursor(); |
|
60 | + list($sum) = array_values($row); |
|
61 | + $totalSize = 0 + $sum; |
|
62 | + $entry['size'] += 0; |
|
63 | + if ($entry['size'] !== $totalSize) { |
|
64 | + $this->update($id, ['size' => $totalSize]); |
|
65 | + } |
|
66 | + } |
|
67 | + } |
|
68 | + return $totalSize; |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * @param string $path |
|
73 | - * @return ICacheEntry |
|
74 | - */ |
|
75 | - public function get($path) { |
|
76 | - $data = parent::get($path); |
|
77 | - if ($path === '' or $path === '/') { |
|
78 | - // only the size of the "files" dir counts |
|
79 | - $filesData = parent::get('files'); |
|
71 | + /** |
|
72 | + * @param string $path |
|
73 | + * @return ICacheEntry |
|
74 | + */ |
|
75 | + public function get($path) { |
|
76 | + $data = parent::get($path); |
|
77 | + if ($path === '' or $path === '/') { |
|
78 | + // only the size of the "files" dir counts |
|
79 | + $filesData = parent::get('files'); |
|
80 | 80 | |
81 | - if (isset($filesData['size'])) { |
|
82 | - $data['size'] = $filesData['size']; |
|
83 | - } |
|
84 | - } |
|
85 | - return $data; |
|
86 | - } |
|
81 | + if (isset($filesData['size'])) { |
|
82 | + $data['size'] = $filesData['size']; |
|
83 | + } |
|
84 | + } |
|
85 | + return $data; |
|
86 | + } |
|
87 | 87 | } |
@@ -51,8 +51,8 @@ |
||
51 | 51 | } |
52 | 52 | if ($entry && $entry['mimetype'] === 'httpd/unix-directory') { |
53 | 53 | $id = $entry['fileid']; |
54 | - $sql = 'SELECT SUM(`size`) AS f1 ' . |
|
55 | - 'FROM `*PREFIX*filecache` ' . |
|
54 | + $sql = 'SELECT SUM(`size`) AS f1 '. |
|
55 | + 'FROM `*PREFIX*filecache` '. |
|
56 | 56 | 'WHERE `parent` = ? AND `storage` = ? AND `size` >= 0'; |
57 | 57 | $result = \OC_DB::executeAudited($sql, [$id, $this->getNumericStorageId()]); |
58 | 58 | if ($row = $result->fetchRow()) { |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | $this->loadTable($schema, $child); |
85 | 85 | break; |
86 | 86 | default: |
87 | - throw new \DomainException('Unknown element: ' . $child->getName()); |
|
87 | + throw new \DomainException('Unknown element: '.$child->getName()); |
|
88 | 88 | |
89 | 89 | } |
90 | 90 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | */ |
105 | 105 | switch ($child->getName()) { |
106 | 106 | case 'name': |
107 | - $name = (string)$child; |
|
107 | + $name = (string) $child; |
|
108 | 108 | $name = str_replace('*dbprefix*', $this->DBTABLEPREFIX, $name); |
109 | 109 | $name = $this->platform->quoteIdentifier($name); |
110 | 110 | $table = $schema->createTable($name); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $this->loadDeclaration($table, $child); |
121 | 121 | break; |
122 | 122 | default: |
123 | - throw new \DomainException('Unknown element: ' . $child->getName()); |
|
123 | + throw new \DomainException('Unknown element: '.$child->getName()); |
|
124 | 124 | |
125 | 125 | } |
126 | 126 | } |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | $this->loadIndex($table, $child); |
145 | 145 | break; |
146 | 146 | default: |
147 | - throw new \DomainException('Unknown element: ' . $child->getName()); |
|
147 | + throw new \DomainException('Unknown element: '.$child->getName()); |
|
148 | 148 | |
149 | 149 | } |
150 | 150 | } |
@@ -156,18 +156,18 @@ discard block |
||
156 | 156 | * @throws \DomainException |
157 | 157 | */ |
158 | 158 | private function loadField($table, $xml) { |
159 | - $options = [ 'notnull' => false ]; |
|
159 | + $options = ['notnull' => false]; |
|
160 | 160 | foreach ($xml->children() as $child) { |
161 | 161 | /** |
162 | 162 | * @var \SimpleXMLElement $child |
163 | 163 | */ |
164 | 164 | switch ($child->getName()) { |
165 | 165 | case 'name': |
166 | - $name = (string)$child; |
|
166 | + $name = (string) $child; |
|
167 | 167 | $name = $this->platform->quoteIdentifier($name); |
168 | 168 | break; |
169 | 169 | case 'type': |
170 | - $type = (string)$child; |
|
170 | + $type = (string) $child; |
|
171 | 171 | switch ($type) { |
172 | 172 | case 'text': |
173 | 173 | $type = 'string'; |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | } |
185 | 185 | break; |
186 | 186 | case 'length': |
187 | - $length = (string)$child; |
|
187 | + $length = (string) $child; |
|
188 | 188 | $options['length'] = $length; |
189 | 189 | break; |
190 | 190 | case 'unsigned': |
@@ -200,11 +200,11 @@ discard block |
||
200 | 200 | $options['autoincrement'] = $autoincrement; |
201 | 201 | break; |
202 | 202 | case 'default': |
203 | - $default = (string)$child; |
|
203 | + $default = (string) $child; |
|
204 | 204 | $options['default'] = $default; |
205 | 205 | break; |
206 | 206 | case 'comments': |
207 | - $comment = (string)$child; |
|
207 | + $comment = (string) $child; |
|
208 | 208 | $options['comment'] = $comment; |
209 | 209 | break; |
210 | 210 | case 'primary': |
@@ -212,15 +212,15 @@ discard block |
||
212 | 212 | $options['primary'] = $primary; |
213 | 213 | break; |
214 | 214 | case 'precision': |
215 | - $precision = (string)$child; |
|
215 | + $precision = (string) $child; |
|
216 | 216 | $options['precision'] = $precision; |
217 | 217 | break; |
218 | 218 | case 'scale': |
219 | - $scale = (string)$child; |
|
219 | + $scale = (string) $child; |
|
220 | 220 | $options['scale'] = $scale; |
221 | 221 | break; |
222 | 222 | default: |
223 | - throw new \DomainException('Unknown element: ' . $child->getName()); |
|
223 | + throw new \DomainException('Unknown element: '.$child->getName()); |
|
224 | 224 | |
225 | 225 | } |
226 | 226 | } |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | } |
243 | 243 | } |
244 | 244 | if ($type === 'integer' && isset($options['default'])) { |
245 | - $options['default'] = (int)$options['default']; |
|
245 | + $options['default'] = (int) $options['default']; |
|
246 | 246 | } |
247 | 247 | if ($type === 'integer' && isset($options['length'])) { |
248 | 248 | $length = $options['length']; |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | */ |
283 | 283 | switch ($child->getName()) { |
284 | 284 | case 'name': |
285 | - $name = (string)$child; |
|
285 | + $name = (string) $child; |
|
286 | 286 | break; |
287 | 287 | case 'primary': |
288 | 288 | $primary = $this->asBool($child); |
@@ -297,20 +297,20 @@ discard block |
||
297 | 297 | */ |
298 | 298 | switch ($field->getName()) { |
299 | 299 | case 'name': |
300 | - $field_name = (string)$field; |
|
300 | + $field_name = (string) $field; |
|
301 | 301 | $field_name = $this->platform->quoteIdentifier($field_name); |
302 | 302 | $fields[] = $field_name; |
303 | 303 | break; |
304 | 304 | case 'sorting': |
305 | 305 | break; |
306 | 306 | default: |
307 | - throw new \DomainException('Unknown element: ' . $field->getName()); |
|
307 | + throw new \DomainException('Unknown element: '.$field->getName()); |
|
308 | 308 | |
309 | 309 | } |
310 | 310 | } |
311 | 311 | break; |
312 | 312 | default: |
313 | - throw new \DomainException('Unknown element: ' . $child->getName()); |
|
313 | + throw new \DomainException('Unknown element: '.$child->getName()); |
|
314 | 314 | |
315 | 315 | } |
316 | 316 | } |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | } |
329 | 329 | } |
330 | 330 | } else { |
331 | - throw new \DomainException('Empty index definition: ' . $name . ' options:' . print_r($fields, true)); |
|
331 | + throw new \DomainException('Empty index definition: '.$name.' options:'.print_r($fields, true)); |
|
332 | 332 | } |
333 | 333 | } |
334 | 334 | |
@@ -337,12 +337,12 @@ discard block |
||
337 | 337 | * @return bool |
338 | 338 | */ |
339 | 339 | private function asBool($xml) { |
340 | - $result = (string)$xml; |
|
340 | + $result = (string) $xml; |
|
341 | 341 | if ($result == 'true') { |
342 | 342 | $result = true; |
343 | 343 | } elseif ($result == 'false') { |
344 | 344 | $result = false; |
345 | 345 | } |
346 | - return (bool)$result; |
|
346 | + return (bool) $result; |
|
347 | 347 | } |
348 | 348 | } |
@@ -36,313 +36,313 @@ |
||
36 | 36 | |
37 | 37 | class MDB2SchemaReader { |
38 | 38 | |
39 | - /** |
|
40 | - * @var string $DBTABLEPREFIX |
|
41 | - */ |
|
42 | - protected $DBTABLEPREFIX; |
|
39 | + /** |
|
40 | + * @var string $DBTABLEPREFIX |
|
41 | + */ |
|
42 | + protected $DBTABLEPREFIX; |
|
43 | 43 | |
44 | - /** |
|
45 | - * @var \Doctrine\DBAL\Platforms\AbstractPlatform $platform |
|
46 | - */ |
|
47 | - protected $platform; |
|
44 | + /** |
|
45 | + * @var \Doctrine\DBAL\Platforms\AbstractPlatform $platform |
|
46 | + */ |
|
47 | + protected $platform; |
|
48 | 48 | |
49 | - /** @var IConfig */ |
|
50 | - protected $config; |
|
49 | + /** @var IConfig */ |
|
50 | + protected $config; |
|
51 | 51 | |
52 | - /** |
|
53 | - * @param \OCP\IConfig $config |
|
54 | - * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform |
|
55 | - */ |
|
56 | - public function __construct(IConfig $config, AbstractPlatform $platform) { |
|
57 | - $this->platform = $platform; |
|
58 | - $this->config = $config; |
|
59 | - $this->DBTABLEPREFIX = $config->getSystemValue('dbtableprefix', 'oc_'); |
|
60 | - } |
|
52 | + /** |
|
53 | + * @param \OCP\IConfig $config |
|
54 | + * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform |
|
55 | + */ |
|
56 | + public function __construct(IConfig $config, AbstractPlatform $platform) { |
|
57 | + $this->platform = $platform; |
|
58 | + $this->config = $config; |
|
59 | + $this->DBTABLEPREFIX = $config->getSystemValue('dbtableprefix', 'oc_'); |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * @param string $file |
|
64 | - * @param Schema $schema |
|
65 | - * @return Schema |
|
66 | - * @throws \DomainException |
|
67 | - */ |
|
68 | - public function loadSchemaFromFile($file, Schema $schema) { |
|
69 | - $loadEntities = libxml_disable_entity_loader(false); |
|
70 | - $xml = simplexml_load_file($file); |
|
71 | - libxml_disable_entity_loader($loadEntities); |
|
72 | - foreach ($xml->children() as $child) { |
|
73 | - /** |
|
74 | - * @var \SimpleXMLElement $child |
|
75 | - */ |
|
76 | - switch ($child->getName()) { |
|
77 | - case 'name': |
|
78 | - case 'create': |
|
79 | - case 'overwrite': |
|
80 | - case 'charset': |
|
81 | - break; |
|
82 | - case 'table': |
|
83 | - $this->loadTable($schema, $child); |
|
84 | - break; |
|
85 | - default: |
|
86 | - throw new \DomainException('Unknown element: ' . $child->getName()); |
|
62 | + /** |
|
63 | + * @param string $file |
|
64 | + * @param Schema $schema |
|
65 | + * @return Schema |
|
66 | + * @throws \DomainException |
|
67 | + */ |
|
68 | + public function loadSchemaFromFile($file, Schema $schema) { |
|
69 | + $loadEntities = libxml_disable_entity_loader(false); |
|
70 | + $xml = simplexml_load_file($file); |
|
71 | + libxml_disable_entity_loader($loadEntities); |
|
72 | + foreach ($xml->children() as $child) { |
|
73 | + /** |
|
74 | + * @var \SimpleXMLElement $child |
|
75 | + */ |
|
76 | + switch ($child->getName()) { |
|
77 | + case 'name': |
|
78 | + case 'create': |
|
79 | + case 'overwrite': |
|
80 | + case 'charset': |
|
81 | + break; |
|
82 | + case 'table': |
|
83 | + $this->loadTable($schema, $child); |
|
84 | + break; |
|
85 | + default: |
|
86 | + throw new \DomainException('Unknown element: ' . $child->getName()); |
|
87 | 87 | |
88 | - } |
|
89 | - } |
|
90 | - return $schema; |
|
91 | - } |
|
88 | + } |
|
89 | + } |
|
90 | + return $schema; |
|
91 | + } |
|
92 | 92 | |
93 | - /** |
|
94 | - * @param \Doctrine\DBAL\Schema\Schema $schema |
|
95 | - * @param \SimpleXMLElement $xml |
|
96 | - * @throws \DomainException |
|
97 | - */ |
|
98 | - private function loadTable($schema, $xml) { |
|
99 | - $table = null; |
|
100 | - foreach ($xml->children() as $child) { |
|
101 | - /** |
|
102 | - * @var \SimpleXMLElement $child |
|
103 | - */ |
|
104 | - switch ($child->getName()) { |
|
105 | - case 'name': |
|
106 | - $name = (string)$child; |
|
107 | - $name = str_replace('*dbprefix*', $this->DBTABLEPREFIX, $name); |
|
108 | - $name = $this->platform->quoteIdentifier($name); |
|
109 | - $table = $schema->createTable($name); |
|
110 | - break; |
|
111 | - case 'create': |
|
112 | - case 'overwrite': |
|
113 | - case 'charset': |
|
114 | - break; |
|
115 | - case 'declaration': |
|
116 | - if (is_null($table)) { |
|
117 | - throw new \DomainException('Table declaration before table name'); |
|
118 | - } |
|
119 | - $this->loadDeclaration($table, $child); |
|
120 | - break; |
|
121 | - default: |
|
122 | - throw new \DomainException('Unknown element: ' . $child->getName()); |
|
93 | + /** |
|
94 | + * @param \Doctrine\DBAL\Schema\Schema $schema |
|
95 | + * @param \SimpleXMLElement $xml |
|
96 | + * @throws \DomainException |
|
97 | + */ |
|
98 | + private function loadTable($schema, $xml) { |
|
99 | + $table = null; |
|
100 | + foreach ($xml->children() as $child) { |
|
101 | + /** |
|
102 | + * @var \SimpleXMLElement $child |
|
103 | + */ |
|
104 | + switch ($child->getName()) { |
|
105 | + case 'name': |
|
106 | + $name = (string)$child; |
|
107 | + $name = str_replace('*dbprefix*', $this->DBTABLEPREFIX, $name); |
|
108 | + $name = $this->platform->quoteIdentifier($name); |
|
109 | + $table = $schema->createTable($name); |
|
110 | + break; |
|
111 | + case 'create': |
|
112 | + case 'overwrite': |
|
113 | + case 'charset': |
|
114 | + break; |
|
115 | + case 'declaration': |
|
116 | + if (is_null($table)) { |
|
117 | + throw new \DomainException('Table declaration before table name'); |
|
118 | + } |
|
119 | + $this->loadDeclaration($table, $child); |
|
120 | + break; |
|
121 | + default: |
|
122 | + throw new \DomainException('Unknown element: ' . $child->getName()); |
|
123 | 123 | |
124 | - } |
|
125 | - } |
|
126 | - } |
|
124 | + } |
|
125 | + } |
|
126 | + } |
|
127 | 127 | |
128 | - /** |
|
129 | - * @param \Doctrine\DBAL\Schema\Table $table |
|
130 | - * @param \SimpleXMLElement $xml |
|
131 | - * @throws \DomainException |
|
132 | - */ |
|
133 | - private function loadDeclaration($table, $xml) { |
|
134 | - foreach ($xml->children() as $child) { |
|
135 | - /** |
|
136 | - * @var \SimpleXMLElement $child |
|
137 | - */ |
|
138 | - switch ($child->getName()) { |
|
139 | - case 'field': |
|
140 | - $this->loadField($table, $child); |
|
141 | - break; |
|
142 | - case 'index': |
|
143 | - $this->loadIndex($table, $child); |
|
144 | - break; |
|
145 | - default: |
|
146 | - throw new \DomainException('Unknown element: ' . $child->getName()); |
|
128 | + /** |
|
129 | + * @param \Doctrine\DBAL\Schema\Table $table |
|
130 | + * @param \SimpleXMLElement $xml |
|
131 | + * @throws \DomainException |
|
132 | + */ |
|
133 | + private function loadDeclaration($table, $xml) { |
|
134 | + foreach ($xml->children() as $child) { |
|
135 | + /** |
|
136 | + * @var \SimpleXMLElement $child |
|
137 | + */ |
|
138 | + switch ($child->getName()) { |
|
139 | + case 'field': |
|
140 | + $this->loadField($table, $child); |
|
141 | + break; |
|
142 | + case 'index': |
|
143 | + $this->loadIndex($table, $child); |
|
144 | + break; |
|
145 | + default: |
|
146 | + throw new \DomainException('Unknown element: ' . $child->getName()); |
|
147 | 147 | |
148 | - } |
|
149 | - } |
|
150 | - } |
|
148 | + } |
|
149 | + } |
|
150 | + } |
|
151 | 151 | |
152 | - /** |
|
153 | - * @param \Doctrine\DBAL\Schema\Table $table |
|
154 | - * @param \SimpleXMLElement $xml |
|
155 | - * @throws \DomainException |
|
156 | - */ |
|
157 | - private function loadField($table, $xml) { |
|
158 | - $options = [ 'notnull' => false ]; |
|
159 | - foreach ($xml->children() as $child) { |
|
160 | - /** |
|
161 | - * @var \SimpleXMLElement $child |
|
162 | - */ |
|
163 | - switch ($child->getName()) { |
|
164 | - case 'name': |
|
165 | - $name = (string)$child; |
|
166 | - $name = $this->platform->quoteIdentifier($name); |
|
167 | - break; |
|
168 | - case 'type': |
|
169 | - $type = (string)$child; |
|
170 | - switch ($type) { |
|
171 | - case 'text': |
|
172 | - $type = 'string'; |
|
173 | - break; |
|
174 | - case 'clob': |
|
175 | - $type = 'text'; |
|
176 | - break; |
|
177 | - case 'timestamp': |
|
178 | - $type = 'datetime'; |
|
179 | - break; |
|
180 | - case 'numeric': |
|
181 | - $type = 'decimal'; |
|
182 | - break; |
|
183 | - } |
|
184 | - break; |
|
185 | - case 'length': |
|
186 | - $length = (string)$child; |
|
187 | - $options['length'] = $length; |
|
188 | - break; |
|
189 | - case 'unsigned': |
|
190 | - $unsigned = $this->asBool($child); |
|
191 | - $options['unsigned'] = $unsigned; |
|
192 | - break; |
|
193 | - case 'notnull': |
|
194 | - $notnull = $this->asBool($child); |
|
195 | - $options['notnull'] = $notnull; |
|
196 | - break; |
|
197 | - case 'autoincrement': |
|
198 | - $autoincrement = $this->asBool($child); |
|
199 | - $options['autoincrement'] = $autoincrement; |
|
200 | - break; |
|
201 | - case 'default': |
|
202 | - $default = (string)$child; |
|
203 | - $options['default'] = $default; |
|
204 | - break; |
|
205 | - case 'comments': |
|
206 | - $comment = (string)$child; |
|
207 | - $options['comment'] = $comment; |
|
208 | - break; |
|
209 | - case 'primary': |
|
210 | - $primary = $this->asBool($child); |
|
211 | - $options['primary'] = $primary; |
|
212 | - break; |
|
213 | - case 'precision': |
|
214 | - $precision = (string)$child; |
|
215 | - $options['precision'] = $precision; |
|
216 | - break; |
|
217 | - case 'scale': |
|
218 | - $scale = (string)$child; |
|
219 | - $options['scale'] = $scale; |
|
220 | - break; |
|
221 | - default: |
|
222 | - throw new \DomainException('Unknown element: ' . $child->getName()); |
|
152 | + /** |
|
153 | + * @param \Doctrine\DBAL\Schema\Table $table |
|
154 | + * @param \SimpleXMLElement $xml |
|
155 | + * @throws \DomainException |
|
156 | + */ |
|
157 | + private function loadField($table, $xml) { |
|
158 | + $options = [ 'notnull' => false ]; |
|
159 | + foreach ($xml->children() as $child) { |
|
160 | + /** |
|
161 | + * @var \SimpleXMLElement $child |
|
162 | + */ |
|
163 | + switch ($child->getName()) { |
|
164 | + case 'name': |
|
165 | + $name = (string)$child; |
|
166 | + $name = $this->platform->quoteIdentifier($name); |
|
167 | + break; |
|
168 | + case 'type': |
|
169 | + $type = (string)$child; |
|
170 | + switch ($type) { |
|
171 | + case 'text': |
|
172 | + $type = 'string'; |
|
173 | + break; |
|
174 | + case 'clob': |
|
175 | + $type = 'text'; |
|
176 | + break; |
|
177 | + case 'timestamp': |
|
178 | + $type = 'datetime'; |
|
179 | + break; |
|
180 | + case 'numeric': |
|
181 | + $type = 'decimal'; |
|
182 | + break; |
|
183 | + } |
|
184 | + break; |
|
185 | + case 'length': |
|
186 | + $length = (string)$child; |
|
187 | + $options['length'] = $length; |
|
188 | + break; |
|
189 | + case 'unsigned': |
|
190 | + $unsigned = $this->asBool($child); |
|
191 | + $options['unsigned'] = $unsigned; |
|
192 | + break; |
|
193 | + case 'notnull': |
|
194 | + $notnull = $this->asBool($child); |
|
195 | + $options['notnull'] = $notnull; |
|
196 | + break; |
|
197 | + case 'autoincrement': |
|
198 | + $autoincrement = $this->asBool($child); |
|
199 | + $options['autoincrement'] = $autoincrement; |
|
200 | + break; |
|
201 | + case 'default': |
|
202 | + $default = (string)$child; |
|
203 | + $options['default'] = $default; |
|
204 | + break; |
|
205 | + case 'comments': |
|
206 | + $comment = (string)$child; |
|
207 | + $options['comment'] = $comment; |
|
208 | + break; |
|
209 | + case 'primary': |
|
210 | + $primary = $this->asBool($child); |
|
211 | + $options['primary'] = $primary; |
|
212 | + break; |
|
213 | + case 'precision': |
|
214 | + $precision = (string)$child; |
|
215 | + $options['precision'] = $precision; |
|
216 | + break; |
|
217 | + case 'scale': |
|
218 | + $scale = (string)$child; |
|
219 | + $options['scale'] = $scale; |
|
220 | + break; |
|
221 | + default: |
|
222 | + throw new \DomainException('Unknown element: ' . $child->getName()); |
|
223 | 223 | |
224 | - } |
|
225 | - } |
|
226 | - if (isset($name) && isset($type)) { |
|
227 | - if (isset($options['default']) && empty($options['default'])) { |
|
228 | - if (empty($options['notnull']) || !$options['notnull']) { |
|
229 | - unset($options['default']); |
|
230 | - $options['notnull'] = false; |
|
231 | - } else { |
|
232 | - $options['default'] = ''; |
|
233 | - } |
|
234 | - if ($type == 'integer' || $type == 'decimal') { |
|
235 | - $options['default'] = 0; |
|
236 | - } elseif ($type == 'boolean') { |
|
237 | - $options['default'] = false; |
|
238 | - } |
|
239 | - if (!empty($options['autoincrement']) && $options['autoincrement']) { |
|
240 | - unset($options['default']); |
|
241 | - } |
|
242 | - } |
|
243 | - if ($type === 'integer' && isset($options['default'])) { |
|
244 | - $options['default'] = (int)$options['default']; |
|
245 | - } |
|
246 | - if ($type === 'integer' && isset($options['length'])) { |
|
247 | - $length = $options['length']; |
|
248 | - if ($length < 4) { |
|
249 | - $type = 'smallint'; |
|
250 | - } else if ($length > 4) { |
|
251 | - $type = 'bigint'; |
|
252 | - } |
|
253 | - } |
|
254 | - if ($type === 'boolean' && isset($options['default'])) { |
|
255 | - $options['default'] = $this->asBool($options['default']); |
|
256 | - } |
|
257 | - if (!empty($options['autoincrement']) |
|
258 | - && !empty($options['notnull']) |
|
259 | - ) { |
|
260 | - $options['primary'] = true; |
|
261 | - } |
|
224 | + } |
|
225 | + } |
|
226 | + if (isset($name) && isset($type)) { |
|
227 | + if (isset($options['default']) && empty($options['default'])) { |
|
228 | + if (empty($options['notnull']) || !$options['notnull']) { |
|
229 | + unset($options['default']); |
|
230 | + $options['notnull'] = false; |
|
231 | + } else { |
|
232 | + $options['default'] = ''; |
|
233 | + } |
|
234 | + if ($type == 'integer' || $type == 'decimal') { |
|
235 | + $options['default'] = 0; |
|
236 | + } elseif ($type == 'boolean') { |
|
237 | + $options['default'] = false; |
|
238 | + } |
|
239 | + if (!empty($options['autoincrement']) && $options['autoincrement']) { |
|
240 | + unset($options['default']); |
|
241 | + } |
|
242 | + } |
|
243 | + if ($type === 'integer' && isset($options['default'])) { |
|
244 | + $options['default'] = (int)$options['default']; |
|
245 | + } |
|
246 | + if ($type === 'integer' && isset($options['length'])) { |
|
247 | + $length = $options['length']; |
|
248 | + if ($length < 4) { |
|
249 | + $type = 'smallint'; |
|
250 | + } else if ($length > 4) { |
|
251 | + $type = 'bigint'; |
|
252 | + } |
|
253 | + } |
|
254 | + if ($type === 'boolean' && isset($options['default'])) { |
|
255 | + $options['default'] = $this->asBool($options['default']); |
|
256 | + } |
|
257 | + if (!empty($options['autoincrement']) |
|
258 | + && !empty($options['notnull']) |
|
259 | + ) { |
|
260 | + $options['primary'] = true; |
|
261 | + } |
|
262 | 262 | |
263 | - $table->addColumn($name, $type, $options); |
|
264 | - if (!empty($options['primary']) && $options['primary']) { |
|
265 | - $table->setPrimaryKey([$name]); |
|
266 | - } |
|
267 | - } |
|
268 | - } |
|
263 | + $table->addColumn($name, $type, $options); |
|
264 | + if (!empty($options['primary']) && $options['primary']) { |
|
265 | + $table->setPrimaryKey([$name]); |
|
266 | + } |
|
267 | + } |
|
268 | + } |
|
269 | 269 | |
270 | - /** |
|
271 | - * @param \Doctrine\DBAL\Schema\Table $table |
|
272 | - * @param \SimpleXMLElement $xml |
|
273 | - * @throws \DomainException |
|
274 | - */ |
|
275 | - private function loadIndex($table, $xml) { |
|
276 | - $name = null; |
|
277 | - $fields = []; |
|
278 | - foreach ($xml->children() as $child) { |
|
279 | - /** |
|
280 | - * @var \SimpleXMLElement $child |
|
281 | - */ |
|
282 | - switch ($child->getName()) { |
|
283 | - case 'name': |
|
284 | - $name = (string)$child; |
|
285 | - break; |
|
286 | - case 'primary': |
|
287 | - $primary = $this->asBool($child); |
|
288 | - break; |
|
289 | - case 'unique': |
|
290 | - $unique = $this->asBool($child); |
|
291 | - break; |
|
292 | - case 'field': |
|
293 | - foreach ($child->children() as $field) { |
|
294 | - /** |
|
295 | - * @var \SimpleXMLElement $field |
|
296 | - */ |
|
297 | - switch ($field->getName()) { |
|
298 | - case 'name': |
|
299 | - $field_name = (string)$field; |
|
300 | - $field_name = $this->platform->quoteIdentifier($field_name); |
|
301 | - $fields[] = $field_name; |
|
302 | - break; |
|
303 | - case 'sorting': |
|
304 | - break; |
|
305 | - default: |
|
306 | - throw new \DomainException('Unknown element: ' . $field->getName()); |
|
270 | + /** |
|
271 | + * @param \Doctrine\DBAL\Schema\Table $table |
|
272 | + * @param \SimpleXMLElement $xml |
|
273 | + * @throws \DomainException |
|
274 | + */ |
|
275 | + private function loadIndex($table, $xml) { |
|
276 | + $name = null; |
|
277 | + $fields = []; |
|
278 | + foreach ($xml->children() as $child) { |
|
279 | + /** |
|
280 | + * @var \SimpleXMLElement $child |
|
281 | + */ |
|
282 | + switch ($child->getName()) { |
|
283 | + case 'name': |
|
284 | + $name = (string)$child; |
|
285 | + break; |
|
286 | + case 'primary': |
|
287 | + $primary = $this->asBool($child); |
|
288 | + break; |
|
289 | + case 'unique': |
|
290 | + $unique = $this->asBool($child); |
|
291 | + break; |
|
292 | + case 'field': |
|
293 | + foreach ($child->children() as $field) { |
|
294 | + /** |
|
295 | + * @var \SimpleXMLElement $field |
|
296 | + */ |
|
297 | + switch ($field->getName()) { |
|
298 | + case 'name': |
|
299 | + $field_name = (string)$field; |
|
300 | + $field_name = $this->platform->quoteIdentifier($field_name); |
|
301 | + $fields[] = $field_name; |
|
302 | + break; |
|
303 | + case 'sorting': |
|
304 | + break; |
|
305 | + default: |
|
306 | + throw new \DomainException('Unknown element: ' . $field->getName()); |
|
307 | 307 | |
308 | - } |
|
309 | - } |
|
310 | - break; |
|
311 | - default: |
|
312 | - throw new \DomainException('Unknown element: ' . $child->getName()); |
|
308 | + } |
|
309 | + } |
|
310 | + break; |
|
311 | + default: |
|
312 | + throw new \DomainException('Unknown element: ' . $child->getName()); |
|
313 | 313 | |
314 | - } |
|
315 | - } |
|
316 | - if (!empty($fields)) { |
|
317 | - if (isset($primary) && $primary) { |
|
318 | - if ($table->hasPrimaryKey()) { |
|
319 | - return; |
|
320 | - } |
|
321 | - $table->setPrimaryKey($fields, $name); |
|
322 | - } else { |
|
323 | - if (isset($unique) && $unique) { |
|
324 | - $table->addUniqueIndex($fields, $name); |
|
325 | - } else { |
|
326 | - $table->addIndex($fields, $name); |
|
327 | - } |
|
328 | - } |
|
329 | - } else { |
|
330 | - throw new \DomainException('Empty index definition: ' . $name . ' options:' . print_r($fields, true)); |
|
331 | - } |
|
332 | - } |
|
314 | + } |
|
315 | + } |
|
316 | + if (!empty($fields)) { |
|
317 | + if (isset($primary) && $primary) { |
|
318 | + if ($table->hasPrimaryKey()) { |
|
319 | + return; |
|
320 | + } |
|
321 | + $table->setPrimaryKey($fields, $name); |
|
322 | + } else { |
|
323 | + if (isset($unique) && $unique) { |
|
324 | + $table->addUniqueIndex($fields, $name); |
|
325 | + } else { |
|
326 | + $table->addIndex($fields, $name); |
|
327 | + } |
|
328 | + } |
|
329 | + } else { |
|
330 | + throw new \DomainException('Empty index definition: ' . $name . ' options:' . print_r($fields, true)); |
|
331 | + } |
|
332 | + } |
|
333 | 333 | |
334 | - /** |
|
335 | - * @param \SimpleXMLElement|string $xml |
|
336 | - * @return bool |
|
337 | - */ |
|
338 | - private function asBool($xml) { |
|
339 | - $result = (string)$xml; |
|
340 | - if ($result == 'true') { |
|
341 | - $result = true; |
|
342 | - } elseif ($result == 'false') { |
|
343 | - $result = false; |
|
344 | - } |
|
345 | - return (bool)$result; |
|
346 | - } |
|
334 | + /** |
|
335 | + * @param \SimpleXMLElement|string $xml |
|
336 | + * @return bool |
|
337 | + */ |
|
338 | + private function asBool($xml) { |
|
339 | + $result = (string)$xml; |
|
340 | + if ($result == 'true') { |
|
341 | + $result = true; |
|
342 | + } elseif ($result == 'false') { |
|
343 | + $result = false; |
|
344 | + } |
|
345 | + return (bool)$result; |
|
346 | + } |
|
347 | 347 | |
348 | 348 | } |
@@ -32,62 +32,62 @@ |
||
32 | 32 | |
33 | 33 | class SQLiteMigrator extends Migrator { |
34 | 34 | |
35 | - /** |
|
36 | - * @param \Doctrine\DBAL\Schema\Schema $targetSchema |
|
37 | - * @throws \OC\DB\MigrationException |
|
38 | - * |
|
39 | - * For sqlite we simple make a copy of the entire database, and test the migration on that |
|
40 | - */ |
|
41 | - public function checkMigrate(\Doctrine\DBAL\Schema\Schema $targetSchema) { |
|
42 | - $dbFile = $this->connection->getDatabase(); |
|
43 | - $tmpFile = $this->buildTempDatabase(); |
|
44 | - copy($dbFile, $tmpFile); |
|
35 | + /** |
|
36 | + * @param \Doctrine\DBAL\Schema\Schema $targetSchema |
|
37 | + * @throws \OC\DB\MigrationException |
|
38 | + * |
|
39 | + * For sqlite we simple make a copy of the entire database, and test the migration on that |
|
40 | + */ |
|
41 | + public function checkMigrate(\Doctrine\DBAL\Schema\Schema $targetSchema) { |
|
42 | + $dbFile = $this->connection->getDatabase(); |
|
43 | + $tmpFile = $this->buildTempDatabase(); |
|
44 | + copy($dbFile, $tmpFile); |
|
45 | 45 | |
46 | - $connectionParams = [ |
|
47 | - 'path' => $tmpFile, |
|
48 | - 'driver' => 'pdo_sqlite', |
|
49 | - ]; |
|
50 | - $conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams); |
|
51 | - try { |
|
52 | - $this->applySchema($targetSchema, $conn); |
|
53 | - $conn->close(); |
|
54 | - unlink($tmpFile); |
|
55 | - } catch (DBALException $e) { |
|
56 | - $conn->close(); |
|
57 | - unlink($tmpFile); |
|
58 | - throw new MigrationException('', $e->getMessage()); |
|
59 | - } |
|
60 | - } |
|
46 | + $connectionParams = [ |
|
47 | + 'path' => $tmpFile, |
|
48 | + 'driver' => 'pdo_sqlite', |
|
49 | + ]; |
|
50 | + $conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams); |
|
51 | + try { |
|
52 | + $this->applySchema($targetSchema, $conn); |
|
53 | + $conn->close(); |
|
54 | + unlink($tmpFile); |
|
55 | + } catch (DBALException $e) { |
|
56 | + $conn->close(); |
|
57 | + unlink($tmpFile); |
|
58 | + throw new MigrationException('', $e->getMessage()); |
|
59 | + } |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * @return string |
|
64 | - */ |
|
65 | - private function buildTempDatabase() { |
|
66 | - $dataDir = $this->config->getSystemValue("datadirectory", \OC::$SERVERROOT . '/data'); |
|
67 | - $tmpFile = uniqid("oc_"); |
|
68 | - return "$dataDir/$tmpFile.db"; |
|
69 | - } |
|
62 | + /** |
|
63 | + * @return string |
|
64 | + */ |
|
65 | + private function buildTempDatabase() { |
|
66 | + $dataDir = $this->config->getSystemValue("datadirectory", \OC::$SERVERROOT . '/data'); |
|
67 | + $tmpFile = uniqid("oc_"); |
|
68 | + return "$dataDir/$tmpFile.db"; |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * @param Schema $targetSchema |
|
73 | - * @param \Doctrine\DBAL\Connection $connection |
|
74 | - * @return \Doctrine\DBAL\Schema\SchemaDiff |
|
75 | - */ |
|
76 | - protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection) { |
|
77 | - $platform = $connection->getDatabasePlatform(); |
|
78 | - $platform->registerDoctrineTypeMapping('tinyint unsigned', 'integer'); |
|
79 | - $platform->registerDoctrineTypeMapping('smallint unsigned', 'integer'); |
|
80 | - $platform->registerDoctrineTypeMapping('varchar ', 'string'); |
|
71 | + /** |
|
72 | + * @param Schema $targetSchema |
|
73 | + * @param \Doctrine\DBAL\Connection $connection |
|
74 | + * @return \Doctrine\DBAL\Schema\SchemaDiff |
|
75 | + */ |
|
76 | + protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection) { |
|
77 | + $platform = $connection->getDatabasePlatform(); |
|
78 | + $platform->registerDoctrineTypeMapping('tinyint unsigned', 'integer'); |
|
79 | + $platform->registerDoctrineTypeMapping('smallint unsigned', 'integer'); |
|
80 | + $platform->registerDoctrineTypeMapping('varchar ', 'string'); |
|
81 | 81 | |
82 | - // with sqlite autoincrement columns is of type integer |
|
83 | - foreach ($targetSchema->getTables() as $table) { |
|
84 | - foreach ($table->getColumns() as $column) { |
|
85 | - if ($column->getType() instanceof BigIntType && $column->getAutoincrement()) { |
|
86 | - $column->setType(Type::getType('integer')); |
|
87 | - } |
|
88 | - } |
|
89 | - } |
|
82 | + // with sqlite autoincrement columns is of type integer |
|
83 | + foreach ($targetSchema->getTables() as $table) { |
|
84 | + foreach ($table->getColumns() as $column) { |
|
85 | + if ($column->getType() instanceof BigIntType && $column->getAutoincrement()) { |
|
86 | + $column->setType(Type::getType('integer')); |
|
87 | + } |
|
88 | + } |
|
89 | + } |
|
90 | 90 | |
91 | - return parent::getDiff($targetSchema, $connection); |
|
92 | - } |
|
91 | + return parent::getDiff($targetSchema, $connection); |
|
92 | + } |
|
93 | 93 | } |
@@ -24,12 +24,12 @@ |
||
24 | 24 | namespace OC\BackgroundJob\Legacy; |
25 | 25 | |
26 | 26 | class QueuedJob extends \OC\BackgroundJob\QueuedJob { |
27 | - public function run($argument) { |
|
28 | - $class = $argument['klass']; |
|
29 | - $method = $argument['method']; |
|
30 | - $parameters = $argument['parameters']; |
|
31 | - if (is_callable([$class, $method])) { |
|
32 | - call_user_func([$class, $method], $parameters); |
|
33 | - } |
|
34 | - } |
|
27 | + public function run($argument) { |
|
28 | + $class = $argument['klass']; |
|
29 | + $method = $argument['method']; |
|
30 | + $parameters = $argument['parameters']; |
|
31 | + if (is_callable([$class, $method])) { |
|
32 | + call_user_func([$class, $method], $parameters); |
|
33 | + } |
|
34 | + } |
|
35 | 35 | } |