@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | /** |
55 | 55 | * pass all other function directly to the \Doctrine\DBAL\Driver\Statement |
56 | 56 | */ |
57 | - public function __call($name,$arguments) { |
|
58 | - return call_user_func_array(array($this->statement,$name), $arguments); |
|
57 | + public function __call($name, $arguments) { |
|
58 | + return call_user_func_array(array($this->statement, $name), $arguments); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * @param array $input |
65 | 65 | * @return \OC_DB_StatementWrapper|int|bool |
66 | 66 | */ |
67 | - public function execute($input= []) { |
|
67 | + public function execute($input = []) { |
|
68 | 68 | $this->lastArguments = $input; |
69 | 69 | if (count($input) > 0) { |
70 | 70 | $result = $this->statement->execute($input); |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * @param integer|null $length max length when using an OUT bind |
114 | 114 | * @return boolean |
115 | 115 | */ |
116 | - public function bindParam($column, &$variable, $type = null, $length = null){ |
|
116 | + public function bindParam($column, &$variable, $type = null, $length = null) { |
|
117 | 117 | return $this->statement->bindParam($column, $variable, $type, $length); |
118 | 118 | } |
119 | 119 | } |
@@ -37,83 +37,83 @@ |
||
37 | 37 | * @method array fetchAll(integer $fetchMode = null); |
38 | 38 | */ |
39 | 39 | class OC_DB_StatementWrapper { |
40 | - /** |
|
41 | - * @var \Doctrine\DBAL\Driver\Statement |
|
42 | - */ |
|
43 | - private $statement = null; |
|
44 | - private $isManipulation = false; |
|
45 | - private $lastArguments = array(); |
|
40 | + /** |
|
41 | + * @var \Doctrine\DBAL\Driver\Statement |
|
42 | + */ |
|
43 | + private $statement = null; |
|
44 | + private $isManipulation = false; |
|
45 | + private $lastArguments = array(); |
|
46 | 46 | |
47 | - /** |
|
48 | - * @param boolean $isManipulation |
|
49 | - */ |
|
50 | - public function __construct($statement, $isManipulation) { |
|
51 | - $this->statement = $statement; |
|
52 | - $this->isManipulation = $isManipulation; |
|
53 | - } |
|
47 | + /** |
|
48 | + * @param boolean $isManipulation |
|
49 | + */ |
|
50 | + public function __construct($statement, $isManipulation) { |
|
51 | + $this->statement = $statement; |
|
52 | + $this->isManipulation = $isManipulation; |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * pass all other function directly to the \Doctrine\DBAL\Driver\Statement |
|
57 | - */ |
|
58 | - public function __call($name,$arguments) { |
|
59 | - return call_user_func_array(array($this->statement,$name), $arguments); |
|
60 | - } |
|
55 | + /** |
|
56 | + * pass all other function directly to the \Doctrine\DBAL\Driver\Statement |
|
57 | + */ |
|
58 | + public function __call($name,$arguments) { |
|
59 | + return call_user_func_array(array($this->statement,$name), $arguments); |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * make execute return the result instead of a bool |
|
64 | - * |
|
65 | - * @param array $input |
|
66 | - * @return \OC_DB_StatementWrapper|int|bool |
|
67 | - */ |
|
68 | - public function execute($input= []) { |
|
69 | - $this->lastArguments = $input; |
|
70 | - if (count($input) > 0) { |
|
71 | - $result = $this->statement->execute($input); |
|
72 | - } else { |
|
73 | - $result = $this->statement->execute(); |
|
74 | - } |
|
62 | + /** |
|
63 | + * make execute return the result instead of a bool |
|
64 | + * |
|
65 | + * @param array $input |
|
66 | + * @return \OC_DB_StatementWrapper|int|bool |
|
67 | + */ |
|
68 | + public function execute($input= []) { |
|
69 | + $this->lastArguments = $input; |
|
70 | + if (count($input) > 0) { |
|
71 | + $result = $this->statement->execute($input); |
|
72 | + } else { |
|
73 | + $result = $this->statement->execute(); |
|
74 | + } |
|
75 | 75 | |
76 | - if ($result === false) { |
|
77 | - return false; |
|
78 | - } |
|
79 | - if ($this->isManipulation) { |
|
80 | - return $this->statement->rowCount(); |
|
81 | - } else { |
|
82 | - return $this; |
|
83 | - } |
|
84 | - } |
|
76 | + if ($result === false) { |
|
77 | + return false; |
|
78 | + } |
|
79 | + if ($this->isManipulation) { |
|
80 | + return $this->statement->rowCount(); |
|
81 | + } else { |
|
82 | + return $this; |
|
83 | + } |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * provide an alias for fetch |
|
88 | - * |
|
89 | - * @return mixed |
|
90 | - */ |
|
91 | - public function fetchRow() { |
|
92 | - return $this->statement->fetch(); |
|
93 | - } |
|
86 | + /** |
|
87 | + * provide an alias for fetch |
|
88 | + * |
|
89 | + * @return mixed |
|
90 | + */ |
|
91 | + public function fetchRow() { |
|
92 | + return $this->statement->fetch(); |
|
93 | + } |
|
94 | 94 | |
95 | - /** |
|
96 | - * Provide a simple fetchOne. |
|
97 | - * |
|
98 | - * fetch single column from the next row |
|
99 | - * @param int $column the column number to fetch |
|
100 | - * @return string |
|
101 | - */ |
|
102 | - public function fetchOne($column = 0) { |
|
103 | - return $this->statement->fetchColumn($column); |
|
104 | - } |
|
95 | + /** |
|
96 | + * Provide a simple fetchOne. |
|
97 | + * |
|
98 | + * fetch single column from the next row |
|
99 | + * @param int $column the column number to fetch |
|
100 | + * @return string |
|
101 | + */ |
|
102 | + public function fetchOne($column = 0) { |
|
103 | + return $this->statement->fetchColumn($column); |
|
104 | + } |
|
105 | 105 | |
106 | - /** |
|
107 | - * Binds a PHP variable to a corresponding named or question mark placeholder in the |
|
108 | - * SQL statement that was use to prepare the statement. |
|
109 | - * |
|
110 | - * @param mixed $column Either the placeholder name or the 1-indexed placeholder index |
|
111 | - * @param mixed $variable The variable to bind |
|
112 | - * @param integer|null $type one of the PDO::PARAM_* constants |
|
113 | - * @param integer|null $length max length when using an OUT bind |
|
114 | - * @return boolean |
|
115 | - */ |
|
116 | - public function bindParam($column, &$variable, $type = null, $length = null){ |
|
117 | - return $this->statement->bindParam($column, $variable, $type, $length); |
|
118 | - } |
|
106 | + /** |
|
107 | + * Binds a PHP variable to a corresponding named or question mark placeholder in the |
|
108 | + * SQL statement that was use to prepare the statement. |
|
109 | + * |
|
110 | + * @param mixed $column Either the placeholder name or the 1-indexed placeholder index |
|
111 | + * @param mixed $variable The variable to bind |
|
112 | + * @param integer|null $type one of the PDO::PARAM_* constants |
|
113 | + * @param integer|null $length max length when using an OUT bind |
|
114 | + * @return boolean |
|
115 | + */ |
|
116 | + public function bindParam($column, &$variable, $type = null, $length = null){ |
|
117 | + return $this->statement->bindParam($column, $variable, $type, $length); |
|
118 | + } |
|
119 | 119 | } |
@@ -29,179 +29,179 @@ |
||
29 | 29 | |
30 | 30 | class MigrationSchemaChecker extends NodeVisitorAbstract { |
31 | 31 | |
32 | - /** @var string */ |
|
33 | - protected $schemaVariableName = null; |
|
34 | - /** @var array */ |
|
35 | - protected $tableVariableNames = []; |
|
36 | - /** @var array */ |
|
37 | - public $errors = []; |
|
32 | + /** @var string */ |
|
33 | + protected $schemaVariableName = null; |
|
34 | + /** @var array */ |
|
35 | + protected $tableVariableNames = []; |
|
36 | + /** @var array */ |
|
37 | + public $errors = []; |
|
38 | 38 | |
39 | - /** |
|
40 | - * @param Node $node |
|
41 | - * @return void |
|
42 | - * |
|
43 | - * @suppress PhanUndeclaredProperty |
|
44 | - */ |
|
45 | - public function enterNode(Node $node) { |
|
46 | - /** |
|
47 | - * Check tables |
|
48 | - */ |
|
49 | - if ($this->schemaVariableName !== null && |
|
50 | - $node instanceof Node\Expr\Assign && |
|
51 | - $node->var instanceof Node\Expr\Variable && |
|
52 | - $node->expr instanceof Node\Expr\MethodCall && |
|
53 | - $node->expr->var instanceof Node\Expr\Variable && |
|
54 | - $node->expr->var->name === $this->schemaVariableName) { |
|
39 | + /** |
|
40 | + * @param Node $node |
|
41 | + * @return void |
|
42 | + * |
|
43 | + * @suppress PhanUndeclaredProperty |
|
44 | + */ |
|
45 | + public function enterNode(Node $node) { |
|
46 | + /** |
|
47 | + * Check tables |
|
48 | + */ |
|
49 | + if ($this->schemaVariableName !== null && |
|
50 | + $node instanceof Node\Expr\Assign && |
|
51 | + $node->var instanceof Node\Expr\Variable && |
|
52 | + $node->expr instanceof Node\Expr\MethodCall && |
|
53 | + $node->expr->var instanceof Node\Expr\Variable && |
|
54 | + $node->expr->var->name === $this->schemaVariableName) { |
|
55 | 55 | |
56 | - if ($node->expr->name === 'createTable') { |
|
57 | - if (isset($node->expr->args[0]) && $node->expr->args[0]->value instanceof Node\Scalar\String_) { |
|
58 | - if (!$this->checkNameLength($node->expr->args[0]->value->value)) { |
|
59 | - $this->errors[] = [ |
|
60 | - 'line' => $node->getLine(), |
|
61 | - 'disallowedToken' => $node->expr->args[0]->value->value, |
|
62 | - 'reason' => 'Table name is too long (max. 27)', |
|
63 | - ]; |
|
64 | - } else { |
|
65 | - $this->tableVariableNames[$node->var->name] = $node->expr->args[0]->value->value; |
|
66 | - } |
|
67 | - } |
|
68 | - } else if ($node->expr->name === 'getTable') { |
|
69 | - if (isset($node->expr->args[0]) && $node->expr->args[0]->value instanceof Node\Scalar\String_) { |
|
70 | - $this->tableVariableNames[$node->var->name] = $node->expr->args[0]->value->value; |
|
71 | - } |
|
72 | - } |
|
73 | - } else if ($this->schemaVariableName !== null && |
|
74 | - $node instanceof Node\Expr\MethodCall && |
|
75 | - $node->var instanceof Node\Expr\Variable && |
|
76 | - $node->var->name === $this->schemaVariableName) { |
|
56 | + if ($node->expr->name === 'createTable') { |
|
57 | + if (isset($node->expr->args[0]) && $node->expr->args[0]->value instanceof Node\Scalar\String_) { |
|
58 | + if (!$this->checkNameLength($node->expr->args[0]->value->value)) { |
|
59 | + $this->errors[] = [ |
|
60 | + 'line' => $node->getLine(), |
|
61 | + 'disallowedToken' => $node->expr->args[0]->value->value, |
|
62 | + 'reason' => 'Table name is too long (max. 27)', |
|
63 | + ]; |
|
64 | + } else { |
|
65 | + $this->tableVariableNames[$node->var->name] = $node->expr->args[0]->value->value; |
|
66 | + } |
|
67 | + } |
|
68 | + } else if ($node->expr->name === 'getTable') { |
|
69 | + if (isset($node->expr->args[0]) && $node->expr->args[0]->value instanceof Node\Scalar\String_) { |
|
70 | + $this->tableVariableNames[$node->var->name] = $node->expr->args[0]->value->value; |
|
71 | + } |
|
72 | + } |
|
73 | + } else if ($this->schemaVariableName !== null && |
|
74 | + $node instanceof Node\Expr\MethodCall && |
|
75 | + $node->var instanceof Node\Expr\Variable && |
|
76 | + $node->var->name === $this->schemaVariableName) { |
|
77 | 77 | |
78 | - if ($node->name === 'renameTable') { |
|
79 | - $this->errors[] = [ |
|
80 | - 'line' => $node->getLine(), |
|
81 | - 'disallowedToken' => 'Deprecated method', |
|
82 | - 'reason' => sprintf( |
|
83 | - '`$%s->renameTable()` must not be used', |
|
84 | - $node->var->name |
|
85 | - ), |
|
86 | - ]; |
|
87 | - } |
|
78 | + if ($node->name === 'renameTable') { |
|
79 | + $this->errors[] = [ |
|
80 | + 'line' => $node->getLine(), |
|
81 | + 'disallowedToken' => 'Deprecated method', |
|
82 | + 'reason' => sprintf( |
|
83 | + '`$%s->renameTable()` must not be used', |
|
84 | + $node->var->name |
|
85 | + ), |
|
86 | + ]; |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * Check columns and Indexes |
|
91 | - */ |
|
92 | - } else if (!empty($this->tableVariableNames) && |
|
93 | - $node instanceof Node\Expr\MethodCall && |
|
94 | - $node->var instanceof Node\Expr\Variable && |
|
95 | - isset($this->tableVariableNames[$node->var->name])) { |
|
89 | + /** |
|
90 | + * Check columns and Indexes |
|
91 | + */ |
|
92 | + } else if (!empty($this->tableVariableNames) && |
|
93 | + $node instanceof Node\Expr\MethodCall && |
|
94 | + $node->var instanceof Node\Expr\Variable && |
|
95 | + isset($this->tableVariableNames[$node->var->name])) { |
|
96 | 96 | |
97 | - if ($node->name === 'addColumn' || $node->name === 'changeColumn') { |
|
98 | - if (isset($node->args[0]) && $node->args[0]->value instanceof Node\Scalar\String_) { |
|
99 | - if (!$this->checkNameLength($node->args[0]->value->value)) { |
|
100 | - $this->errors[] = [ |
|
101 | - 'line' => $node->getLine(), |
|
102 | - 'disallowedToken' => $node->args[0]->value->value, |
|
103 | - 'reason' => sprintf( |
|
104 | - 'Column name is too long on table `%s` (max. 27)', |
|
105 | - $this->tableVariableNames[$node->var->name] |
|
106 | - ), |
|
107 | - ]; |
|
108 | - } |
|
97 | + if ($node->name === 'addColumn' || $node->name === 'changeColumn') { |
|
98 | + if (isset($node->args[0]) && $node->args[0]->value instanceof Node\Scalar\String_) { |
|
99 | + if (!$this->checkNameLength($node->args[0]->value->value)) { |
|
100 | + $this->errors[] = [ |
|
101 | + 'line' => $node->getLine(), |
|
102 | + 'disallowedToken' => $node->args[0]->value->value, |
|
103 | + 'reason' => sprintf( |
|
104 | + 'Column name is too long on table `%s` (max. 27)', |
|
105 | + $this->tableVariableNames[$node->var->name] |
|
106 | + ), |
|
107 | + ]; |
|
108 | + } |
|
109 | 109 | |
110 | - // On autoincrement the max length of the table name is 21 instead of 27 |
|
111 | - if (isset($node->args[2]) && $node->args[2]->value instanceof Node\Expr\Array_) { |
|
112 | - /** @var Node\Expr\Array_ $options */ |
|
113 | - $options = $node->args[2]->value; |
|
114 | - if ($this->checkColumnForAutoincrement($options)) { |
|
115 | - if (!$this->checkNameLength($this->tableVariableNames[$node->var->name], true)) { |
|
116 | - $this->errors[] = [ |
|
117 | - 'line' => $node->getLine(), |
|
118 | - 'disallowedToken' => $this->tableVariableNames[$node->var->name], |
|
119 | - 'reason' => 'Table name is too long because of autoincrement (max. 21)', |
|
120 | - ]; |
|
121 | - } |
|
122 | - } |
|
123 | - } |
|
124 | - } |
|
125 | - } else if ($node->name === 'addIndex' || |
|
126 | - $node->name === 'addUniqueIndex' || |
|
127 | - $node->name === 'renameIndex' || |
|
128 | - $node->name === 'setPrimaryKey') { |
|
129 | - if (isset($node->args[1]) && $node->args[1]->value instanceof Node\Scalar\String_) { |
|
130 | - if (!$this->checkNameLength($node->args[1]->value->value)) { |
|
131 | - $this->errors[] = [ |
|
132 | - 'line' => $node->getLine(), |
|
133 | - 'disallowedToken' => $node->args[1]->value->value, |
|
134 | - 'reason' => sprintf( |
|
135 | - 'Index name is too long on table `%s` (max. 27)', |
|
136 | - $this->tableVariableNames[$node->var->name] |
|
137 | - ), |
|
138 | - ]; |
|
139 | - } |
|
140 | - } |
|
141 | - } else if ($node->name === 'addForeignKeyConstraint') { |
|
142 | - if (isset($node->args[4]) && $node->args[4]->value instanceof Node\Scalar\String_) { |
|
143 | - if (!$this->checkNameLength($node->args[4]->value->value)) { |
|
144 | - $this->errors[] = [ |
|
145 | - 'line' => $node->getLine(), |
|
146 | - 'disallowedToken' => $node->args[4]->value->value, |
|
147 | - 'reason' => sprintf( |
|
148 | - 'Constraint name is too long on table `%s` (max. 27)', |
|
149 | - $this->tableVariableNames[$node->var->name] |
|
150 | - ), |
|
151 | - ]; |
|
152 | - } |
|
153 | - } |
|
154 | - } else if ($node->name === 'renameColumn') { |
|
155 | - $this->errors[] = [ |
|
156 | - 'line' => $node->getLine(), |
|
157 | - 'disallowedToken' => 'Deprecated method', |
|
158 | - 'reason' => sprintf( |
|
159 | - '`$%s->renameColumn()` must not be used', |
|
160 | - $node->var->name |
|
161 | - ), |
|
162 | - ]; |
|
163 | - } |
|
110 | + // On autoincrement the max length of the table name is 21 instead of 27 |
|
111 | + if (isset($node->args[2]) && $node->args[2]->value instanceof Node\Expr\Array_) { |
|
112 | + /** @var Node\Expr\Array_ $options */ |
|
113 | + $options = $node->args[2]->value; |
|
114 | + if ($this->checkColumnForAutoincrement($options)) { |
|
115 | + if (!$this->checkNameLength($this->tableVariableNames[$node->var->name], true)) { |
|
116 | + $this->errors[] = [ |
|
117 | + 'line' => $node->getLine(), |
|
118 | + 'disallowedToken' => $this->tableVariableNames[$node->var->name], |
|
119 | + 'reason' => 'Table name is too long because of autoincrement (max. 21)', |
|
120 | + ]; |
|
121 | + } |
|
122 | + } |
|
123 | + } |
|
124 | + } |
|
125 | + } else if ($node->name === 'addIndex' || |
|
126 | + $node->name === 'addUniqueIndex' || |
|
127 | + $node->name === 'renameIndex' || |
|
128 | + $node->name === 'setPrimaryKey') { |
|
129 | + if (isset($node->args[1]) && $node->args[1]->value instanceof Node\Scalar\String_) { |
|
130 | + if (!$this->checkNameLength($node->args[1]->value->value)) { |
|
131 | + $this->errors[] = [ |
|
132 | + 'line' => $node->getLine(), |
|
133 | + 'disallowedToken' => $node->args[1]->value->value, |
|
134 | + 'reason' => sprintf( |
|
135 | + 'Index name is too long on table `%s` (max. 27)', |
|
136 | + $this->tableVariableNames[$node->var->name] |
|
137 | + ), |
|
138 | + ]; |
|
139 | + } |
|
140 | + } |
|
141 | + } else if ($node->name === 'addForeignKeyConstraint') { |
|
142 | + if (isset($node->args[4]) && $node->args[4]->value instanceof Node\Scalar\String_) { |
|
143 | + if (!$this->checkNameLength($node->args[4]->value->value)) { |
|
144 | + $this->errors[] = [ |
|
145 | + 'line' => $node->getLine(), |
|
146 | + 'disallowedToken' => $node->args[4]->value->value, |
|
147 | + 'reason' => sprintf( |
|
148 | + 'Constraint name is too long on table `%s` (max. 27)', |
|
149 | + $this->tableVariableNames[$node->var->name] |
|
150 | + ), |
|
151 | + ]; |
|
152 | + } |
|
153 | + } |
|
154 | + } else if ($node->name === 'renameColumn') { |
|
155 | + $this->errors[] = [ |
|
156 | + 'line' => $node->getLine(), |
|
157 | + 'disallowedToken' => 'Deprecated method', |
|
158 | + 'reason' => sprintf( |
|
159 | + '`$%s->renameColumn()` must not be used', |
|
160 | + $node->var->name |
|
161 | + ), |
|
162 | + ]; |
|
163 | + } |
|
164 | 164 | |
165 | - /** |
|
166 | - * Find the schema |
|
167 | - */ |
|
168 | - } else if ($node instanceof Node\Expr\Assign && |
|
169 | - $node->expr instanceof Node\Expr\FuncCall && |
|
170 | - $node->var instanceof Node\Expr\Variable && |
|
171 | - $node->expr->name instanceof Node\Expr\Variable && |
|
172 | - $node->expr->name->name === 'schemaClosure') { |
|
173 | - // E.g. $schema = $schemaClosure(); |
|
174 | - $this->schemaVariableName = $node->var->name; |
|
175 | - } |
|
176 | - } |
|
165 | + /** |
|
166 | + * Find the schema |
|
167 | + */ |
|
168 | + } else if ($node instanceof Node\Expr\Assign && |
|
169 | + $node->expr instanceof Node\Expr\FuncCall && |
|
170 | + $node->var instanceof Node\Expr\Variable && |
|
171 | + $node->expr->name instanceof Node\Expr\Variable && |
|
172 | + $node->expr->name->name === 'schemaClosure') { |
|
173 | + // E.g. $schema = $schemaClosure(); |
|
174 | + $this->schemaVariableName = $node->var->name; |
|
175 | + } |
|
176 | + } |
|
177 | 177 | |
178 | - protected function checkNameLength($tableName, $hasAutoincrement = false) { |
|
179 | - if ($hasAutoincrement) { |
|
180 | - return strlen($tableName) <= 21; |
|
181 | - } |
|
182 | - return strlen($tableName) <= 27; |
|
183 | - } |
|
178 | + protected function checkNameLength($tableName, $hasAutoincrement = false) { |
|
179 | + if ($hasAutoincrement) { |
|
180 | + return strlen($tableName) <= 21; |
|
181 | + } |
|
182 | + return strlen($tableName) <= 27; |
|
183 | + } |
|
184 | 184 | |
185 | - /** |
|
186 | - * @param Node\Expr\Array_ $optionsArray |
|
187 | - * @return bool Whether the column is an autoincrement column |
|
188 | - */ |
|
189 | - protected function checkColumnForAutoincrement(Node\Expr\Array_ $optionsArray) { |
|
190 | - foreach ($optionsArray->items as $option) { |
|
191 | - if ($option->key instanceof Node\Scalar\String_) { |
|
192 | - if ($option->key->value === 'autoincrement' && |
|
193 | - $option->value instanceof Node\Expr\ConstFetch) { |
|
194 | - /** @var Node\Expr\ConstFetch $const */ |
|
195 | - $const = $option->value; |
|
185 | + /** |
|
186 | + * @param Node\Expr\Array_ $optionsArray |
|
187 | + * @return bool Whether the column is an autoincrement column |
|
188 | + */ |
|
189 | + protected function checkColumnForAutoincrement(Node\Expr\Array_ $optionsArray) { |
|
190 | + foreach ($optionsArray->items as $option) { |
|
191 | + if ($option->key instanceof Node\Scalar\String_) { |
|
192 | + if ($option->key->value === 'autoincrement' && |
|
193 | + $option->value instanceof Node\Expr\ConstFetch) { |
|
194 | + /** @var Node\Expr\ConstFetch $const */ |
|
195 | + $const = $option->value; |
|
196 | 196 | |
197 | - if ($const->name instanceof Name && |
|
198 | - $const->name->parts === ['true']) { |
|
199 | - return true; |
|
200 | - } |
|
201 | - } |
|
202 | - } |
|
203 | - } |
|
197 | + if ($const->name instanceof Name && |
|
198 | + $const->name->parts === ['true']) { |
|
199 | + return true; |
|
200 | + } |
|
201 | + } |
|
202 | + } |
|
203 | + } |
|
204 | 204 | |
205 | - return false; |
|
206 | - } |
|
205 | + return false; |
|
206 | + } |
|
207 | 207 | } |
@@ -25,16 +25,16 @@ |
||
25 | 25 | |
26 | 26 | class Exception extends \Exception { |
27 | 27 | |
28 | - /** @var Result */ |
|
29 | - private $result; |
|
28 | + /** @var Result */ |
|
29 | + private $result; |
|
30 | 30 | |
31 | - public function __construct(Result $result) { |
|
32 | - parent::__construct(); |
|
33 | - $this->result = $result; |
|
34 | - } |
|
31 | + public function __construct(Result $result) { |
|
32 | + parent::__construct(); |
|
33 | + $this->result = $result; |
|
34 | + } |
|
35 | 35 | |
36 | - public function getResult() { |
|
37 | - return $this->result; |
|
38 | - } |
|
36 | + public function getResult() { |
|
37 | + return $this->result; |
|
38 | + } |
|
39 | 39 | |
40 | 40 | } |
@@ -32,26 +32,26 @@ |
||
32 | 32 | * @package OC\BackgroundJob |
33 | 33 | */ |
34 | 34 | abstract class TimedJob extends Job { |
35 | - protected $interval = 0; |
|
35 | + protected $interval = 0; |
|
36 | 36 | |
37 | - /** |
|
38 | - * set the interval for the job |
|
39 | - * |
|
40 | - * @param int $interval |
|
41 | - */ |
|
42 | - public function setInterval($interval) { |
|
43 | - $this->interval = $interval; |
|
44 | - } |
|
37 | + /** |
|
38 | + * set the interval for the job |
|
39 | + * |
|
40 | + * @param int $interval |
|
41 | + */ |
|
42 | + public function setInterval($interval) { |
|
43 | + $this->interval = $interval; |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * run the job if |
|
48 | - * |
|
49 | - * @param JobList $jobList |
|
50 | - * @param ILogger|null $logger |
|
51 | - */ |
|
52 | - public function execute($jobList, ILogger $logger = null) { |
|
53 | - if ((time() - $this->lastRun) > $this->interval) { |
|
54 | - parent::execute($jobList, $logger); |
|
55 | - } |
|
56 | - } |
|
46 | + /** |
|
47 | + * run the job if |
|
48 | + * |
|
49 | + * @param JobList $jobList |
|
50 | + * @param ILogger|null $logger |
|
51 | + */ |
|
52 | + public function execute($jobList, ILogger $logger = null) { |
|
53 | + if ((time() - $this->lastRun) > $this->interval) { |
|
54 | + parent::execute($jobList, $logger); |
|
55 | + } |
|
56 | + } |
|
57 | 57 | } |
@@ -32,14 +32,14 @@ |
||
32 | 32 | * @package OC\BackgroundJob |
33 | 33 | */ |
34 | 34 | abstract class QueuedJob extends Job { |
35 | - /** |
|
36 | - * run the job, then remove it from the joblist |
|
37 | - * |
|
38 | - * @param JobList $jobList |
|
39 | - * @param ILogger|null $logger |
|
40 | - */ |
|
41 | - public function execute($jobList, ILogger $logger = null) { |
|
42 | - $jobList->remove($this, $this->argument); |
|
43 | - parent::execute($jobList, $logger); |
|
44 | - } |
|
35 | + /** |
|
36 | + * run the job, then remove it from the joblist |
|
37 | + * |
|
38 | + * @param JobList $jobList |
|
39 | + * @param ILogger|null $logger |
|
40 | + */ |
|
41 | + public function execute($jobList, ILogger $logger = null) { |
|
42 | + $jobList->remove($this, $this->argument); |
|
43 | + parent::execute($jobList, $logger); |
|
44 | + } |
|
45 | 45 | } |
@@ -30,439 +30,439 @@ |
||
30 | 30 | * Throws a StorageNotAvailableException for storages with known failures |
31 | 31 | */ |
32 | 32 | class Availability extends Wrapper { |
33 | - const RECHECK_TTL_SEC = 600; // 10 minutes |
|
34 | - |
|
35 | - public static function shouldRecheck($availability) { |
|
36 | - if (!$availability['available']) { |
|
37 | - // trigger a recheck if TTL reached |
|
38 | - if ((time() - $availability['last_checked']) > self::RECHECK_TTL_SEC) { |
|
39 | - return true; |
|
40 | - } |
|
41 | - } |
|
42 | - return false; |
|
43 | - } |
|
44 | - |
|
45 | - /** |
|
46 | - * Only called if availability === false |
|
47 | - * |
|
48 | - * @return bool |
|
49 | - */ |
|
50 | - private function updateAvailability() { |
|
51 | - // reset availability to false so that multiple requests don't recheck concurrently |
|
52 | - $this->setAvailability(false); |
|
53 | - try { |
|
54 | - $result = $this->test(); |
|
55 | - } catch (\Exception $e) { |
|
56 | - $result = false; |
|
57 | - } |
|
58 | - $this->setAvailability($result); |
|
59 | - return $result; |
|
60 | - } |
|
61 | - |
|
62 | - /** |
|
63 | - * @return bool |
|
64 | - */ |
|
65 | - private function isAvailable() { |
|
66 | - $availability = $this->getAvailability(); |
|
67 | - if (self::shouldRecheck($availability)) { |
|
68 | - return $this->updateAvailability(); |
|
69 | - } |
|
70 | - return $availability['available']; |
|
71 | - } |
|
72 | - |
|
73 | - /** |
|
74 | - * @throws \OCP\Files\StorageNotAvailableException |
|
75 | - */ |
|
76 | - private function checkAvailability() { |
|
77 | - if (!$this->isAvailable()) { |
|
78 | - throw new \OCP\Files\StorageNotAvailableException(); |
|
79 | - } |
|
80 | - } |
|
81 | - |
|
82 | - /** {@inheritdoc} */ |
|
83 | - public function mkdir($path) { |
|
84 | - $this->checkAvailability(); |
|
85 | - try { |
|
86 | - return parent::mkdir($path); |
|
87 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
88 | - $this->setAvailability(false); |
|
89 | - throw $e; |
|
90 | - } |
|
91 | - } |
|
92 | - |
|
93 | - /** {@inheritdoc} */ |
|
94 | - public function rmdir($path) { |
|
95 | - $this->checkAvailability(); |
|
96 | - try { |
|
97 | - return parent::rmdir($path); |
|
98 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
99 | - $this->setAvailability(false); |
|
100 | - throw $e; |
|
101 | - } |
|
102 | - } |
|
103 | - |
|
104 | - /** {@inheritdoc} */ |
|
105 | - public function opendir($path) { |
|
106 | - $this->checkAvailability(); |
|
107 | - try { |
|
108 | - return parent::opendir($path); |
|
109 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
110 | - $this->setAvailability(false); |
|
111 | - throw $e; |
|
112 | - } |
|
113 | - } |
|
114 | - |
|
115 | - /** {@inheritdoc} */ |
|
116 | - public function is_dir($path) { |
|
117 | - $this->checkAvailability(); |
|
118 | - try { |
|
119 | - return parent::is_dir($path); |
|
120 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
121 | - $this->setAvailability(false); |
|
122 | - throw $e; |
|
123 | - } |
|
124 | - } |
|
125 | - |
|
126 | - /** {@inheritdoc} */ |
|
127 | - public function is_file($path) { |
|
128 | - $this->checkAvailability(); |
|
129 | - try { |
|
130 | - return parent::is_file($path); |
|
131 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
132 | - $this->setAvailability(false); |
|
133 | - throw $e; |
|
134 | - } |
|
135 | - } |
|
136 | - |
|
137 | - /** {@inheritdoc} */ |
|
138 | - public function stat($path) { |
|
139 | - $this->checkAvailability(); |
|
140 | - try { |
|
141 | - return parent::stat($path); |
|
142 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
143 | - $this->setAvailability(false); |
|
144 | - throw $e; |
|
145 | - } |
|
146 | - } |
|
147 | - |
|
148 | - /** {@inheritdoc} */ |
|
149 | - public function filetype($path) { |
|
150 | - $this->checkAvailability(); |
|
151 | - try { |
|
152 | - return parent::filetype($path); |
|
153 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
154 | - $this->setAvailability(false); |
|
155 | - throw $e; |
|
156 | - } |
|
157 | - } |
|
158 | - |
|
159 | - /** {@inheritdoc} */ |
|
160 | - public function filesize($path) { |
|
161 | - $this->checkAvailability(); |
|
162 | - try { |
|
163 | - return parent::filesize($path); |
|
164 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
165 | - $this->setAvailability(false); |
|
166 | - throw $e; |
|
167 | - } |
|
168 | - } |
|
169 | - |
|
170 | - /** {@inheritdoc} */ |
|
171 | - public function isCreatable($path) { |
|
172 | - $this->checkAvailability(); |
|
173 | - try { |
|
174 | - return parent::isCreatable($path); |
|
175 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
176 | - $this->setAvailability(false); |
|
177 | - throw $e; |
|
178 | - } |
|
179 | - } |
|
180 | - |
|
181 | - /** {@inheritdoc} */ |
|
182 | - public function isReadable($path) { |
|
183 | - $this->checkAvailability(); |
|
184 | - try { |
|
185 | - return parent::isReadable($path); |
|
186 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
187 | - $this->setAvailability(false); |
|
188 | - throw $e; |
|
189 | - } |
|
190 | - } |
|
191 | - |
|
192 | - /** {@inheritdoc} */ |
|
193 | - public function isUpdatable($path) { |
|
194 | - $this->checkAvailability(); |
|
195 | - try { |
|
196 | - return parent::isUpdatable($path); |
|
197 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
198 | - $this->setAvailability(false); |
|
199 | - throw $e; |
|
200 | - } |
|
201 | - } |
|
202 | - |
|
203 | - /** {@inheritdoc} */ |
|
204 | - public function isDeletable($path) { |
|
205 | - $this->checkAvailability(); |
|
206 | - try { |
|
207 | - return parent::isDeletable($path); |
|
208 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
209 | - $this->setAvailability(false); |
|
210 | - throw $e; |
|
211 | - } |
|
212 | - } |
|
213 | - |
|
214 | - /** {@inheritdoc} */ |
|
215 | - public function isSharable($path) { |
|
216 | - $this->checkAvailability(); |
|
217 | - try { |
|
218 | - return parent::isSharable($path); |
|
219 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
220 | - $this->setAvailability(false); |
|
221 | - throw $e; |
|
222 | - } |
|
223 | - } |
|
224 | - |
|
225 | - /** {@inheritdoc} */ |
|
226 | - public function getPermissions($path) { |
|
227 | - $this->checkAvailability(); |
|
228 | - try { |
|
229 | - return parent::getPermissions($path); |
|
230 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
231 | - $this->setAvailability(false); |
|
232 | - throw $e; |
|
233 | - } |
|
234 | - } |
|
235 | - |
|
236 | - /** {@inheritdoc} */ |
|
237 | - public function file_exists($path) { |
|
238 | - if ($path === '') { |
|
239 | - return true; |
|
240 | - } |
|
241 | - $this->checkAvailability(); |
|
242 | - try { |
|
243 | - return parent::file_exists($path); |
|
244 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
245 | - $this->setAvailability(false); |
|
246 | - throw $e; |
|
247 | - } |
|
248 | - } |
|
249 | - |
|
250 | - /** {@inheritdoc} */ |
|
251 | - public function filemtime($path) { |
|
252 | - $this->checkAvailability(); |
|
253 | - try { |
|
254 | - return parent::filemtime($path); |
|
255 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
256 | - $this->setAvailability(false); |
|
257 | - throw $e; |
|
258 | - } |
|
259 | - } |
|
260 | - |
|
261 | - /** {@inheritdoc} */ |
|
262 | - public function file_get_contents($path) { |
|
263 | - $this->checkAvailability(); |
|
264 | - try { |
|
265 | - return parent::file_get_contents($path); |
|
266 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
267 | - $this->setAvailability(false); |
|
268 | - throw $e; |
|
269 | - } |
|
270 | - } |
|
271 | - |
|
272 | - /** {@inheritdoc} */ |
|
273 | - public function file_put_contents($path, $data) { |
|
274 | - $this->checkAvailability(); |
|
275 | - try { |
|
276 | - return parent::file_put_contents($path, $data); |
|
277 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
278 | - $this->setAvailability(false); |
|
279 | - throw $e; |
|
280 | - } |
|
281 | - } |
|
282 | - |
|
283 | - /** {@inheritdoc} */ |
|
284 | - public function unlink($path) { |
|
285 | - $this->checkAvailability(); |
|
286 | - try { |
|
287 | - return parent::unlink($path); |
|
288 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
289 | - $this->setAvailability(false); |
|
290 | - throw $e; |
|
291 | - } |
|
292 | - } |
|
293 | - |
|
294 | - /** {@inheritdoc} */ |
|
295 | - public function rename($path1, $path2) { |
|
296 | - $this->checkAvailability(); |
|
297 | - try { |
|
298 | - return parent::rename($path1, $path2); |
|
299 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
300 | - $this->setAvailability(false); |
|
301 | - throw $e; |
|
302 | - } |
|
303 | - } |
|
304 | - |
|
305 | - /** {@inheritdoc} */ |
|
306 | - public function copy($path1, $path2) { |
|
307 | - $this->checkAvailability(); |
|
308 | - try { |
|
309 | - return parent::copy($path1, $path2); |
|
310 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
311 | - $this->setAvailability(false); |
|
312 | - throw $e; |
|
313 | - } |
|
314 | - } |
|
315 | - |
|
316 | - /** {@inheritdoc} */ |
|
317 | - public function fopen($path, $mode) { |
|
318 | - $this->checkAvailability(); |
|
319 | - try { |
|
320 | - return parent::fopen($path, $mode); |
|
321 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
322 | - $this->setAvailability(false); |
|
323 | - throw $e; |
|
324 | - } |
|
325 | - } |
|
326 | - |
|
327 | - /** {@inheritdoc} */ |
|
328 | - public function getMimeType($path) { |
|
329 | - $this->checkAvailability(); |
|
330 | - try { |
|
331 | - return parent::getMimeType($path); |
|
332 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
333 | - $this->setAvailability(false); |
|
334 | - throw $e; |
|
335 | - } |
|
336 | - } |
|
337 | - |
|
338 | - /** {@inheritdoc} */ |
|
339 | - public function hash($type, $path, $raw = false) { |
|
340 | - $this->checkAvailability(); |
|
341 | - try { |
|
342 | - return parent::hash($type, $path, $raw); |
|
343 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
344 | - $this->setAvailability(false); |
|
345 | - throw $e; |
|
346 | - } |
|
347 | - } |
|
348 | - |
|
349 | - /** {@inheritdoc} */ |
|
350 | - public function free_space($path) { |
|
351 | - $this->checkAvailability(); |
|
352 | - try { |
|
353 | - return parent::free_space($path); |
|
354 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
355 | - $this->setAvailability(false); |
|
356 | - throw $e; |
|
357 | - } |
|
358 | - } |
|
359 | - |
|
360 | - /** {@inheritdoc} */ |
|
361 | - public function search($query) { |
|
362 | - $this->checkAvailability(); |
|
363 | - try { |
|
364 | - return parent::search($query); |
|
365 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
366 | - $this->setAvailability(false); |
|
367 | - throw $e; |
|
368 | - } |
|
369 | - } |
|
370 | - |
|
371 | - /** {@inheritdoc} */ |
|
372 | - public function touch($path, $mtime = null) { |
|
373 | - $this->checkAvailability(); |
|
374 | - try { |
|
375 | - return parent::touch($path, $mtime); |
|
376 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
377 | - $this->setAvailability(false); |
|
378 | - throw $e; |
|
379 | - } |
|
380 | - } |
|
381 | - |
|
382 | - /** {@inheritdoc} */ |
|
383 | - public function getLocalFile($path) { |
|
384 | - $this->checkAvailability(); |
|
385 | - try { |
|
386 | - return parent::getLocalFile($path); |
|
387 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
388 | - $this->setAvailability(false); |
|
389 | - throw $e; |
|
390 | - } |
|
391 | - } |
|
392 | - |
|
393 | - /** {@inheritdoc} */ |
|
394 | - public function hasUpdated($path, $time) { |
|
395 | - $this->checkAvailability(); |
|
396 | - try { |
|
397 | - return parent::hasUpdated($path, $time); |
|
398 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
399 | - $this->setAvailability(false); |
|
400 | - throw $e; |
|
401 | - } |
|
402 | - } |
|
403 | - |
|
404 | - /** {@inheritdoc} */ |
|
405 | - public function getOwner($path) { |
|
406 | - try { |
|
407 | - return parent::getOwner($path); |
|
408 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
409 | - $this->setAvailability(false); |
|
410 | - throw $e; |
|
411 | - } |
|
412 | - } |
|
413 | - |
|
414 | - /** {@inheritdoc} */ |
|
415 | - public function getETag($path) { |
|
416 | - $this->checkAvailability(); |
|
417 | - try { |
|
418 | - return parent::getETag($path); |
|
419 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
420 | - $this->setAvailability(false); |
|
421 | - throw $e; |
|
422 | - } |
|
423 | - } |
|
424 | - |
|
425 | - /** {@inheritdoc} */ |
|
426 | - public function getDirectDownload($path) { |
|
427 | - $this->checkAvailability(); |
|
428 | - try { |
|
429 | - return parent::getDirectDownload($path); |
|
430 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
431 | - $this->setAvailability(false); |
|
432 | - throw $e; |
|
433 | - } |
|
434 | - } |
|
435 | - |
|
436 | - /** {@inheritdoc} */ |
|
437 | - public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) { |
|
438 | - $this->checkAvailability(); |
|
439 | - try { |
|
440 | - return parent::copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); |
|
441 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
442 | - $this->setAvailability(false); |
|
443 | - throw $e; |
|
444 | - } |
|
445 | - } |
|
446 | - |
|
447 | - /** {@inheritdoc} */ |
|
448 | - public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) { |
|
449 | - $this->checkAvailability(); |
|
450 | - try { |
|
451 | - return parent::moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); |
|
452 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
453 | - $this->setAvailability(false); |
|
454 | - throw $e; |
|
455 | - } |
|
456 | - } |
|
457 | - |
|
458 | - /** {@inheritdoc} */ |
|
459 | - public function getMetaData($path) { |
|
460 | - $this->checkAvailability(); |
|
461 | - try { |
|
462 | - return parent::getMetaData($path); |
|
463 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
464 | - $this->setAvailability(false); |
|
465 | - throw $e; |
|
466 | - } |
|
467 | - } |
|
33 | + const RECHECK_TTL_SEC = 600; // 10 minutes |
|
34 | + |
|
35 | + public static function shouldRecheck($availability) { |
|
36 | + if (!$availability['available']) { |
|
37 | + // trigger a recheck if TTL reached |
|
38 | + if ((time() - $availability['last_checked']) > self::RECHECK_TTL_SEC) { |
|
39 | + return true; |
|
40 | + } |
|
41 | + } |
|
42 | + return false; |
|
43 | + } |
|
44 | + |
|
45 | + /** |
|
46 | + * Only called if availability === false |
|
47 | + * |
|
48 | + * @return bool |
|
49 | + */ |
|
50 | + private function updateAvailability() { |
|
51 | + // reset availability to false so that multiple requests don't recheck concurrently |
|
52 | + $this->setAvailability(false); |
|
53 | + try { |
|
54 | + $result = $this->test(); |
|
55 | + } catch (\Exception $e) { |
|
56 | + $result = false; |
|
57 | + } |
|
58 | + $this->setAvailability($result); |
|
59 | + return $result; |
|
60 | + } |
|
61 | + |
|
62 | + /** |
|
63 | + * @return bool |
|
64 | + */ |
|
65 | + private function isAvailable() { |
|
66 | + $availability = $this->getAvailability(); |
|
67 | + if (self::shouldRecheck($availability)) { |
|
68 | + return $this->updateAvailability(); |
|
69 | + } |
|
70 | + return $availability['available']; |
|
71 | + } |
|
72 | + |
|
73 | + /** |
|
74 | + * @throws \OCP\Files\StorageNotAvailableException |
|
75 | + */ |
|
76 | + private function checkAvailability() { |
|
77 | + if (!$this->isAvailable()) { |
|
78 | + throw new \OCP\Files\StorageNotAvailableException(); |
|
79 | + } |
|
80 | + } |
|
81 | + |
|
82 | + /** {@inheritdoc} */ |
|
83 | + public function mkdir($path) { |
|
84 | + $this->checkAvailability(); |
|
85 | + try { |
|
86 | + return parent::mkdir($path); |
|
87 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
88 | + $this->setAvailability(false); |
|
89 | + throw $e; |
|
90 | + } |
|
91 | + } |
|
92 | + |
|
93 | + /** {@inheritdoc} */ |
|
94 | + public function rmdir($path) { |
|
95 | + $this->checkAvailability(); |
|
96 | + try { |
|
97 | + return parent::rmdir($path); |
|
98 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
99 | + $this->setAvailability(false); |
|
100 | + throw $e; |
|
101 | + } |
|
102 | + } |
|
103 | + |
|
104 | + /** {@inheritdoc} */ |
|
105 | + public function opendir($path) { |
|
106 | + $this->checkAvailability(); |
|
107 | + try { |
|
108 | + return parent::opendir($path); |
|
109 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
110 | + $this->setAvailability(false); |
|
111 | + throw $e; |
|
112 | + } |
|
113 | + } |
|
114 | + |
|
115 | + /** {@inheritdoc} */ |
|
116 | + public function is_dir($path) { |
|
117 | + $this->checkAvailability(); |
|
118 | + try { |
|
119 | + return parent::is_dir($path); |
|
120 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
121 | + $this->setAvailability(false); |
|
122 | + throw $e; |
|
123 | + } |
|
124 | + } |
|
125 | + |
|
126 | + /** {@inheritdoc} */ |
|
127 | + public function is_file($path) { |
|
128 | + $this->checkAvailability(); |
|
129 | + try { |
|
130 | + return parent::is_file($path); |
|
131 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
132 | + $this->setAvailability(false); |
|
133 | + throw $e; |
|
134 | + } |
|
135 | + } |
|
136 | + |
|
137 | + /** {@inheritdoc} */ |
|
138 | + public function stat($path) { |
|
139 | + $this->checkAvailability(); |
|
140 | + try { |
|
141 | + return parent::stat($path); |
|
142 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
143 | + $this->setAvailability(false); |
|
144 | + throw $e; |
|
145 | + } |
|
146 | + } |
|
147 | + |
|
148 | + /** {@inheritdoc} */ |
|
149 | + public function filetype($path) { |
|
150 | + $this->checkAvailability(); |
|
151 | + try { |
|
152 | + return parent::filetype($path); |
|
153 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
154 | + $this->setAvailability(false); |
|
155 | + throw $e; |
|
156 | + } |
|
157 | + } |
|
158 | + |
|
159 | + /** {@inheritdoc} */ |
|
160 | + public function filesize($path) { |
|
161 | + $this->checkAvailability(); |
|
162 | + try { |
|
163 | + return parent::filesize($path); |
|
164 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
165 | + $this->setAvailability(false); |
|
166 | + throw $e; |
|
167 | + } |
|
168 | + } |
|
169 | + |
|
170 | + /** {@inheritdoc} */ |
|
171 | + public function isCreatable($path) { |
|
172 | + $this->checkAvailability(); |
|
173 | + try { |
|
174 | + return parent::isCreatable($path); |
|
175 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
176 | + $this->setAvailability(false); |
|
177 | + throw $e; |
|
178 | + } |
|
179 | + } |
|
180 | + |
|
181 | + /** {@inheritdoc} */ |
|
182 | + public function isReadable($path) { |
|
183 | + $this->checkAvailability(); |
|
184 | + try { |
|
185 | + return parent::isReadable($path); |
|
186 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
187 | + $this->setAvailability(false); |
|
188 | + throw $e; |
|
189 | + } |
|
190 | + } |
|
191 | + |
|
192 | + /** {@inheritdoc} */ |
|
193 | + public function isUpdatable($path) { |
|
194 | + $this->checkAvailability(); |
|
195 | + try { |
|
196 | + return parent::isUpdatable($path); |
|
197 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
198 | + $this->setAvailability(false); |
|
199 | + throw $e; |
|
200 | + } |
|
201 | + } |
|
202 | + |
|
203 | + /** {@inheritdoc} */ |
|
204 | + public function isDeletable($path) { |
|
205 | + $this->checkAvailability(); |
|
206 | + try { |
|
207 | + return parent::isDeletable($path); |
|
208 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
209 | + $this->setAvailability(false); |
|
210 | + throw $e; |
|
211 | + } |
|
212 | + } |
|
213 | + |
|
214 | + /** {@inheritdoc} */ |
|
215 | + public function isSharable($path) { |
|
216 | + $this->checkAvailability(); |
|
217 | + try { |
|
218 | + return parent::isSharable($path); |
|
219 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
220 | + $this->setAvailability(false); |
|
221 | + throw $e; |
|
222 | + } |
|
223 | + } |
|
224 | + |
|
225 | + /** {@inheritdoc} */ |
|
226 | + public function getPermissions($path) { |
|
227 | + $this->checkAvailability(); |
|
228 | + try { |
|
229 | + return parent::getPermissions($path); |
|
230 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
231 | + $this->setAvailability(false); |
|
232 | + throw $e; |
|
233 | + } |
|
234 | + } |
|
235 | + |
|
236 | + /** {@inheritdoc} */ |
|
237 | + public function file_exists($path) { |
|
238 | + if ($path === '') { |
|
239 | + return true; |
|
240 | + } |
|
241 | + $this->checkAvailability(); |
|
242 | + try { |
|
243 | + return parent::file_exists($path); |
|
244 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
245 | + $this->setAvailability(false); |
|
246 | + throw $e; |
|
247 | + } |
|
248 | + } |
|
249 | + |
|
250 | + /** {@inheritdoc} */ |
|
251 | + public function filemtime($path) { |
|
252 | + $this->checkAvailability(); |
|
253 | + try { |
|
254 | + return parent::filemtime($path); |
|
255 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
256 | + $this->setAvailability(false); |
|
257 | + throw $e; |
|
258 | + } |
|
259 | + } |
|
260 | + |
|
261 | + /** {@inheritdoc} */ |
|
262 | + public function file_get_contents($path) { |
|
263 | + $this->checkAvailability(); |
|
264 | + try { |
|
265 | + return parent::file_get_contents($path); |
|
266 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
267 | + $this->setAvailability(false); |
|
268 | + throw $e; |
|
269 | + } |
|
270 | + } |
|
271 | + |
|
272 | + /** {@inheritdoc} */ |
|
273 | + public function file_put_contents($path, $data) { |
|
274 | + $this->checkAvailability(); |
|
275 | + try { |
|
276 | + return parent::file_put_contents($path, $data); |
|
277 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
278 | + $this->setAvailability(false); |
|
279 | + throw $e; |
|
280 | + } |
|
281 | + } |
|
282 | + |
|
283 | + /** {@inheritdoc} */ |
|
284 | + public function unlink($path) { |
|
285 | + $this->checkAvailability(); |
|
286 | + try { |
|
287 | + return parent::unlink($path); |
|
288 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
289 | + $this->setAvailability(false); |
|
290 | + throw $e; |
|
291 | + } |
|
292 | + } |
|
293 | + |
|
294 | + /** {@inheritdoc} */ |
|
295 | + public function rename($path1, $path2) { |
|
296 | + $this->checkAvailability(); |
|
297 | + try { |
|
298 | + return parent::rename($path1, $path2); |
|
299 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
300 | + $this->setAvailability(false); |
|
301 | + throw $e; |
|
302 | + } |
|
303 | + } |
|
304 | + |
|
305 | + /** {@inheritdoc} */ |
|
306 | + public function copy($path1, $path2) { |
|
307 | + $this->checkAvailability(); |
|
308 | + try { |
|
309 | + return parent::copy($path1, $path2); |
|
310 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
311 | + $this->setAvailability(false); |
|
312 | + throw $e; |
|
313 | + } |
|
314 | + } |
|
315 | + |
|
316 | + /** {@inheritdoc} */ |
|
317 | + public function fopen($path, $mode) { |
|
318 | + $this->checkAvailability(); |
|
319 | + try { |
|
320 | + return parent::fopen($path, $mode); |
|
321 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
322 | + $this->setAvailability(false); |
|
323 | + throw $e; |
|
324 | + } |
|
325 | + } |
|
326 | + |
|
327 | + /** {@inheritdoc} */ |
|
328 | + public function getMimeType($path) { |
|
329 | + $this->checkAvailability(); |
|
330 | + try { |
|
331 | + return parent::getMimeType($path); |
|
332 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
333 | + $this->setAvailability(false); |
|
334 | + throw $e; |
|
335 | + } |
|
336 | + } |
|
337 | + |
|
338 | + /** {@inheritdoc} */ |
|
339 | + public function hash($type, $path, $raw = false) { |
|
340 | + $this->checkAvailability(); |
|
341 | + try { |
|
342 | + return parent::hash($type, $path, $raw); |
|
343 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
344 | + $this->setAvailability(false); |
|
345 | + throw $e; |
|
346 | + } |
|
347 | + } |
|
348 | + |
|
349 | + /** {@inheritdoc} */ |
|
350 | + public function free_space($path) { |
|
351 | + $this->checkAvailability(); |
|
352 | + try { |
|
353 | + return parent::free_space($path); |
|
354 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
355 | + $this->setAvailability(false); |
|
356 | + throw $e; |
|
357 | + } |
|
358 | + } |
|
359 | + |
|
360 | + /** {@inheritdoc} */ |
|
361 | + public function search($query) { |
|
362 | + $this->checkAvailability(); |
|
363 | + try { |
|
364 | + return parent::search($query); |
|
365 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
366 | + $this->setAvailability(false); |
|
367 | + throw $e; |
|
368 | + } |
|
369 | + } |
|
370 | + |
|
371 | + /** {@inheritdoc} */ |
|
372 | + public function touch($path, $mtime = null) { |
|
373 | + $this->checkAvailability(); |
|
374 | + try { |
|
375 | + return parent::touch($path, $mtime); |
|
376 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
377 | + $this->setAvailability(false); |
|
378 | + throw $e; |
|
379 | + } |
|
380 | + } |
|
381 | + |
|
382 | + /** {@inheritdoc} */ |
|
383 | + public function getLocalFile($path) { |
|
384 | + $this->checkAvailability(); |
|
385 | + try { |
|
386 | + return parent::getLocalFile($path); |
|
387 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
388 | + $this->setAvailability(false); |
|
389 | + throw $e; |
|
390 | + } |
|
391 | + } |
|
392 | + |
|
393 | + /** {@inheritdoc} */ |
|
394 | + public function hasUpdated($path, $time) { |
|
395 | + $this->checkAvailability(); |
|
396 | + try { |
|
397 | + return parent::hasUpdated($path, $time); |
|
398 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
399 | + $this->setAvailability(false); |
|
400 | + throw $e; |
|
401 | + } |
|
402 | + } |
|
403 | + |
|
404 | + /** {@inheritdoc} */ |
|
405 | + public function getOwner($path) { |
|
406 | + try { |
|
407 | + return parent::getOwner($path); |
|
408 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
409 | + $this->setAvailability(false); |
|
410 | + throw $e; |
|
411 | + } |
|
412 | + } |
|
413 | + |
|
414 | + /** {@inheritdoc} */ |
|
415 | + public function getETag($path) { |
|
416 | + $this->checkAvailability(); |
|
417 | + try { |
|
418 | + return parent::getETag($path); |
|
419 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
420 | + $this->setAvailability(false); |
|
421 | + throw $e; |
|
422 | + } |
|
423 | + } |
|
424 | + |
|
425 | + /** {@inheritdoc} */ |
|
426 | + public function getDirectDownload($path) { |
|
427 | + $this->checkAvailability(); |
|
428 | + try { |
|
429 | + return parent::getDirectDownload($path); |
|
430 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
431 | + $this->setAvailability(false); |
|
432 | + throw $e; |
|
433 | + } |
|
434 | + } |
|
435 | + |
|
436 | + /** {@inheritdoc} */ |
|
437 | + public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) { |
|
438 | + $this->checkAvailability(); |
|
439 | + try { |
|
440 | + return parent::copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); |
|
441 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
442 | + $this->setAvailability(false); |
|
443 | + throw $e; |
|
444 | + } |
|
445 | + } |
|
446 | + |
|
447 | + /** {@inheritdoc} */ |
|
448 | + public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) { |
|
449 | + $this->checkAvailability(); |
|
450 | + try { |
|
451 | + return parent::moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); |
|
452 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
453 | + $this->setAvailability(false); |
|
454 | + throw $e; |
|
455 | + } |
|
456 | + } |
|
457 | + |
|
458 | + /** {@inheritdoc} */ |
|
459 | + public function getMetaData($path) { |
|
460 | + $this->checkAvailability(); |
|
461 | + try { |
|
462 | + return parent::getMetaData($path); |
|
463 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
464 | + $this->setAvailability(false); |
|
465 | + throw $e; |
|
466 | + } |
|
467 | + } |
|
468 | 468 | } |
@@ -30,114 +30,114 @@ |
||
30 | 30 | * @since 8.0.0 |
31 | 31 | */ |
32 | 32 | interface IDateTimeFormatter { |
33 | - /** |
|
34 | - * Formats the date of the given timestamp |
|
35 | - * |
|
36 | - * @param int|\DateTime $timestamp |
|
37 | - * @param string $format Either 'full', 'long', 'medium' or 'short' |
|
38 | - * full: e.g. 'EEEE, MMMM d, y' => 'Wednesday, August 20, 2014' |
|
39 | - * long: e.g. 'MMMM d, y' => 'August 20, 2014' |
|
40 | - * medium: e.g. 'MMM d, y' => 'Aug 20, 2014' |
|
41 | - * short: e.g. 'M/d/yy' => '8/20/14' |
|
42 | - * The exact format is dependent on the language |
|
43 | - * @param \DateTimeZone|null $timeZone The timezone to use |
|
44 | - * @param \OCP\IL10N|null $l The locale to use |
|
45 | - * @return string Formatted date string |
|
46 | - * @since 8.0.0 |
|
47 | - */ |
|
48 | - public function formatDate($timestamp, $format = 'long', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null); |
|
33 | + /** |
|
34 | + * Formats the date of the given timestamp |
|
35 | + * |
|
36 | + * @param int|\DateTime $timestamp |
|
37 | + * @param string $format Either 'full', 'long', 'medium' or 'short' |
|
38 | + * full: e.g. 'EEEE, MMMM d, y' => 'Wednesday, August 20, 2014' |
|
39 | + * long: e.g. 'MMMM d, y' => 'August 20, 2014' |
|
40 | + * medium: e.g. 'MMM d, y' => 'Aug 20, 2014' |
|
41 | + * short: e.g. 'M/d/yy' => '8/20/14' |
|
42 | + * The exact format is dependent on the language |
|
43 | + * @param \DateTimeZone|null $timeZone The timezone to use |
|
44 | + * @param \OCP\IL10N|null $l The locale to use |
|
45 | + * @return string Formatted date string |
|
46 | + * @since 8.0.0 |
|
47 | + */ |
|
48 | + public function formatDate($timestamp, $format = 'long', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null); |
|
49 | 49 | |
50 | - /** |
|
51 | - * Formats the date of the given timestamp |
|
52 | - * |
|
53 | - * @param int|\DateTime $timestamp |
|
54 | - * @param string $format Either 'full', 'long', 'medium' or 'short' |
|
55 | - * full: e.g. 'EEEE, MMMM d, y' => 'Wednesday, August 20, 2014' |
|
56 | - * long: e.g. 'MMMM d, y' => 'August 20, 2014' |
|
57 | - * medium: e.g. 'MMM d, y' => 'Aug 20, 2014' |
|
58 | - * short: e.g. 'M/d/yy' => '8/20/14' |
|
59 | - * The exact format is dependent on the language |
|
60 | - * Uses 'Today', 'Yesterday' and 'Tomorrow' when applicable |
|
61 | - * @param \DateTimeZone|null $timeZone The timezone to use |
|
62 | - * @param \OCP\IL10N|null $l The locale to use |
|
63 | - * @return string Formatted relative date string |
|
64 | - * @since 8.0.0 |
|
65 | - */ |
|
66 | - public function formatDateRelativeDay($timestamp, $format = 'long', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null); |
|
50 | + /** |
|
51 | + * Formats the date of the given timestamp |
|
52 | + * |
|
53 | + * @param int|\DateTime $timestamp |
|
54 | + * @param string $format Either 'full', 'long', 'medium' or 'short' |
|
55 | + * full: e.g. 'EEEE, MMMM d, y' => 'Wednesday, August 20, 2014' |
|
56 | + * long: e.g. 'MMMM d, y' => 'August 20, 2014' |
|
57 | + * medium: e.g. 'MMM d, y' => 'Aug 20, 2014' |
|
58 | + * short: e.g. 'M/d/yy' => '8/20/14' |
|
59 | + * The exact format is dependent on the language |
|
60 | + * Uses 'Today', 'Yesterday' and 'Tomorrow' when applicable |
|
61 | + * @param \DateTimeZone|null $timeZone The timezone to use |
|
62 | + * @param \OCP\IL10N|null $l The locale to use |
|
63 | + * @return string Formatted relative date string |
|
64 | + * @since 8.0.0 |
|
65 | + */ |
|
66 | + public function formatDateRelativeDay($timestamp, $format = 'long', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null); |
|
67 | 67 | |
68 | - /** |
|
69 | - * Gives the relative date of the timestamp |
|
70 | - * Only works for past dates |
|
71 | - * |
|
72 | - * @param int|\DateTime $timestamp |
|
73 | - * @param int|\DateTime|null $baseTimestamp Timestamp to compare $timestamp against, defaults to current time |
|
74 | - * @param \OCP\IL10N|null $l The locale to use |
|
75 | - * @return string Dates returned are: |
|
76 | - * < 1 month => Today, Yesterday, n days ago |
|
77 | - * < 13 month => last month, n months ago |
|
78 | - * >= 13 month => last year, n years ago |
|
79 | - * @since 8.0.0 |
|
80 | - */ |
|
81 | - public function formatDateSpan($timestamp, $baseTimestamp = null, \OCP\IL10N $l = null); |
|
68 | + /** |
|
69 | + * Gives the relative date of the timestamp |
|
70 | + * Only works for past dates |
|
71 | + * |
|
72 | + * @param int|\DateTime $timestamp |
|
73 | + * @param int|\DateTime|null $baseTimestamp Timestamp to compare $timestamp against, defaults to current time |
|
74 | + * @param \OCP\IL10N|null $l The locale to use |
|
75 | + * @return string Dates returned are: |
|
76 | + * < 1 month => Today, Yesterday, n days ago |
|
77 | + * < 13 month => last month, n months ago |
|
78 | + * >= 13 month => last year, n years ago |
|
79 | + * @since 8.0.0 |
|
80 | + */ |
|
81 | + public function formatDateSpan($timestamp, $baseTimestamp = null, \OCP\IL10N $l = null); |
|
82 | 82 | |
83 | - /** |
|
84 | - * Formats the time of the given timestamp |
|
85 | - * |
|
86 | - * @param int|\DateTime $timestamp |
|
87 | - * @param string $format Either 'full', 'long', 'medium' or 'short' |
|
88 | - * full: e.g. 'h:mm:ss a zzzz' => '11:42:13 AM GMT+0:00' |
|
89 | - * long: e.g. 'h:mm:ss a z' => '11:42:13 AM GMT' |
|
90 | - * medium: e.g. 'h:mm:ss a' => '11:42:13 AM' |
|
91 | - * short: e.g. 'h:mm a' => '11:42 AM' |
|
92 | - * The exact format is dependent on the language |
|
93 | - * @param \DateTimeZone|null $timeZone The timezone to use |
|
94 | - * @param \OCP\IL10N|null $l The locale to use |
|
95 | - * @return string Formatted time string |
|
96 | - * @since 8.0.0 |
|
97 | - */ |
|
98 | - public function formatTime($timestamp, $format = 'medium', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null); |
|
83 | + /** |
|
84 | + * Formats the time of the given timestamp |
|
85 | + * |
|
86 | + * @param int|\DateTime $timestamp |
|
87 | + * @param string $format Either 'full', 'long', 'medium' or 'short' |
|
88 | + * full: e.g. 'h:mm:ss a zzzz' => '11:42:13 AM GMT+0:00' |
|
89 | + * long: e.g. 'h:mm:ss a z' => '11:42:13 AM GMT' |
|
90 | + * medium: e.g. 'h:mm:ss a' => '11:42:13 AM' |
|
91 | + * short: e.g. 'h:mm a' => '11:42 AM' |
|
92 | + * The exact format is dependent on the language |
|
93 | + * @param \DateTimeZone|null $timeZone The timezone to use |
|
94 | + * @param \OCP\IL10N|null $l The locale to use |
|
95 | + * @return string Formatted time string |
|
96 | + * @since 8.0.0 |
|
97 | + */ |
|
98 | + public function formatTime($timestamp, $format = 'medium', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null); |
|
99 | 99 | |
100 | - /** |
|
101 | - * Gives the relative past time of the timestamp |
|
102 | - * |
|
103 | - * @param int|\DateTime $timestamp |
|
104 | - * @param int|\DateTime|null $baseTimestamp Timestamp to compare $timestamp against, defaults to current time |
|
105 | - * @param \OCP\IL10N|null $l The locale to use |
|
106 | - * @return string Dates returned are: |
|
107 | - * < 60 sec => seconds ago |
|
108 | - * < 1 hour => n minutes ago |
|
109 | - * < 1 day => n hours ago |
|
110 | - * < 1 month => Yesterday, n days ago |
|
111 | - * < 13 month => last month, n months ago |
|
112 | - * >= 13 month => last year, n years ago |
|
113 | - * @since 8.0.0 |
|
114 | - */ |
|
115 | - public function formatTimeSpan($timestamp, $baseTimestamp = null, \OCP\IL10N $l = null); |
|
100 | + /** |
|
101 | + * Gives the relative past time of the timestamp |
|
102 | + * |
|
103 | + * @param int|\DateTime $timestamp |
|
104 | + * @param int|\DateTime|null $baseTimestamp Timestamp to compare $timestamp against, defaults to current time |
|
105 | + * @param \OCP\IL10N|null $l The locale to use |
|
106 | + * @return string Dates returned are: |
|
107 | + * < 60 sec => seconds ago |
|
108 | + * < 1 hour => n minutes ago |
|
109 | + * < 1 day => n hours ago |
|
110 | + * < 1 month => Yesterday, n days ago |
|
111 | + * < 13 month => last month, n months ago |
|
112 | + * >= 13 month => last year, n years ago |
|
113 | + * @since 8.0.0 |
|
114 | + */ |
|
115 | + public function formatTimeSpan($timestamp, $baseTimestamp = null, \OCP\IL10N $l = null); |
|
116 | 116 | |
117 | - /** |
|
118 | - * Formats the date and time of the given timestamp |
|
119 | - * |
|
120 | - * @param int|\DateTime $timestamp |
|
121 | - * @param string $formatDate See formatDate() for description |
|
122 | - * @param string $formatTime See formatTime() for description |
|
123 | - * @param \DateTimeZone|null $timeZone The timezone to use |
|
124 | - * @param \OCP\IL10N|null $l The locale to use |
|
125 | - * @return string Formatted date and time string |
|
126 | - * @since 8.0.0 |
|
127 | - */ |
|
128 | - public function formatDateTime($timestamp, $formatDate = 'long', $formatTime = 'medium', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null); |
|
117 | + /** |
|
118 | + * Formats the date and time of the given timestamp |
|
119 | + * |
|
120 | + * @param int|\DateTime $timestamp |
|
121 | + * @param string $formatDate See formatDate() for description |
|
122 | + * @param string $formatTime See formatTime() for description |
|
123 | + * @param \DateTimeZone|null $timeZone The timezone to use |
|
124 | + * @param \OCP\IL10N|null $l The locale to use |
|
125 | + * @return string Formatted date and time string |
|
126 | + * @since 8.0.0 |
|
127 | + */ |
|
128 | + public function formatDateTime($timestamp, $formatDate = 'long', $formatTime = 'medium', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null); |
|
129 | 129 | |
130 | - /** |
|
131 | - * Formats the date and time of the given timestamp |
|
132 | - * |
|
133 | - * @param int|\DateTime $timestamp |
|
134 | - * @param string $formatDate See formatDate() for description |
|
135 | - * Uses 'Today', 'Yesterday' and 'Tomorrow' when applicable |
|
136 | - * @param string $formatTime See formatTime() for description |
|
137 | - * @param \DateTimeZone|null $timeZone The timezone to use |
|
138 | - * @param \OCP\IL10N|null $l The locale to use |
|
139 | - * @return string Formatted relative date and time string |
|
140 | - * @since 8.0.0 |
|
141 | - */ |
|
142 | - public function formatDateTimeRelativeDay($timestamp, $formatDate = 'long', $formatTime = 'medium', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null); |
|
130 | + /** |
|
131 | + * Formats the date and time of the given timestamp |
|
132 | + * |
|
133 | + * @param int|\DateTime $timestamp |
|
134 | + * @param string $formatDate See formatDate() for description |
|
135 | + * Uses 'Today', 'Yesterday' and 'Tomorrow' when applicable |
|
136 | + * @param string $formatTime See formatTime() for description |
|
137 | + * @param \DateTimeZone|null $timeZone The timezone to use |
|
138 | + * @param \OCP\IL10N|null $l The locale to use |
|
139 | + * @return string Formatted relative date and time string |
|
140 | + * @since 8.0.0 |
|
141 | + */ |
|
142 | + public function formatDateTimeRelativeDay($timestamp, $formatDate = 'long', $formatTime = 'medium', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null); |
|
143 | 143 | } |
@@ -30,39 +30,39 @@ |
||
30 | 30 | */ |
31 | 31 | abstract class PagedProvider extends Provider { |
32 | 32 | |
33 | - /** |
|
34 | - * show all results |
|
35 | - * @since 8.0.0 |
|
36 | - */ |
|
37 | - const SIZE_ALL = 0; |
|
33 | + /** |
|
34 | + * show all results |
|
35 | + * @since 8.0.0 |
|
36 | + */ |
|
37 | + const SIZE_ALL = 0; |
|
38 | 38 | |
39 | - /** |
|
40 | - * Constructor |
|
41 | - * @param array $options |
|
42 | - * @since 8.0.0 |
|
43 | - */ |
|
44 | - public function __construct($options) { |
|
45 | - parent::__construct($options); |
|
46 | - } |
|
39 | + /** |
|
40 | + * Constructor |
|
41 | + * @param array $options |
|
42 | + * @since 8.0.0 |
|
43 | + */ |
|
44 | + public function __construct($options) { |
|
45 | + parent::__construct($options); |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * Search for $query |
|
50 | - * @param string $query |
|
51 | - * @return array An array of OCP\Search\Result's |
|
52 | - * @since 8.0.0 |
|
53 | - */ |
|
54 | - public function search($query) { |
|
55 | - // old apps might assume they get all results, so we use SIZE_ALL |
|
56 | - return $this->searchPaged($query, 1, self::SIZE_ALL); |
|
57 | - } |
|
48 | + /** |
|
49 | + * Search for $query |
|
50 | + * @param string $query |
|
51 | + * @return array An array of OCP\Search\Result's |
|
52 | + * @since 8.0.0 |
|
53 | + */ |
|
54 | + public function search($query) { |
|
55 | + // old apps might assume they get all results, so we use SIZE_ALL |
|
56 | + return $this->searchPaged($query, 1, self::SIZE_ALL); |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * Search for $query |
|
61 | - * @param string $query |
|
62 | - * @param int $page pages start at page 1 |
|
63 | - * @param int $size 0 = SIZE_ALL |
|
64 | - * @return array An array of OCP\Search\Result's |
|
65 | - * @since 8.0.0 |
|
66 | - */ |
|
67 | - abstract public function searchPaged($query, $page, $size); |
|
59 | + /** |
|
60 | + * Search for $query |
|
61 | + * @param string $query |
|
62 | + * @param int $page pages start at page 1 |
|
63 | + * @param int $size 0 = SIZE_ALL |
|
64 | + * @return array An array of OCP\Search\Result's |
|
65 | + * @since 8.0.0 |
|
66 | + */ |
|
67 | + abstract public function searchPaged($query, $page, $size); |
|
68 | 68 | } |
@@ -31,18 +31,18 @@ |
||
31 | 31 | */ |
32 | 32 | class GenericShareException extends HintException { |
33 | 33 | |
34 | - /** |
|
35 | - * @param string $message |
|
36 | - * @param string $hint |
|
37 | - * @param int $code |
|
38 | - * @param \Exception|null $previous |
|
39 | - * @since 9.0.0 |
|
40 | - */ |
|
41 | - public function __construct($message = '', $hint = '', $code = 0, \Exception $previous = null) { |
|
42 | - if (empty($message)) { |
|
43 | - $message = 'There was an error retrieving the share. Maybe the link is wrong, it was unshared, or it was deleted.'; |
|
44 | - } |
|
45 | - parent::__construct($message, $hint, $code, $previous); |
|
46 | - } |
|
34 | + /** |
|
35 | + * @param string $message |
|
36 | + * @param string $hint |
|
37 | + * @param int $code |
|
38 | + * @param \Exception|null $previous |
|
39 | + * @since 9.0.0 |
|
40 | + */ |
|
41 | + public function __construct($message = '', $hint = '', $code = 0, \Exception $previous = null) { |
|
42 | + if (empty($message)) { |
|
43 | + $message = 'There was an error retrieving the share. Maybe the link is wrong, it was unshared, or it was deleted.'; |
|
44 | + } |
|
45 | + parent::__construct($message, $hint, $code, $previous); |
|
46 | + } |
|
47 | 47 | |
48 | 48 | } |