Skip to content

Commit 201cda6

Browse files
committed
Merge branch '4.6'
# Conflicts: # phpstan-baseline-gte-8.0.neon # phpstan-baseline.neon # phpstan-baseline.neon.php # src/bundle/Core/URLChecker/Handler/HTTPHandler.php
2 parents 1870a58 + 2a440c3 commit 201cda6

File tree

5 files changed

+90
-78
lines changed

5 files changed

+90
-78
lines changed

phpstan-baseline-gte-8.1.neon

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: '#^Possibly invalid array key type bool\|float\|int\|string\.$#'
5+
identifier: offsetAccess.invalidOffset
6+
count: 3
7+
path: src/lib/Persistence/Legacy/Content/Mapper.php
8+
9+
-
10+
message: '#^Possibly invalid array key type bool\|float\|int\|string\.$#'
11+
identifier: offsetAccess.invalidOffset
12+
count: 2
13+
path: tests/integration/Core/Repository/SearchService/RemoteIdIndexingTest.php

phpstan-baseline.neon

Lines changed: 24 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -5490,18 +5490,6 @@ parameters:
54905490
count: 1
54915491
path: src/contracts/Repository/Values/Content/Query/Criterion/FullText.php
54925492

5493-
-
5494-
message: '#^Method Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Query\\Criterion\\IsFieldEmpty\:\:__construct\(\) has Ibexa\\Contracts\\Core\\Repository\\Exceptions\\InvalidArgumentException in PHPDoc @throws tag but it''s not thrown\.$#'
5495-
identifier: throws.unusedType
5496-
count: 1
5497-
path: src/contracts/Repository/Values/Content/Query/Criterion/IsFieldEmpty.php
5498-
5499-
-
5500-
message: '#^Method Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Query\\Criterion\\LogicalNot\:\:__construct\(\) has InvalidArgumentException in PHPDoc @throws tag but it''s not thrown\.$#'
5501-
identifier: throws.unusedType
5502-
count: 1
5503-
path: src/contracts/Repository/Values/Content/Query/Criterion/LogicalNot.php
5504-
55055493
-
55065494
message: '#^Class Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\RelationList implements generic interface IteratorAggregate but does not specify its types\: TKey, TValue$#'
55075495
identifier: missingType.generics
@@ -5622,12 +5610,6 @@ parameters:
56225610
count: 1
56235611
path: src/contracts/Repository/Values/ObjectState/ObjectStateCreateStruct.php
56245612

5625-
-
5626-
message: '#^Method Ibexa\\Contracts\\Core\\Repository\\Values\\URL\\Query\\Criterion\\LogicalNot\:\:__construct\(\) has InvalidArgumentException in PHPDoc @throws tag but it''s not thrown\.$#'
5627-
identifier: throws.unusedType
5628-
count: 1
5629-
path: src/contracts/Repository/Values/URL/Query/Criterion/LogicalNot.php
5630-
56315613
-
56325614
message: '#^Class Ibexa\\Contracts\\Core\\Repository\\Values\\URL\\SearchResult implements generic interface IteratorAggregate but does not specify its types\: TKey, TValue$#'
56335615
identifier: missingType.generics
@@ -6486,12 +6468,6 @@ parameters:
64866468
count: 1
64876469
path: src/lib/FieldType/FieldType.php
64886470

6489-
-
6490-
message: '#^Method Ibexa\\Core\\FieldType\\FieldType\:\:validate\(\) has Ibexa\\Contracts\\Core\\Repository\\Exceptions\\InvalidArgumentException in PHPDoc @throws tag but it''s not thrown\.$#'
6491-
identifier: throws.unusedType
6492-
count: 1
6493-
path: src/lib/FieldType/FieldType.php
6494-
64956471
-
64966472
message: '#^Method Ibexa\\Core\\FieldType\\FieldType\:\:validatorConfigurationFromHash\(\) has parameter \$validatorConfigurationHash with no value type specified in iterable type array\.$#'
64976473
identifier: missingType.iterableValue
@@ -7182,12 +7158,6 @@ parameters:
71827158
count: 1
71837159
path: src/lib/FieldType/Null/Type.php
71847160

7185-
-
7186-
message: '#^Method Ibexa\\Core\\FieldType\\Null\\Type\:\:checkValueStructure\(\) has Ibexa\\Contracts\\Core\\Repository\\Exceptions\\InvalidArgumentException in PHPDoc @throws tag but it''s not thrown\.$#'
7187-
identifier: throws.unusedType
7188-
count: 1
7189-
path: src/lib/FieldType/Null/Type.php
7190-
71917161
-
71927162
message: '#^Method Ibexa\\Core\\FieldType\\Null\\Type\:\:checkValueStructure\(\) has no return type specified\.$#'
71937163
identifier: missingType.return
@@ -7512,12 +7482,6 @@ parameters:
75127482
count: 1
75137483
path: src/lib/FieldType/User/Type.php
75147484

7515-
-
7516-
message: '#^Method Ibexa\\Core\\FieldType\\User\\Type\:\:checkValueStructure\(\) has Ibexa\\Contracts\\Core\\Repository\\Exceptions\\InvalidArgumentException in PHPDoc @throws tag but it''s not thrown\.$#'
7517-
identifier: throws.unusedType
7518-
count: 1
7519-
path: src/lib/FieldType/User/Type.php
7520-
75217485
-
75227486
message: '#^Method Ibexa\\Core\\FieldType\\User\\Type\:\:checkValueStructure\(\) has no return type specified\.$#'
75237487
identifier: missingType.return
@@ -7914,12 +7878,6 @@ parameters:
79147878
count: 1
79157879
path: src/lib/Helper/TranslationHelper.php
79167880

7917-
-
7918-
message: '#^Method Ibexa\\Core\\Limitation\\BlockingLimitationType\:\:evaluate\(\) has Ibexa\\Contracts\\Core\\Repository\\Exceptions\\BadStateException in PHPDoc @throws tag but it''s not thrown\.$#'
7919-
identifier: throws.unusedType
7920-
count: 1
7921-
path: src/lib/Limitation/BlockingLimitationType.php
7922-
79237881
-
79247882
message: '#^Method Ibexa\\Core\\Limitation\\LanguageLimitation\\ContentDeleteEvaluator\:\:evaluate\(\) never returns null so it can be removed from the return type\.$#'
79257883
identifier: return.unusedType
@@ -12150,18 +12108,6 @@ parameters:
1215012108
count: 1
1215112109
path: src/lib/Persistence/Legacy/Content/Gateway.php
1215212110

12153-
-
12154-
message: '#^Argument of an invalid type DOMNodeList\<DOMNode\>\|false supplied for foreach, only iterables are supported\.$#'
12155-
identifier: foreach.nonIterable
12156-
count: 1
12157-
path: src/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php
12158-
12159-
-
12160-
message: '#^Cannot call method removeChild\(\) on DOMNode\|null\.$#'
12161-
identifier: method.nonObject
12162-
count: 1
12163-
path: src/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php
12164-
1216512111
-
1216612112
message: '#^Method Ibexa\\Core\\Persistence\\Legacy\\Content\\Gateway\\DoctrineDatabase\:\:deleteTranslationFromContentNames\(\) has no return type specified\.$#'
1216712113
identifier: missingType.return
@@ -13086,6 +13032,12 @@ parameters:
1308613032
count: 1
1308713033
path: src/lib/Persistence/Legacy/Content/Mapper.php
1308813034

13035+
-
13036+
message: '#^Possibly invalid array key type bool\|float\|int\|string\.$#'
13037+
identifier: offsetAccess.invalidOffset
13038+
count: 3
13039+
path: src/lib/Persistence/Legacy/Content/Mapper.php
13040+
1308913041
-
1309013042
message: '#^Property Ibexa\\Contracts\\Core\\Persistence\\Content\\CreateStruct\:\:\$isHidden \(bool\) on left side of \?\? is not nullable\.$#'
1309113043
identifier: nullCoalesce.property
@@ -18246,6 +18198,12 @@ parameters:
1824618198
count: 2
1824718199
path: src/lib/Repository/URLWildcardService.php
1824818200

18201+
-
18202+
message: '#^Parameter \#3 \$hashType of method Ibexa\\Contracts\\Core\\Repository\\PasswordHashService\:\:isValidPassword\(\) expects int\|null, string given\.$#'
18203+
identifier: argument.type
18204+
count: 1
18205+
path: src/lib/Repository/User/PasswordValidator.php
18206+
1824918207
-
1825018208
message: '#^Dead catch \- Exception is never thrown in the try block\.$#'
1825118209
identifier: catch.neverThrown
@@ -18306,6 +18264,12 @@ parameters:
1830618264
count: 1
1830718265
path: src/lib/Repository/UserService.php
1830818266

18267+
-
18268+
message: '#^Parameter \#3 \$hashAlgorithm of method Ibexa\\Core\\Repository\\UserService\:\:comparePasswordHashes\(\) expects int, string given\.$#'
18269+
identifier: argument.type
18270+
count: 1
18271+
path: src/lib/Repository/UserService.php
18272+
1830918273
-
1831018274
message: '#^Property Ibexa\\Contracts\\Core\\Repository\\Values\\User\\UserUpdateStruct\:\:\$contentMetadataUpdateStruct \(Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\ContentMetadataUpdateStruct\) in empty\(\) is not falsy\.$#'
1831118275
identifier: empty.property
@@ -35634,6 +35598,12 @@ parameters:
3563435598
count: 1
3563535599
path: tests/integration/Core/Repository/SearchService/RemoteIdIndexingTest.php
3563635600

35601+
-
35602+
message: '#^Possibly invalid array key type bool\|float\|int\|string\.$#'
35603+
identifier: offsetAccess.invalidOffset
35604+
count: 2
35605+
path: tests/integration/Core/Repository/SearchService/RemoteIdIndexingTest.php
35606+
3563735607
-
3563835608
message: '#^Access to an undefined property Ibexa\\Contracts\\Core\\Repository\\Values\\ValueObject\:\:\$remoteId\.$#'
3563935609
identifier: property.notFound
@@ -60522,12 +60492,6 @@ parameters:
6052260492
count: 1
6052360493
path: tests/lib/Search/Legacy/Content/AbstractTestCase.php
6052460494

60525-
-
60526-
message: '#^Method Ibexa\\Tests\\Core\\Search\\Legacy\\Content\\AbstractTestCase\:\:getContentTypeHandler\(\) has Doctrine\\DBAL\\Exception in PHPDoc @throws tag but it''s not thrown\.$#'
60527-
identifier: throws.unusedType
60528-
count: 1
60529-
path: tests/lib/Search/Legacy/Content/AbstractTestCase.php
60530-
6053160495
-
6053260496
message: '#^Method Ibexa\\Tests\\Core\\Search\\Legacy\\Content\\AbstractTestCase\:\:getConverterRegistry\(\) has no return type specified\.$#'
6053360497
identifier: missingType.return

src/bundle/Core/Imagine/PlaceholderProvider/RemoteProvider.php

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,43 @@ public function getPlaceholder(ImageValue $value, array $options = []): string
2626
$options = $this->resolveOptions($options);
2727

2828
$path = $this->getTemporaryPath();
29+
if ($path === '') {
30+
throw new RuntimeException('Temporary file path is empty.');
31+
}
32+
2933
$placeholderUrl = $this->getPlaceholderUrl($options['url_pattern'], $value);
34+
if ($placeholderUrl === '') {
35+
throw new RuntimeException('Placeholder URL must be a non-empty string.');
36+
}
3037

31-
try {
32-
$handler = curl_init();
38+
$fp = fopen($path, 'wb');
39+
if ($fp === false) {
40+
throw new RuntimeException("Unable to open temp file for writing: {$path}");
41+
}
3342

34-
curl_setopt_array($handler, [
35-
CURLOPT_URL => $placeholderUrl,
36-
CURLOPT_FILE => fopen($path, 'wb'),
37-
CURLOPT_TIMEOUT => $options['timeout'],
38-
CURLOPT_FAILONERROR => true,
39-
]);
43+
$handler = \curl_init();
44+
if ($handler === false) {
45+
throw new RuntimeException('Unable to initialize cURL.');
46+
}
47+
48+
$timeout = $options['timeout'];
4049

50+
curl_setopt_array($handler, [
51+
CURLOPT_URL => $placeholderUrl, // non-empty-string
52+
CURLOPT_FILE => $fp, // resource
53+
CURLOPT_TIMEOUT => $timeout, // int
54+
CURLOPT_FAILONERROR => true, // bool
55+
]);
56+
57+
try {
4158
if (curl_exec($handler) === false) {
42-
throw new RuntimeException("Unable to download placeholder for {$value->id} ($placeholderUrl): " . curl_error($handler));
59+
throw new RuntimeException(
60+
"Unable to download placeholder for {$value->id} ({$placeholderUrl}): " . curl_error($handler)
61+
);
4362
}
4463
} finally {
4564
curl_close($handler);
65+
fclose($fp);
4666
}
4767

4868
return $path;

src/bundle/Core/URLChecker/Handler/HTTPHandler.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99

1010
use CurlHandle;
1111
use Ibexa\Contracts\Core\Repository\Values\URL\URL;
12+
use InvalidArgumentException;
1213
use LogicException;
14+
use RuntimeException;
1315
use Symfony\Component\OptionsResolver\OptionsResolver;
1416

1517
class HTTPHandler extends AbstractConfigResolverBasedURLHandler
@@ -116,9 +118,18 @@ private function createCurlHandlerForUrl(URL $url, array &$handlers, int $connec
116118
{
117119
$options = $this->getOptions();
118120
$handler = curl_init();
121+
if ($handler === false) {
122+
throw new RuntimeException('Unable to initialize cURL handler.');
123+
}
124+
125+
$urlString = $url->getUrl();
126+
if ($urlString === '') {
127+
throw new InvalidArgumentException('URL must be a non-empty string.');
128+
}
119129

130+
/** @var non-empty-string $urlString */
120131
curl_setopt_array($handler, [
121-
CURLOPT_URL => $url->getUrl(),
132+
CURLOPT_URL => $urlString,
122133
CURLOPT_RETURNTRANSFER => false,
123134
CURLOPT_FOLLOWLOCATION => true,
124135
CURLOPT_CONNECTTIMEOUT => $connectionTimeout,
@@ -127,18 +138,14 @@ private function createCurlHandlerForUrl(URL $url, array &$handlers, int $connec
127138
CURLOPT_NOBODY => true,
128139
]);
129140

130-
if ($options['ignore_certificate']) {
141+
if (!empty($options['ignore_certificate'])) {
131142
curl_setopt_array($handler, [
132143
CURLOPT_SSL_VERIFYPEER => false,
133-
CURLOPT_SSL_VERIFYHOST => false,
144+
CURLOPT_SSL_VERIFYHOST => 0,
134145
]);
135146
}
136147

137-
$handlers[(int)$handler] = $url;
138-
139-
if (false === $handler) {
140-
throw new LogicException("Failed to create Curl handler for '{$url->getUrl()}' URL", 1);
141-
}
148+
$handlers[(int) $handler] = $url;
142149

143150
return $handler;
144151
}

src/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Doctrine\DBAL\Platforms\AbstractPlatform;
1515
use Doctrine\DBAL\Query\QueryBuilder as DoctrineQueryBuilder;
1616
use DOMDocument;
17+
use DOMElement;
1718
use DOMXPath;
1819
use Ibexa\Contracts\Core\Persistence\Content;
1920
use Ibexa\Contracts\Core\Persistence\Content\ContentInfo;
@@ -37,6 +38,7 @@
3738
use Ibexa\Core\Persistence\Legacy\Content\StorageFieldValue;
3839
use Ibexa\Core\Persistence\Legacy\SharedGateway\Gateway as SharedGateway;
3940
use LogicException;
41+
use RuntimeException;
4042

4143
/**
4244
* Doctrine database based content gateway.
@@ -1187,8 +1189,14 @@ private function removeRelationFromRelationListField(int $contentId, array $row)
11871189
$xpathExpression = "//related-objects/relation-list/relation-item[@contentobject-id='{$contentId}']";
11881190

11891191
$relationItems = $xpath->query($xpathExpression);
1192+
if ($relationItems === false) {
1193+
throw new RuntimeException('Invalid XPath: ' . $xpathExpression);
1194+
}
1195+
11901196
foreach ($relationItems as $relationItem) {
1191-
$relationItem->parentNode->removeChild($relationItem);
1197+
if ($relationItem instanceof DOMElement && $relationItem->parentNode !== null) {
1198+
$relationItem->parentNode->removeChild($relationItem);
1199+
}
11921200
}
11931201

11941202
$query = $this->connection->createQueryBuilder();

0 commit comments

Comments
 (0)