Completed
Push — parallel_test_fork ( 458d25...5e34ca )
by
unknown
20:19 queued 02:09
created

ExceptionConversion::setPublishedStatus()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 2
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * File containing the Content Gateway base class.
5
 *
6
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
7
 * @license For full copyright and license information view LICENSE file distributed with this source code.
8
 */
9
namespace eZ\Publish\Core\Persistence\Legacy\Content\Gateway;
10
11
use eZ\Publish\API\Repository\Exceptions\BadStateException;
12
use eZ\Publish\Core\Persistence\Legacy\Content\Gateway;
13
use eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldValue;
14
use eZ\Publish\SPI\Persistence\Content;
15
use eZ\Publish\SPI\Persistence\Content\CreateStruct;
16
use eZ\Publish\SPI\Persistence\Content\UpdateStruct;
17
use eZ\Publish\SPI\Persistence\Content\MetadataUpdateStruct;
18
use eZ\Publish\SPI\Persistence\Content\VersionInfo;
19
use eZ\Publish\SPI\Persistence\Content\Field;
20
use eZ\Publish\SPI\Persistence\Content\Relation\CreateStruct as RelationCreateStruct;
21
use Doctrine\DBAL\DBALException;
22
use PDOException;
23
use RuntimeException;
24
25
/**
26
 * Base class for content gateways.
27
 */
28
class ExceptionConversion extends Gateway
29
{
30
    /**
31
     * The wrapped gateway.
32
     *
33
     * @var Gateway
34
     */
35
    protected $innerGateway;
36
37
    /**
38
     * Creates a new exception conversion gateway around $innerGateway.
39
     *
40
     * @param Gateway $innerGateway
41
     */
42
    public function __construct(Gateway $innerGateway)
43
    {
44
        $this->innerGateway = $innerGateway;
45
    }
46
47
    /**
48
     * Get context definition for external storage layers.
49
     *
50
     * @return array
51
     */
52
    public function getContext()
53
    {
54
        try {
55
            return $this->innerGateway->getContext();
56
        } catch (DBALException $e) {
57
            throw new RuntimeException('Database error', 0, $e);
58
        } catch (PDOException $e) {
59
            throw new RuntimeException('Database error', 0, $e);
60
        }
61
    }
62
63
    /**
64
     * Inserts a new content object.
65
     *
66
     * @param \eZ\Publish\SPI\Persistence\Content\CreateStruct $struct
67
     * @param mixed $currentVersionNo
68
     *
69
     * @return int ID
70
     */
71
    public function insertContentObject(CreateStruct $struct, $currentVersionNo = 1)
72
    {
73
        try {
74
            return $this->innerGateway->insertContentObject($struct, $currentVersionNo);
75
        } catch (DBALException $e) {
76
            throw new RuntimeException('Database error', 0, $e);
77
        } catch (PDOException $e) {
78
            throw new RuntimeException('Database error', 0, $e);
79
        }
80
    }
81
82
    /**
83
     * Inserts a new version.
84
     *
85
     * @param \eZ\Publish\SPI\Persistence\Content\VersionInfo $versionInfo
86
     * @param \eZ\Publish\SPI\Persistence\Content\Field[] $fields
87
     *
88
     * @return int ID
89
     */
90
    public function insertVersion(VersionInfo $versionInfo, array $fields)
91
    {
92
        try {
93
            return $this->innerGateway->insertVersion($versionInfo, $fields);
94
        } catch (DBALException $e) {
95
            throw new RuntimeException('Database error', 0, $e);
96
        } catch (PDOException $e) {
97
            throw new RuntimeException('Database error', 0, $e);
98
        }
99
    }
100
101
    /**
102
     * Updates an existing content identified by $contentId in respect to $struct.
103
     *
104
     * @param int $contentId
105
     * @param \eZ\Publish\SPI\Persistence\Content\MetadataUpdateStruct $struct
106
     * @param \eZ\Publish\SPI\Persistence\Content\VersionInfo $prePublishVersionInfo Provided on publish
107
     */
108
    public function updateContent($contentId, MetadataUpdateStruct $struct, VersionInfo $prePublishVersionInfo = null)
109
    {
110
        try {
111
            return $this->innerGateway->updateContent($contentId, $struct, $prePublishVersionInfo);
112
        } catch (DBALException $e) {
113
            throw new RuntimeException('Database error', 0, $e);
114
        } catch (PDOException $e) {
115
            throw new RuntimeException('Database error', 0, $e);
116
        }
117
    }
118
119
    /**
120
     * Updates version $versionNo for content identified by $contentId, in respect to $struct.
121
     *
122
     * @param int $contentId
123
     * @param int $versionNo
124
     * @param \eZ\Publish\SPI\Persistence\Content\UpdateStruct $struct
125
     */
126
    public function updateVersion($contentId, $versionNo, UpdateStruct $struct)
127
    {
128
        try {
129
            return $this->innerGateway->updateVersion($contentId, $versionNo, $struct);
130
        } catch (DBALException $e) {
131
            throw new RuntimeException('Database error', 0, $e);
132
        } catch (PDOException $e) {
133
            throw new RuntimeException('Database error', 0, $e);
134
        }
135
    }
136
137
    /**
138
     * Updates "always available" flag for content identified by $contentId, in respect to $alwaysAvailable.
139
     *
140
     * @param int $contentId
141
     * @param bool $newAlwaysAvailable New "always available" value
142
     */
143
    public function updateAlwaysAvailableFlag($contentId, $newAlwaysAvailable)
144
    {
145
        try {
146
            return $this->innerGateway->updateAlwaysAvailableFlag($contentId, $newAlwaysAvailable);
147
        } catch (DBALException $e) {
148
            throw new RuntimeException('Database error', 0, $e);
149
        } catch (PDOException $e) {
150
            throw new RuntimeException('Database error', 0, $e);
151
        }
152
    }
153
154
    /**
155
     * Sets the state of object identified by $contentId and $version to $state.
156
     *
157
     * The $status can be one of STATUS_DRAFT, STATUS_PUBLISHED, STATUS_ARCHIVED
158
     *
159
     * @param int $contentId
160
     * @param int $version
161
     * @param int $status
162
     *
163
     * @return bool
164
     */
165
    public function setStatus($contentId, $version, $status)
166
    {
167
        try {
168
            return $this->innerGateway->setStatus($contentId, $version, $status);
169
        } catch (DBALException $e) {
170
            throw new RuntimeException('Database error', 0, $e);
171
        } catch (PDOException $e) {
172
            throw new RuntimeException('Database error', 0, $e);
173
        }
174
    }
175
176
    public function setPublishedStatus(int $contentId, int $status): void
177
    {
178
        try {
179
            $this->innerGateway->setPublishedStatus($contentId, $status);
180
        } catch (DBALException | PDOException $e) {
181
            throw new RuntimeException('Database error', 0, $e);
182
        }
183
    }
184
185
    /**
186
     * Inserts a new field.
187
     *
188
     * Only used when a new field is created (i.e. a new object or a field in a
189
     * new language!). After that, field IDs need to stay the same, only the
190
     * version number changes.
191
     *
192
     * @param \eZ\Publish\SPI\Persistence\Content $content
193
     * @param \eZ\Publish\SPI\Persistence\Content\Field $field
194
     * @param \eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldValue $value
195
     *
196
     * @return int ID
197
     */
198
    public function insertNewField(Content $content, Field $field, StorageFieldValue $value)
199
    {
200
        try {
201
            return $this->innerGateway->insertNewField($content, $field, $value);
202
        } catch (DBALException $e) {
203
            throw new RuntimeException('Database error', 0, $e);
204
        } catch (PDOException $e) {
205
            throw new RuntimeException('Database error', 0, $e);
206
        }
207
    }
208
209
    /**
210
     * Inserts an existing field.
211
     *
212
     * Used to insert a field with an exsting ID but a new version number.
213
     *
214
     * @param Content $content
215
     * @param Field $field
216
     * @param StorageFieldValue $value
217
     */
218
    public function insertExistingField(Content $content, Field $field, StorageFieldValue $value)
219
    {
220
        try {
221
            return $this->innerGateway->insertExistingField($content, $field, $value);
222
        } catch (DBALException $e) {
223
            throw new RuntimeException('Database error', 0, $e);
224
        } catch (PDOException $e) {
225
            throw new RuntimeException('Database error', 0, $e);
226
        }
227
    }
228
229
    /**
230
     * Updates an existing field.
231
     *
232
     * @param Field $field
233
     * @param StorageFieldValue $value
234
     */
235
    public function updateField(Field $field, StorageFieldValue $value)
236
    {
237
        try {
238
            return $this->innerGateway->updateField($field, $value);
239
        } catch (DBALException $e) {
240
            throw new RuntimeException('Database error', 0, $e);
241
        } catch (PDOException $e) {
242
            throw new RuntimeException('Database error', 0, $e);
243
        }
244
    }
245
246
    /**
247
     * Updates an existing, non-translatable field.
248
     *
249
     * @param \eZ\Publish\SPI\Persistence\Content\Field $field
250
     * @param \eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldValue $value
251
     * @param int $contentId
252
     */
253
    public function updateNonTranslatableField(
254
        Field $field,
255
        StorageFieldValue $value,
256
        $contentId
257
    ) {
258
        try {
259
            return $this->innerGateway->updateNonTranslatableField($field, $value, $contentId);
260
        } catch (DBALException $e) {
261
            throw new RuntimeException('Database error', 0, $e);
262
        } catch (PDOException $e) {
263
            throw new RuntimeException('Database error', 0, $e);
264
        }
265
    }
266
267
    /**
268
     * {@inheritdoc}
269
     */
270
    public function load($contentId, $version = null, array $translations = null)
271
    {
272
        try {
273
            return $this->innerGateway->load($contentId, $version, $translations);
0 ignored issues
show
Bug introduced by
It seems like $translations defined by parameter $translations on line 270 can also be of type array; however, eZ\Publish\Core\Persiste...Content\Gateway::load() does only seem to accept null|array<integer,string>, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
274
        } catch (DBALException $e) {
275
            throw new RuntimeException('Database error', 0, $e);
276
        } catch (PDOException $e) {
277
            throw new RuntimeException('Database error', 0, $e);
278
        }
279
    }
280
281
    /**
282
     * {@inheritdoc}
283
     */
284
    public function loadContentList(array $contentIds, array $translations = null): array
285
    {
286
        try {
287
            return $this->innerGateway->loadContentList($contentIds, $translations);
0 ignored issues
show
Bug introduced by
It seems like $translations defined by parameter $translations on line 284 can also be of type array; however, eZ\Publish\Core\Persiste...eway::loadContentList() does only seem to accept null|array<integer,string>, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
288
        } catch (DBALException | PDOException $e) {
289
            throw new RuntimeException('Database error', 0, $e);
290
        }
291
    }
292
293
    /**
294
     * Loads data for a content object identified by its remote ID.
295
     *
296
     * Returns an array with the relevant data.
297
     *
298
     * @param mixed $remoteId
299
     *
300
     * @return array
301
     */
302
    public function loadContentInfoByRemoteId($remoteId)
303
    {
304
        try {
305
            return $this->innerGateway->loadContentInfoByRemoteId($remoteId);
306
        } catch (DBALException $e) {
307
            throw new \RuntimeException('Database error', 0, $e);
308
        } catch (\PDOException $e) {
309
            throw new \RuntimeException('Database error', 0, $e);
310
        }
311
    }
312
313
    /**
314
     * Loads info for a content object identified by its location ID (node ID).
315
     *
316
     * Returns an array with the relevant data.
317
     *
318
     * @param int $locationId
319
     *
320
     * @throws \eZ\Publish\Core\Base\Exceptions\NotFoundException
321
     *
322
     * @return array
323
     */
324
    public function loadContentInfoByLocationId($locationId)
325
    {
326
        try {
327
            return $this->innerGateway->loadContentInfoByLocationId($locationId);
328
        } catch (DBALException $e) {
329
            throw new \RuntimeException('Database error', 0, $e);
330
        } catch (\PDOException $e) {
331
            throw new \RuntimeException('Database error', 0, $e);
332
        }
333
    }
334
335
    /**
336
     * Loads info for content identified by $contentId.
337
     * Will basically return a hash containing all field values for ezcontentobject table plus following keys:
338
     *  - always_available => Boolean indicating if content's language mask contains alwaysAvailable bit field
339
     *  - main_language_code => Language code for main (initial) language. E.g. "eng-GB".
340
     *
341
     * @param int $contentId
342
     *
343
     * @throws \eZ\Publish\Core\Base\Exceptions\NotFoundException
344
     *
345
     * @return array
346
     */
347
    public function loadContentInfo($contentId)
348
    {
349
        try {
350
            return $this->innerGateway->loadContentInfo($contentId);
351
        } catch (DBALException $e) {
352
            throw new RuntimeException('Database error', 0, $e);
353
        } catch (PDOException $e) {
354
            throw new RuntimeException('Database error', 0, $e);
355
        }
356
    }
357
358
    public function loadContentInfoList(array $contentIds)
359
    {
360
        try {
361
            return $this->innerGateway->loadContentInfoList($contentIds);
362
        } catch (DBALException $e) {
363
            throw new RuntimeException('Database error', 0, $e);
364
        } catch (PDOException $e) {
365
            throw new RuntimeException('Database error', 0, $e);
366
        }
367
    }
368
369
    /**
370
     * Loads version info for content identified by $contentId and $versionNo.
371
     * Will basically return a hash containing all field values from ezcontentobject_version table plus following keys:
372
     *  - names => Hash of content object names. Key is the language code, value is the name.
373
     *  - languages => Hash of language ids. Key is the language code (e.g. "eng-GB"), value is the language numeric id without the always available bit.
374
     *  - initial_language_code => Language code for initial language in this version.
375
     *
376
     * @param int $contentId
377
     * @param int $versionNo
378
     *
379
     * @return array
380
     */
381
    public function loadVersionInfo($contentId, $versionNo)
382
    {
383
        try {
384
            return $this->innerGateway->loadVersionInfo($contentId, $versionNo);
385
        } catch (DBALException $e) {
386
            throw new RuntimeException('Database error', 0, $e);
387
        } catch (PDOException $e) {
388
            throw new RuntimeException('Database error', 0, $e);
389
        }
390
    }
391
392
    /**
393
     * Returns data for all versions with given status created by the given $userId.
394
     *
395
     * @param int $userId
396
     * @param int $status
397
     *
398
     * @return string[][]
399
     */
400
    public function listVersionsForUser($userId, $status = VersionInfo::STATUS_DRAFT)
401
    {
402
        try {
403
            return $this->innerGateway->listVersionsForUser($userId, $status);
404
        } catch (DBALException $e) {
405
            throw new RuntimeException('Database error', 0, $e);
406
        } catch (PDOException $e) {
407
            throw new RuntimeException('Database error', 0, $e);
408
        }
409
    }
410
411
    /**
412
     * Returns all version data for the given $contentId.
413
     *
414
     * Result is returned with oldest version first (using version id as it has index and is auto increment).
415
     *
416
     * @param mixed $contentId
417
     * @param mixed|null $status Optional argument to filter versions by status, like {@see VersionInfo::STATUS_ARCHIVED}.
418
     * @param int $limit Limit for items returned, -1 means none.
419
     *
420
     * @return string[][]
421
     */
422
    public function listVersions($contentId, $status = null, $limit = -1)
423
    {
424
        try {
425
            return $this->innerGateway->listVersions($contentId, $status, $limit);
426
        } catch (DBALException $e) {
427
            throw new RuntimeException('Database error', 0, $e);
428
        } catch (PDOException $e) {
429
            throw new RuntimeException('Database error', 0, $e);
430
        }
431
    }
432
433
    /**
434
     * Returns all version numbers for the given $contentId.
435
     *
436
     * @param mixed $contentId
437
     *
438
     * @return int[]
439
     */
440
    public function listVersionNumbers($contentId)
441
    {
442
        try {
443
            return $this->innerGateway->listVersionNumbers($contentId);
444
        } catch (DBALException $e) {
445
            throw new RuntimeException('Database error', 0, $e);
446
        } catch (PDOException $e) {
447
            throw new RuntimeException('Database error', 0, $e);
448
        }
449
    }
450
451
    /**
452
     * Returns last version number for content identified by $contentId.
453
     *
454
     * @param int $contentId
455
     *
456
     * @return int
457
     */
458
    public function getLastVersionNumber($contentId)
459
    {
460
        try {
461
            return $this->innerGateway->getLastVersionNumber($contentId);
462
        } catch (DBALException $e) {
463
            throw new RuntimeException('Database error', 0, $e);
464
        } catch (PDOException $e) {
465
            throw new RuntimeException('Database error', 0, $e);
466
        }
467
    }
468
469
    /**
470
     * Returns all IDs for locations that refer to $contentId.
471
     *
472
     * @param int $contentId
473
     *
474
     * @return int[]
475
     */
476
    public function getAllLocationIds($contentId)
477
    {
478
        try {
479
            return $this->innerGateway->getAllLocationIds($contentId);
480
        } catch (DBALException $e) {
481
            throw new RuntimeException('Database error', 0, $e);
482
        } catch (PDOException $e) {
483
            throw new RuntimeException('Database error', 0, $e);
484
        }
485
    }
486
487
    /**
488
     * Returns all field IDs of $contentId grouped by their type.
489
     * If $versionNo is set only field IDs for that version are returned.
490
     * If $languageCode is set, only field IDs for that language are returned.
491
     *
492
     * @param int $contentId
493
     * @param int|null $versionNo
494
     * @param string|null $languageCode
495
     *
496
     * @return int[][]
497
     */
498
    public function getFieldIdsByType($contentId, $versionNo = null, $languageCode = null)
499
    {
500
        try {
501
            return $this->innerGateway->getFieldIdsByType($contentId, $versionNo, $languageCode);
502
        } catch (DBALException $e) {
503
            throw new RuntimeException('Database error', 0, $e);
504
        } catch (PDOException $e) {
505
            throw new RuntimeException('Database error', 0, $e);
506
        }
507
    }
508
509
    /**
510
     * Deletes relations to and from $contentId.
511
     * If $versionNo is set only relations for that version are deleted.
512
     *
513
     * @param int $contentId
514
     * @param int|null $versionNo
515
     */
516
    public function deleteRelations($contentId, $versionNo = null)
517
    {
518
        try {
519
            return $this->innerGateway->deleteRelations($contentId, $versionNo);
520
        } catch (DBALException $e) {
521
            throw new RuntimeException('Database error', 0, $e);
522
        } catch (PDOException $e) {
523
            throw new RuntimeException('Database error', 0, $e);
524
        }
525
    }
526
527
    /**
528
     * Removes relations to Content with $contentId from Relation and RelationList field type fields.
529
     *
530
     * @param int $contentId
531
     */
532
    public function removeReverseFieldRelations($contentId)
533
    {
534
        try {
535
            return $this->innerGateway->removeReverseFieldRelations($contentId);
536
        } catch (DBALException $e) {
537
            throw new RuntimeException('Database error', 0, $e);
538
        } catch (PDOException $e) {
539
            throw new RuntimeException('Database error', 0, $e);
540
        }
541
    }
542
543
    /**
544
     * Deletes the field with the given $fieldId.
545
     *
546
     * @param int $fieldId
547
     */
548
    public function deleteField($fieldId)
549
    {
550
        try {
551
            return $this->innerGateway->deleteField($fieldId);
552
        } catch (DBALException $e) {
553
            throw new RuntimeException('Database error', 0, $e);
554
        } catch (PDOException $e) {
555
            throw new RuntimeException('Database error', 0, $e);
556
        }
557
    }
558
559
    /**
560
     * Deletes all fields of $contentId in all versions.
561
     * If $versionNo is set only fields for that version are deleted.
562
     *
563
     * @param int $contentId
564
     * @param int|null $versionNo
565
     */
566
    public function deleteFields($contentId, $versionNo = null)
567
    {
568
        try {
569
            return $this->innerGateway->deleteFields($contentId, $versionNo);
570
        } catch (DBALException $e) {
571
            throw new RuntimeException('Database error', 0, $e);
572
        } catch (PDOException $e) {
573
            throw new RuntimeException('Database error', 0, $e);
574
        }
575
    }
576
577
    /**
578
     * Deletes all versions of $contentId.
579
     * If $versionNo is set only that version is deleted.
580
     *
581
     * @param int $contentId
582
     * @param int|null $versionNo
583
     */
584
    public function deleteVersions($contentId, $versionNo = null)
585
    {
586
        try {
587
            return $this->innerGateway->deleteVersions($contentId, $versionNo);
588
        } catch (DBALException $e) {
589
            throw new RuntimeException('Database error', 0, $e);
590
        } catch (PDOException $e) {
591
            throw new RuntimeException('Database error', 0, $e);
592
        }
593
    }
594
595
    /**
596
     * Deletes all names of $contentId.
597
     * If $versionNo is set only names for that version are deleted.
598
     *
599
     * @param int $contentId
600
     * @param int|null $versionNo
601
     */
602
    public function deleteNames($contentId, $versionNo = null)
603
    {
604
        try {
605
            return $this->innerGateway->deleteNames($contentId, $versionNo);
606
        } catch (DBALException $e) {
607
            throw new RuntimeException('Database error', 0, $e);
608
        } catch (PDOException $e) {
609
            throw new RuntimeException('Database error', 0, $e);
610
        }
611
    }
612
613
    /**
614
     * Sets the content object name.
615
     *
616
     * @param int $contentId
617
     * @param int $version
618
     * @param string $name
619
     * @param string $language
620
     */
621
    public function setName($contentId, $version, $name, $language)
622
    {
623
        try {
624
            return $this->innerGateway->setName($contentId, $version, $name, $language);
625
        } catch (DBALException $e) {
626
            throw new RuntimeException('Database error', 0, $e);
627
        } catch (PDOException $e) {
628
            throw new RuntimeException('Database error', 0, $e);
629
        }
630
    }
631
632
    /**
633
     * Deletes the actual content object referred to by $contentId.
634
     *
635
     * @param int $contentId
636
     */
637
    public function deleteContent($contentId)
638
    {
639
        try {
640
            return $this->innerGateway->deleteContent($contentId);
641
        } catch (DBALException $e) {
642
            throw new RuntimeException('Database error', 0, $e);
643
        } catch (PDOException $e) {
644
            throw new RuntimeException('Database error', 0, $e);
645
        }
646
    }
647
648
    /**
649
     * Loads data of related to/from $contentId.
650
     *
651
     * @param int $contentId
652
     * @param int $contentVersionNo
653
     * @param int $relationType
654
     *
655
     * @return mixed[][] Content data, array structured like {@see \eZ\Publish\Core\Persistence\Legacy\Content\Gateway::load()}
656
     */
657
    public function loadRelations($contentId, $contentVersionNo = null, $relationType = null)
658
    {
659
        try {
660
            return $this->innerGateway->loadRelations($contentId, $contentVersionNo, $relationType);
661
        } catch (DBALException $e) {
662
            throw new RuntimeException('Database error', 0, $e);
663
        } catch (PDOException $e) {
664
            throw new RuntimeException('Database error', 0, $e);
665
        }
666
    }
667
668
    /**
669
     * Loads data of related to/from $contentId.
670
     *
671
     * @param int $contentId
672
     * @param bool $reverse Reverse relation, default false
0 ignored issues
show
Bug introduced by
There is no parameter named $reverse. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
673
     * @param int $contentVersionNo
0 ignored issues
show
Bug introduced by
There is no parameter named $contentVersionNo. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
674
     * @param int $relationType
675
     *
676
     * @return mixed[][] Content data, array structured like {@see \eZ\Publish\Core\Persistence\Legacy\Content\Gateway::load()}
677
     */
678
    public function loadReverseRelations($contentId, $relationType = null)
679
    {
680
        try {
681
            return $this->innerGateway->loadReverseRelations($contentId, $relationType);
682
        } catch (DBALException $e) {
683
            throw new RuntimeException('Database error', 0, $e);
684
        } catch (PDOException $e) {
685
            throw new RuntimeException('Database error', 0, $e);
686
        }
687
    }
688
689
    /**
690
     * Deletes the relation with the given $relationId.
691
     *
692
     * @param int $relationId
693
     * @param int $type {@see \eZ\Publish\API\Repository\Values\Content\Relation::COMMON,
694
     *                 \eZ\Publish\API\Repository\Values\Content\Relation::EMBED,
695
     *                 \eZ\Publish\API\Repository\Values\Content\Relation::LINK,
696
     *                 \eZ\Publish\API\Repository\Values\Content\Relation::FIELD}
697
     */
698
    public function deleteRelation($relationId, $type)
699
    {
700
        try {
701
            return $this->innerGateway->deleteRelation($relationId, $type);
702
        } catch (DBALException $e) {
703
            throw new RuntimeException('Database error', 0, $e);
704
        } catch (PDOException $e) {
705
            throw new RuntimeException('Database error', 0, $e);
706
        }
707
    }
708
709
    /**
710
     * Inserts a new relation database record.
711
     *
712
     * @param \eZ\Publish\SPI\Persistence\Content\Relation\CreateStruct $createStruct
0 ignored issues
show
Documentation introduced by
There is no parameter named $createStruct. Did you maybe mean $struct?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
713
     *
714
     * @return int ID the inserted ID
715
     */
716
    public function insertRelation(RelationCreateStruct $struct)
717
    {
718
        try {
719
            return $this->innerGateway->insertRelation($struct);
720
        } catch (DBALException $e) {
721
            throw new RuntimeException('Database error', 0, $e);
722
        } catch (PDOException $e) {
723
            throw new RuntimeException('Database error', 0, $e);
724
        }
725
    }
726
727
    /**
728
     * Returns all Content IDs for a given $contentTypeId.
729
     *
730
     * @param int $contentTypeId
731
     *
732
     * @return int[]
733
     */
734
    public function getContentIdsByContentTypeId($contentTypeId)
735
    {
736
        try {
737
            return $this->innerGateway->getContentIdsByContentTypeId($contentTypeId);
738
        } catch (DBALException $e) {
739
            throw new RuntimeException('Database error', 0, $e);
740
        } catch (PDOException $e) {
741
            throw new RuntimeException('Database error', 0, $e);
742
        }
743
    }
744
745
    /**
746
     * Load name data for set of content id's and corresponding version number.
747
     *
748
     * @param array[] $rows array of hashes with 'id' and 'version' to load names for
749
     *
750
     * @return array
751
     */
752
    public function loadVersionedNameData($rows)
753
    {
754
        try {
755
            return $this->innerGateway->loadVersionedNameData($rows);
756
        } catch (DBALException $e) {
757
            throw new RuntimeException('Database error', 0, $e);
758
        } catch (PDOException $e) {
759
            throw new RuntimeException('Database error', 0, $e);
760
        }
761
    }
762
763
    /**
764
     * Batch method for copying all relation meta data for copied Content object.
765
     *
766
     * {@inheritdoc}
767
     *
768
     * @param int $originalContentId
769
     * @param int $copiedContentId
770
     * @param int|null $versionNo If specified only copy for a given version number, otherwise all.
771
     */
772
    public function copyRelations($originalContentId, $copiedContentId, $versionNo = null)
773
    {
774
        try {
775
            return $this->innerGateway->copyRelations($originalContentId, $copiedContentId, $versionNo);
776
        } catch (DBALException $e) {
777
            throw new RuntimeException('Database error', 0, $e);
778
        } catch (PDOException $e) {
779
            throw new RuntimeException('Database error', 0, $e);
780
        }
781
    }
782
783
    /**
784
     * Remove the specified translation from all the Versions of a Content Object.
785
     *
786
     * @param int $contentId
787
     * @param string $languageCode language code of the translation
788
     */
789
    public function deleteTranslationFromContent($contentId, $languageCode)
790
    {
791
        try {
792
            return $this->innerGateway->deleteTranslationFromContent($contentId, $languageCode);
793
        } catch (DBALException $e) {
794
            throw new RuntimeException('Database error', 0, $e);
795
        } catch (PDOException $e) {
796
            throw new RuntimeException('Database error', 0, $e);
797
        }
798
    }
799
800
    /**
801
     * Delete Content fields (attributes) for the given Translation.
802
     * If $versionNo is given, fields for that Version only will be deleted.
803
     *
804
     * @param string $languageCode
805
     * @param int $contentId
806
     * @param int $versionNo (optional) filter by versionNo
807
     */
808
    public function deleteTranslatedFields($languageCode, $contentId, $versionNo = null)
809
    {
810
        try {
811
            return $this->innerGateway->deleteTranslatedFields($languageCode, $contentId, $versionNo);
812
        } catch (DBALException $e) {
813
            throw new RuntimeException('Database error', 0, $e);
814
        } catch (PDOException $e) {
815
            throw new RuntimeException('Database error', 0, $e);
816
        }
817
    }
818
819
    /**
820
     * Delete the specified Translation from the given Version.
821
     *
822
     * @param int $contentId
823
     * @param int $versionNo
824
     * @param string $languageCode
825
     */
826
    public function deleteTranslationFromVersion($contentId, $versionNo, $languageCode)
827
    {
828
        try {
829
            return $this->innerGateway->deleteTranslationFromVersion($contentId, $versionNo, $languageCode);
830
        } catch (DBALException $e) {
831
            throw new RuntimeException('Database error', 0, $e);
832
        } catch (PDOException $e) {
833
            throw new RuntimeException('Database error', 0, $e);
834
        }
835
    }
836
}
837