1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author Thomas Müller <[email protected]> |
4
|
|
|
* @copyright Copyright (c) 2018, ownCloud GmbH |
5
|
|
|
* @license AGPL-3.0 |
6
|
|
|
* |
7
|
|
|
* This code is free software: you can redistribute it and/or modify |
8
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
9
|
|
|
* as published by the Free Software Foundation. |
10
|
|
|
* |
11
|
|
|
* This program is distributed in the hope that it will be useful, |
12
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14
|
|
|
* GNU Affero General Public License for more details. |
15
|
|
|
* |
16
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
17
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
namespace OC\Lock\Persistent; |
21
|
|
|
|
22
|
|
|
use OCP\AppFramework\Db\Entity; |
23
|
|
|
use OCP\Lock\Persistent\ILock; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Class Lock |
27
|
|
|
* |
28
|
|
|
* @method string getTokenHash() |
29
|
|
|
* @method string getPath() |
30
|
|
|
* @method string getUriV1() |
31
|
|
|
* @method string getUriV2() |
32
|
|
|
* @method string getOwnerAccountId() |
33
|
|
|
* |
34
|
|
|
* @method setFileId(int $fileId) |
35
|
|
|
* @method setCreatedAt(int $timestamp) |
36
|
|
|
* @method setTimeout(int $timeout) |
37
|
|
|
* @method setScope(int $scope) |
38
|
|
|
* @method setDepth(int $depth) |
39
|
|
|
* |
40
|
|
|
* @package OC\Lock\Persistent |
41
|
|
|
*/ |
42
|
|
|
class Lock extends Entity implements ILock { |
43
|
|
|
|
44
|
|
|
/** @var int BIGINT - foreign key to oc_filecache.fileid */ |
45
|
|
|
protected $fileId; |
46
|
|
|
/** @var string - plain text field as transmitted by clients */ |
47
|
|
|
protected $owner; |
48
|
|
|
/** @var int - seconds of lock life time */ |
49
|
|
|
protected $timeout; |
50
|
|
|
/** @var int - unix timestamp when lock was created */ |
51
|
|
|
protected $createdAt; |
52
|
|
|
/** @var string - uuid in WebDAV */ |
53
|
|
|
protected $token; |
54
|
|
|
/** @var string - md5 of token */ |
55
|
|
|
protected $tokenHash; |
56
|
|
|
/** @var int - LOCK_SCOPE_EXCLUSIVE or LOCK_SCOPE_SHARED */ |
57
|
|
|
protected $scope; |
58
|
|
|
/** @var int: 0, 1 or infinite */ |
59
|
|
|
protected $depth; |
60
|
|
|
/** @var int - foreign key zu oc_account.id */ |
61
|
|
|
protected $ownerAccountId; |
62
|
|
|
|
63
|
|
|
/** @var string - joined with oc_filecache */ |
64
|
|
|
protected $path; |
65
|
|
|
/** @var string - computed value */ |
66
|
|
|
protected $globalUserId; |
67
|
|
|
/** @var string - computed value */ |
68
|
|
|
protected $globalFileName; |
69
|
|
|
|
70
|
|
|
public function __construct() { |
71
|
|
|
$this->addType('fileId', 'integer'); |
72
|
|
|
$this->addType('timeout', 'integer'); |
73
|
|
|
$this->addType('createdAt', 'integer'); |
74
|
|
|
$this->addType('scope', 'integer'); |
75
|
|
|
$this->addType('depth', 'integer'); |
76
|
|
|
$this->addType('ownerAccountId', 'integer'); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @param $token |
81
|
|
|
*/ |
82
|
|
|
public function setToken($token) { |
83
|
|
|
parent::setter('token', [$token]); |
|
|
|
|
84
|
|
|
parent::setter('tokenHash', [\md5($token)]); |
|
|
|
|
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Return the owner of the lock - plain text field as transmitted by clients |
89
|
|
|
* |
90
|
|
|
* @return string |
91
|
|
|
* @since 11.0.0 |
92
|
|
|
*/ |
93
|
|
|
public function getOwner(): ?string { |
94
|
|
|
return parent::getOwner(); |
|
|
|
|
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* Foreign key to oc_filecache.fileid |
99
|
|
|
* |
100
|
|
|
* @return int |
101
|
|
|
* @since 11.0.0 |
102
|
|
|
*/ |
103
|
|
|
public function getFileId(): int { |
104
|
|
|
return parent::getFileId(); |
|
|
|
|
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Seconds of lock life time |
109
|
|
|
* |
110
|
|
|
* @return int |
111
|
|
|
* @since 11.0.0 |
112
|
|
|
*/ |
113
|
|
|
public function getTimeout(): int { |
114
|
|
|
return parent::getTimeout(); |
|
|
|
|
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* Unix timestamp when lock was created |
119
|
|
|
* |
120
|
|
|
* @return mixed |
121
|
|
|
* @since 11.0.0 |
122
|
|
|
*/ |
123
|
|
|
public function getCreatedAt(): int { |
124
|
|
|
return parent::getCreatedAt(); |
|
|
|
|
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* Token to identify the lock - uuid usually |
129
|
|
|
* |
130
|
|
|
* @return string |
131
|
|
|
* @since 11.0.0 |
132
|
|
|
*/ |
133
|
|
|
public function getToken(): string { |
134
|
|
|
return parent::getToken(); |
|
|
|
|
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* Either shared lock or exclusive lock |
139
|
|
|
* |
140
|
|
|
* @return int |
141
|
|
|
* @since 11.0.0 |
142
|
|
|
*/ |
143
|
|
|
public function getScope(): int { |
144
|
|
|
return parent::getScope(); |
|
|
|
|
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* Depth as used in WebDAV: 0, 1 or infinite |
149
|
|
|
* |
150
|
|
|
* @return int |
151
|
|
|
* @since 11.0.0 |
152
|
|
|
*/ |
153
|
|
|
public function getDepth(): int { |
154
|
|
|
return parent::getDepth(); |
|
|
|
|
155
|
|
|
} |
156
|
|
|
} |
157
|
|
|
|
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()
method in theSon
calls the wrong method in the parent class.