Skip to content

Commit 7cd3cdd

Browse files
authored
Merge pull request #66021 from nextcloud/backport/65922/stable34
[stable34] fix(since): Ensure provided since version is from the current branch
2 parents 16d0673 + 5d62489 commit 7cd3cdd

16 files changed

Lines changed: 82 additions & 39 deletions

‎build/psalm/OcpSinceChecker.php‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ private static function checkClassComment(ClassLike $stmt, FileSource $statement
140140
)
141141
);
142142
}
143+
foreach ($parsedDocblock->tags['since'] ?? [] as $since) {
144+
self::checkSinceIsReleasable(trim($since), $statementsSource, $stmt);
145+
}
143146

144147
if (isset($parsedDocblock->tags['depreacted'])) {
145148
IssueBuffer::maybeAdd(
@@ -184,6 +187,9 @@ private static function checkStatementComment(Stmt $stmt, FileSource $statements
184187
)
185188
);
186189
}
190+
foreach ($parsedDocblock->tags['since'] ?? [] as $since) {
191+
self::checkSinceIsReleasable(trim($since), $statementsSource, $stmt);
192+
}
187193

188194
if (isset($parsedDocblock->tags['depreacted'])) {
189195
IssueBuffer::maybeAdd(
@@ -213,9 +219,46 @@ private static function checkAttributeHasValidSinceVersion(\PhpParser\Node\Attri
213219
new CodeLocation($statementsSource, $stmt)
214220
)
215221
);
222+
} else {
223+
self::checkSinceIsReleasable($arg->value->value, $statementsSource, $stmt);
216224
}
217225
}
218226
}
219227
}
220228
}
229+
230+
/**
231+
* A since version must not be newer than the next patch release of the
232+
* current branch, so backports with an unadjusted since fail
233+
*/
234+
private static function checkSinceIsReleasable(string $since, FileSource $statementsSource, \PhpParser\Node $stmt): void {
235+
// Backports may list multiple versions: "33.0.1, 32.0.7"
236+
if (!preg_match('/^\d+(\.\d+)*(\s*,\s*\d+(\.\d+)*)*/', $since, $list)) {
237+
return;
238+
}
239+
240+
$maxVersion = self::getMaxSinceVersion();
241+
foreach (preg_split('/\s*,\s*/', $list[0]) as $version) {
242+
if (version_compare($version, $maxVersion, '<=')) {
243+
return;
244+
}
245+
}
246+
247+
IssueBuffer::maybeAdd(
248+
new InvalidDocblock(
249+
'Since version ' . $list[0] . ' is newer than the next release ' . $maxVersion . ' of this branch, please adjust it to the version the change is released in.',
250+
new CodeLocation($statementsSource, $stmt)
251+
)
252+
);
253+
}
254+
255+
private static function getMaxSinceVersion(): string {
256+
static $maxVersion = null;
257+
if ($maxVersion === null) {
258+
require __DIR__ . '/../../version.php';
259+
/** @var array{0: int, 1: int, 2: int, 3: int} $OC_Version */
260+
$maxVersion = $OC_Version[0] . '.' . $OC_Version[1] . '.' . ($OC_Version[2] + 1);
261+
}
262+
return $maxVersion;
263+
}
221264
}

‎lib/public/Authentication/IProvideUserSecretBackend.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ interface IProvideUserSecretBackend {
2727
* secret but is unable to do so.
2828
*
2929
* @since 23.0.0
30-
* @since 35.0.0 The returns value is now optional.
30+
* @since 34.0.2 The returns value is now optional.
3131
*/
3232
public function getCurrentUserSecret(): ?string;
3333
}

‎lib/public/Calendar/CalendarImportOptions.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public function setValidate(int $value): void {
158158
/**
159159
* Gets whether to include object counts as the first yielded value
160160
*
161-
* @since 35.0.0
161+
* @since 34.0.5
162162
*/
163163
public function getCounts(): bool {
164164
return $this->counts;
@@ -167,7 +167,7 @@ public function getCounts(): bool {
167167
/**
168168
* Sets whether to include object counts as the first yielded value
169169
*
170-
* @since 35.0.0
170+
* @since 34.0.5
171171
*/
172172
public function setCounts(bool $counts): void {
173173
$this->counts = $counts;

‎lib/public/Calendar/Events/CalendarObjectUpdatedEvent.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __construct(
3636
* Returns the object data as it was before the update.
3737
*
3838
* @return array
39-
* @since 35.0.0
39+
* @since 34.0.0
4040
*/
4141
public function getOldObjectData(): array {
4242
return $this->oldObjectData;

‎lib/public/Calendar/Room/IRoomMetadata.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ interface IRoomMetadata {
4343
* building from BUILDING_ADDRESS, which only works for backends that
4444
* happen to put the building name first.
4545
*
46-
* @since 35.0.0
46+
* @since 34.0.4
4747
*/
4848
public const BUILDING_NAME = '{http://nextcloud.com/ns}room-building-name';
4949

‎lib/public/Contacts/ContactsImportOptions.php‎

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,45 +13,45 @@
1313
/**
1414
* Contacts Import Options
1515
*
16-
* @since 35.0.0
16+
* @since 34.0.5
1717
*/
1818
final class ContactsImportOptions {
1919

2020
/**
21-
* @since 35.0.0
21+
* @since 34.0.5
2222
*/
2323
public const FORMATS = ['vcf', 'jcf', 'xcf'];
2424

2525
/**
26-
* @since 35.0.0
26+
* @since 34.0.5
2727
*/
2828
public const VALIDATE_NONE = 0;
2929
/**
30-
* @since 35.0.0
30+
* @since 34.0.5
3131
*/
3232
public const VALIDATE_SKIP = 1;
3333
/**
34-
* @since 35.0.0
34+
* @since 34.0.5
3535
*/
3636
public const VALIDATE_FAIL = 2;
3737
/**
38-
* @since 35.0.0
38+
* @since 34.0.5
3939
*/
4040
public const VALIDATE_OPTIONS = [
4141
self::VALIDATE_NONE,
4242
self::VALIDATE_SKIP,
4343
self::VALIDATE_FAIL,
4444
];
4545
/**
46-
* @since 35.0.0
46+
* @since 34.0.5
4747
*/
4848
public const ERROR_CONTINUE = 0;
4949
/**
50-
* @since 35.0.0
50+
* @since 34.0.5
5151
*/
5252
public const ERROR_FAIL = 1;
5353
/**
54-
* @since 35.0.0
54+
* @since 34.0.5
5555
*/
5656
public const ERROR_OPTIONS = [
5757
self::ERROR_CONTINUE,
@@ -69,7 +69,7 @@ final class ContactsImportOptions {
6969
* Gets the import format
7070
*
7171
* @return 'vcf'|'jcf'|'xcf' (defaults to vcf)
72-
* @since 35.0.0
72+
* @since 34.0.5
7373
*/
7474
public function getFormat(): string {
7575
return $this->format;
@@ -79,7 +79,7 @@ public function getFormat(): string {
7979
* Sets the import format
8080
*
8181
* @param 'vcf'|'jcf'|'xcf' $value
82-
* @since 35.0.0
82+
* @since 34.0.5
8383
*/
8484
public function setFormat(string $value): void {
8585
if (!in_array($value, self::FORMATS, true)) {
@@ -91,7 +91,7 @@ public function setFormat(string $value): void {
9191
/**
9292
* Gets whether to supersede existing objects
9393
*
94-
* @since 35.0.0
94+
* @since 34.0.5
9595
*/
9696
public function getSupersede(): bool {
9797
return $this->supersede;
@@ -100,7 +100,7 @@ public function getSupersede(): bool {
100100
/**
101101
* Sets whether to supersede existing objects
102102
*
103-
* @since 35.0.0
103+
* @since 34.0.5
104104
*/
105105
public function setSupersede(bool $supersede): void {
106106
$this->supersede = $supersede;
@@ -110,7 +110,7 @@ public function setSupersede(bool $supersede): void {
110110
* Gets how to handle object errors
111111
*
112112
* @return int 0 - continue, 1 - fail
113-
* @since 35.0.0
113+
* @since 34.0.5
114114
*/
115115
public function getErrors(): int {
116116
return $this->errors;
@@ -122,7 +122,7 @@ public function getErrors(): int {
122122
* @param int $value 0 - continue, 1 - fail
123123
*
124124
* @template $value of self::ERROR_*
125-
* @since 35.0.0
125+
* @since 34.0.5
126126
*/
127127
public function setErrors(int $value): void {
128128
if (!in_array($value, self::ERROR_OPTIONS, true)) {
@@ -135,7 +135,7 @@ public function setErrors(int $value): void {
135135
* Gets how to handle object validation
136136
*
137137
* @return int 0 - no validation, 1 - validate and skip on issue, 2 - validate and fail on issue
138-
* @since 35.0.0
138+
* @since 34.0.5
139139
*/
140140
public function getValidate(): int {
141141
return $this->validate;
@@ -147,7 +147,7 @@ public function getValidate(): int {
147147
* @param int $value 0 - no validation, 1 - validate and skip on issue, 2 - validate and fail on issue
148148
*
149149
* @template $value of self::VALIDATE_*
150-
* @since 35.0.0
150+
* @since 34.0.5
151151
*/
152152
public function setValidate(int $value): void {
153153
if (!in_array($value, self::VALIDATE_OPTIONS, true)) {
@@ -159,7 +159,7 @@ public function setValidate(int $value): void {
159159
/**
160160
* Gets whether to include object counts as the first yielded value
161161
*
162-
* @since 35.0.0
162+
* @since 34.0.5
163163
*/
164164
public function getCounts(): bool {
165165
return $this->counts;
@@ -168,7 +168,7 @@ public function getCounts(): bool {
168168
/**
169169
* Sets whether to include object counts as the first yielded value
170170
*
171-
* @since 35.0.0
171+
* @since 34.0.5
172172
*/
173173
public function setCounts(bool $counts): void {
174174
$this->counts = $counts;

‎lib/public/DB/QueryBuilder/IFunctionBuilder.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function substring($input, $start, $length = null): IQueryFunction;
6868
* @param string|ILiteral|IParameter|IQueryFunction $pattern The pattern to match and return
6969
*
7070
* @return IQueryFunction
71-
* @since 36.0.0
71+
* @since 34.0.5
7272
*/
7373
public function regexSubstring($input, $pattern): IQueryFunction;
7474

‎lib/public/Defaults.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public function getLogo(bool $useSvg = true): string {
177177
* Raw logo image data (raster) for embedding directly into emails
178178
*
179179
* @return array{content: string, mimeType: string}|null null when unavailable
180-
* @since 35.0.0
180+
* @since 34.0.4
181181
*/
182182
public function getLogoImage(): ?array {
183183
return $this->defaults->getLogoImage();

‎lib/public/FilesMetadata/IFilesMetadataManager.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function getMetadata(int $fileId, bool $generate = false): IFilesMetadata
7676
*
7777
* @return IFilesMetadata
7878
* @throws FilesMetadataNotFoundException if not found
79-
* @since 36.0.0
79+
* @since 34.0.6
8080
*/
8181
public function getMetadataForNode(Node $node, bool $generate = false): IFilesMetadata;
8282

‎lib/public/FilesMetadata/Model/IFilesMetadata.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function getFileId(): int;
4949
* returns the storage id linked to this metadata
5050
*
5151
* @return int
52-
* @since 36.0.0
52+
* @since 34.0.6
5353
*/
5454
public function getStorageId(): int;
5555

0 commit comments

Comments
 (0)