Completed
Push — parallel_test_fork ( b1fcc3...0461b5 )
by
unknown
33:11 queued 13:37
created

ExceptionConversion::setPublishedStatus()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 2
dl 0
loc 10
rs 9.9332
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 (BadStateException $e) {
181
            throw $e;
182
        } catch (DBALException | PDOException $e) {
183
            throw new RuntimeException('Database error', 0, $e);
184
        }
185
    }
186
187
    /**
188
     * Inserts a new field.
189
     *
190
     * Only used when a new field is created (i.e. a new object or a field in a
191
     * new language!). After that, field IDs need to stay the same, only the
192
     * version number changes.
193
     *
194
     * @param \eZ\Publish\SPI\Persistence\Content $content
195
     * @param \eZ\Publish\SPI\Persistence\Content\Field $field
196
     * @param \eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldValue $value
197
     *
198
     * @return int ID
199
     */
200
    public function insertNewField(Content $content, Field $field, StorageFieldValue $value)
201
    {
202
        try {
203
            return $this->innerGateway->insertNewField($content, $field, $value);
204
        } catch (DBALException $e) {
205
            throw new RuntimeException('Database error', 0, $e);
206
        } catch (PDOException $e) {
207
            throw new RuntimeException('Database error', 0, $e);
208
        }
209
    }
210
211
    /**
212
     * Inserts an existing field.
213
     *
214
     * Used to insert a field with an exsting ID but a new version number.
215
     *
216
     * @param Content $content
217
     * @param Field $field
218
     * @param StorageFieldValue $value
219
     */
220
    public function insertExistingField(Content $content, Field $field, StorageFieldValue $value)
221
    {
222
        try {
223
            return $this->innerGateway->insertExistingField($content, $field, $value);
224
        } catch (DBALException $e) {
225
            throw new RuntimeException('Database error', 0, $e);
226
        } catch (PDOException $e) {
227
            throw new RuntimeException('Database error', 0, $e);
228
        }
229
    }
230
231
    /**
232
     * Updates an existing field.
233
     *
234
     * @param Field $field
235
     * @param StorageFieldValue $value
236
     */
237
    public function updateField(Field $field, StorageFieldValue $value)
238
    {
239
        try {
240
            return $this->innerGateway->updateField($field, $value);
241
        } catch (DBALException $e) {
242
            throw new RuntimeException('Database error', 0, $e);
243
        } catch (PDOException $e) {
244
            throw new RuntimeException('Database error', 0, $e);
245
        }
246
    }
247
248
    /**
249
     * Updates an existing, non-translatable field.
250
     *
251
     * @param \eZ\Publish\SPI\Persistence\Content\Field $field
252
     * @param \eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldValue $value
253
     * @param int $contentId
254
     */
255
    public function updateNonTranslatableField(
256
        Field $field,
257
        StorageFieldValue $value,
258
        $contentId
259
    ) {
260
        try {
261
            return $this->innerGateway->updateNonTranslatableField($field, $value, $contentId);
262
        } catch (DBALException $e) {
263
            throw new RuntimeException('Database error', 0, $e);
264
        } catch (PDOException $e) {
265
            throw new RuntimeException('Database error', 0, $e);
266
        }
267
    }
268
269
    /**
270
     * {@inheritdoc}
271
     */
272
    public function load($contentId, $version = null, array $translations = null)
273
    {
274
        try {
275
            return $this->innerGateway->load($contentId, $version, $translations);
0 ignored issues
show
Bug introduced by
It seems like $translations defined by parameter $translations on line 272 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...
276
        } catch (DBALException $e) {
277
            throw new RuntimeException('Database error', 0, $e);
278
        } catch (PDOException $e) {
279
            throw new RuntimeException('Database error', 0, $e);
280
        }
281
    }
282
283
    /**
284
     * {@inheritdoc}
285
     */
286
    public function loadContentList(array $contentIds, array $translations = null): array
287
    {
288
        try {
289
            return $this->innerGateway->loadContentList($contentIds, $translations);
0 ignored issues
show
Bug introduced by
It seems like $translations defined by parameter $translations on line 286 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...
290
        } catch (DBALException | PDOException $e) {
291
            throw new RuntimeException('Database error', 0, $e);
292
        }
293
    }
294
295
    /**
296
     * Loads data for a content object identified by its remote ID.
297
     *
298
     * Returns an array with the relevant data.
299
     *
300
     * @param mixed $remoteId
301
     *
302
     * @return array
303
     */
304
    public function loadContentInfoByRemoteId($remoteId)
305
    {
306
        try {
307
            return $this->innerGateway->loadContentInfoByRemoteId($remoteId);
308
        } catch (DBALException $e) {
309
            throw new \RuntimeException('Database error', 0, $e);
310
        } catch (\PDOException $e) {
311
            throw new \RuntimeException('Database error', 0, $e);
312
        }
313
    }
314
315
    /**
316
     * Loads info for a content object identified by its location ID (node ID).
317
     *
318
     * Returns an array with the relevant data.
319
     *
320
     * @param int $locationId
321
     *
322
     * @throws \eZ\Publish\Core\Base\Exceptions\NotFoundException
323
     *
324
     * @return array
325
     */
326
    public function loadContentInfoByLocationId($locationId)
327
    {
328
        try {
329
            return $this->innerGateway->loadContentInfoByLocationId($locationId);
330
        } catch (DBALException $e) {
331
            throw new \RuntimeException('Database error', 0, $e);
332
        } catch (\PDOException $e) {
333
            throw new \RuntimeException('Database error', 0, $e);
334
        }
335
    }
336
337
    /**
338
     * Loads info for content identified by $contentId.
339
     * Will basically return a hash containing all field values for ezcontentobject table plus following keys:
340
     *  - always_available => Boolean indicating if content's language mask contains alwaysAvailable bit field
341
     *  - main_language_code => Language code for main (initial) language. E.g. "eng-GB".
342
     *
343
     * @param int $contentId
344
     *
345
     * @throws \eZ\Publish\Core\Base\Exceptions\NotFoundException
346
     *
347
     * @return array
348
     */
349
    public function loadContentInfo($contentId)
350
    {
351
        try {
352
            return $this->innerGateway->loadContentInfo($contentId);
353
        } catch (DBALException $e) {
354
            throw new RuntimeException('Database error', 0, $e);
355
        } catch (PDOException $e) {
356
            throw new RuntimeException('Database error', 0, $e);
357
        }
358
    }
359
360
    public function loadContentInfoList(array $contentIds)
361
    {
362
        try {
363
            return $this->innerGateway->loadContentInfoList($contentIds);
364
        } catch (DBALException $e) {
365
            throw new RuntimeException('Database error', 0, $e);
366
        } catch (PDOException $e) {
367
            throw new RuntimeException('Database error', 0, $e);
368
        }
369
    }
370
371
    /**
372
     * Loads version info for content identified by $contentId and $versionNo.
373
     * Will basically return a hash containing all field values from ezcontentobject_version table plus following keys:
374
     *  - names => Hash of content object names. Key is the language code, value is the name.
375
     *  - 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.
376
     *  - initial_language_code => Language code for initial language in this version.
377
     *
378
     * @param int $contentId
379
     * @param int $versionNo
380
     *
381
     * @return array
382
     */
383
    public function loadVersionInfo($contentId, $versionNo)
384
    {
385
        try {
386
            return $this->innerGateway->loadVersionInfo($contentId, $versionNo);
387
        } catch (DBALException $e) {
388
            throw new RuntimeException('Database error', 0, $e);
389
        } catch (PDOException $e) {
390
            throw new RuntimeException('Database error', 0, $e);
391
        }
392
    }
393
394
    /**
395
     * Returns data for all versions with given status created by the given $userId.
396
     *
397
     * @param int $userId
398
     * @param int $status
399
     *
400
     * @return string[][]
401
     */
402
    public function listVersionsForUser($userId, $status = VersionInfo::STATUS_DRAFT)
403
    {
404
        try {
405
            return $this->innerGateway->listVersionsForUser($userId, $status);
406
        } catch (DBALException $e) {
407
            throw new RuntimeException('Database error', 0, $e);
408
        } catch (PDOException $e) {
409
            throw new RuntimeException('Database error', 0, $e);
410
        }
411
    }
412
413
    /**
414
     * Returns all version data for the given $contentId.
415
     *
416
     * Result is returned with oldest version first (using version id as it has index and is auto increment).
417
     *
418
     * @param mixed $contentId
419
     * @param mixed|null $status Optional argument to filter versions by status, like {@see VersionInfo::STATUS_ARCHIVED}.
420
     * @param int $limit Limit for items returned, -1 means none.
421
     *
422
     * @return string[][]
423
     */
424
    public function listVersions($contentId, $status = null, $limit = -1)
425
    {
426
        try {
427
            return $this->innerGateway->listVersions($contentId, $status, $limit);
428
        } catch (DBALException $e) {
429
            throw new RuntimeException('Database error', 0, $e);
430
        } catch (PDOException $e) {
431
            throw new RuntimeException('Database error', 0, $e);
432
        }
433
    }
434
435
    /**
436
     * Returns all version numbers for the given $contentId.
437
     *
438
     * @param mixed $contentId
439
     *
440
     * @return int[]
441
     */
442
    public function listVersionNumbers($contentId)
443
    {
444
        try {
445
            return $this->innerGateway->listVersionNumbers($contentId);
446
        } catch (DBALException $e) {
447
            throw new RuntimeException('Database error', 0, $e);
448
        } catch (PDOException $e) {
449
            throw new RuntimeException('Database error', 0, $e);
450
        }
451
    }
452
453
    /**
454
     * Returns last version number for content identified by $contentId.
455
     *
456
     * @param int $contentId
457
     *
458
     * @return int
459
     */
460
    public function getLastVersionNumber($contentId)
461
    {
462
        try {
463
            return $this->innerGateway->getLastVersionNumber($contentId);
464
        } catch (DBALException $e) {
465
            throw new RuntimeException('Database error', 0, $e);
466
        } catch (PDOException $e) {
467
            throw new RuntimeException('Database error', 0, $e);
468
        }
469
    }
470
471
    /**
472
     * Returns all IDs for locations that refer to $contentId.
473
     *
474
     * @param int $contentId
475
     *
476
     * @return int[]
477
     */
478
    public function getAllLocationIds($contentId)
479
    {
480
        try {
481
            return $this->innerGateway->getAllLocationIds($contentId);
482
        } catch (DBALException $e) {
483
            throw new RuntimeException('Database error', 0, $e);
484
        } catch (PDOException $e) {
485
            throw new RuntimeException('Database error', 0, $e);
486
        }
487
    }
488
489
    /**
490
     * Returns all field IDs of $contentId grouped by their type.
491
     * If $versionNo is set only field IDs for that version are returned.
492
     * If $languageCode is set, only field IDs for that language are returned.
493
     *
494
     * @param int $contentId
495
     * @param int|null $versionNo
496
     * @param string|null $languageCode
497
     *
498
     * @return int[][]
499
     */
500
    public function getFieldIdsByType($contentId, $versionNo = null, $languageCode = null)
501
    {
502
        try {
503
            return $this->innerGateway->getFieldIdsByType($contentId, $versionNo, $languageCode);
504
        } catch (DBALException $e) {
505
            throw new RuntimeException('Database error', 0, $e);
506
        } catch (PDOException $e) {
507
            throw new RuntimeException('Database error', 0, $e);
508
        }
509
    }
510
511
    /**
512
     * Deletes relations to and from $contentId.
513
     * If $versionNo is set only relations for that version are deleted.
514
     *
515
     * @param int $contentId
516
     * @param int|null $versionNo
517
     */
518
    public function deleteRelations($contentId, $versionNo = null)
519
    {
520
        try {
521
            return $this->innerGateway->deleteRelations($contentId, $versionNo);
522
        } catch (DBALException $e) {
523
            throw new RuntimeException('Database error', 0, $e);
524
        } catch (PDOException $e) {
525
            throw new RuntimeException('Database error', 0, $e);
526
        }
527
    }
528
529
    /**
530
     * Removes relations to Content with $contentId from Relation and RelationList field type fields.
531
     *
532
     * @param int $contentId
533
     */
534
    public function removeReverseFieldRelations($contentId)
535
    {
536
        try {
537
            return $this->innerGateway->removeReverseFieldRelations($contentId);
538
        } catch (DBALException $e) {
539
            throw new RuntimeException('Database error', 0, $e);
540
        } catch (PDOException $e) {
541
            throw new RuntimeException('Database error', 0, $e);
542
        }
543
    }
544
545
    /**
546
     * Deletes the field with the given $fieldId.
547
     *
548
     * @param int $fieldId
549
     */
550
    public function deleteField($fieldId)
551
    {
552
        try {
553
            return $this->innerGateway->deleteField($fieldId);
554
        } catch (DBALException $e) {
555
            throw new RuntimeException('Database error', 0, $e);
556
        } catch (PDOException $e) {
557
            throw new RuntimeException('Database error', 0, $e);
558
        }
559
    }
560
561
    /**
562
     * Deletes all fields of $contentId in all versions.
563
     * If $versionNo is set only fields for that version are deleted.
564
     *
565
     * @param int $contentId
566
     * @param int|null $versionNo
567
     */
568
    public function deleteFields($contentId, $versionNo = null)
569
    {
570
        try {
571
            return $this->innerGateway->deleteFields($contentId, $versionNo);
572
        } catch (DBALException $e) {
573
            throw new RuntimeException('Database error', 0, $e);
574
        } catch (PDOException $e) {
575
            throw new RuntimeException('Database error', 0, $e);
576
        }
577
    }
578
579
    /**
580
     * Deletes all versions of $contentId.
581
     * If $versionNo is set only that version is deleted.
582
     *
583
     * @param int $contentId
584
     * @param int|null $versionNo
585
     */
586
    public function deleteVersions($contentId, $versionNo = null)
587
    {
588
        try {
589
            return $this->innerGateway->deleteVersions($contentId, $versionNo);
590
        } catch (DBALException $e) {
591
            throw new RuntimeException('Database error', 0, $e);
592
        } catch (PDOException $e) {
593
            throw new RuntimeException('Database error', 0, $e);
594
        }
595
    }
596
597
    /**
598
     * Deletes all names of $contentId.
599
     * If $versionNo is set only names for that version are deleted.
600
     *
601
     * @param int $contentId
602
     * @param int|null $versionNo
603
     */
604
    public function deleteNames($contentId, $versionNo = null)
605
    {
606
        try {
607
            return $this->innerGateway->deleteNames($contentId, $versionNo);
608
        } catch (DBALException $e) {
609
            throw new RuntimeException('Database error', 0, $e);
610
        } catch (PDOException $e) {
611
            throw new RuntimeException('Database error', 0, $e);
612
        }
613
    }
614
615
    /**
616
     * Sets the content object name.
617
     *
618
     * @param int $contentId
619
     * @param int $version
620
     * @param string $name
621
     * @param string $language
622
     */
623
    public function setName($contentId, $version, $name, $language)
624
    {
625
        try {
626
            return $this->innerGateway->setName($contentId, $version, $name, $language);
627
        } catch (DBALException $e) {
628
            throw new RuntimeException('Database error', 0, $e);
629
        } catch (PDOException $e) {
630
            throw new RuntimeException('Database error', 0, $e);
631
        }
632
    }
633
634
    /**
635
     * Deletes the actual content object referred to by $contentId.
636
     *
637
     * @param int $contentId
638
     */
639
    public function deleteContent($contentId)
640
    {
641
        try {
642
            return $this->innerGateway->deleteContent($contentId);
643
        } catch (DBALException $e) {
644
            throw new RuntimeException('Database error', 0, $e);
645
        } catch (PDOException $e) {
646
            throw new RuntimeException('Database error', 0, $e);
647
        }
648
    }
649
650
    /**
651
     * Loads data of related to/from $contentId.
652
     *
653
     * @param int $contentId
654
     * @param int $contentVersionNo
655
     * @param int $relationType
656
     *
657
     * @return mixed[][] Content data, array structured like {@see \eZ\Publish\Core\Persistence\Legacy\Content\Gateway::load()}
658
     */
659
    public function loadRelations($contentId, $contentVersionNo = null, $relationType = null)
660
    {
661
        try {
662
            return $this->innerGateway->loadRelations($contentId, $contentVersionNo, $relationType);
663
        } catch (DBALException $e) {
664
            throw new RuntimeException('Database error', 0, $e);
665
        } catch (PDOException $e) {
666
            throw new RuntimeException('Database error', 0, $e);
667
        }
668
    }
669
670
    /**
671
     * Loads data of related to/from $contentId.
672
     *
673
     * @param int $contentId
674
     * @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...
675
     * @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...
676
     * @param int $relationType
677
     *
678
     * @return mixed[][] Content data, array structured like {@see \eZ\Publish\Core\Persistence\Legacy\Content\Gateway::load()}
679
     */
680
    public function loadReverseRelations($contentId, $relationType = null)
681
    {
682
        try {
683
            return $this->innerGateway->loadReverseRelations($contentId, $relationType);
684
        } catch (DBALException $e) {
685
            throw new RuntimeException('Database error', 0, $e);
686
        } catch (PDOException $e) {
687
            throw new RuntimeException('Database error', 0, $e);
688
        }
689
    }
690
691
    /**
692
     * Deletes the relation with the given $relationId.
693
     *
694
     * @param int $relationId
695
     * @param int $type {@see \eZ\Publish\API\Repository\Values\Content\Relation::COMMON,
696
     *                 \eZ\Publish\API\Repository\Values\Content\Relation::EMBED,
697
     *                 \eZ\Publish\API\Repository\Values\Content\Relation::LINK,
698
     *                 \eZ\Publish\API\Repository\Values\Content\Relation::FIELD}
699
     */
700
    public function deleteRelation($relationId, $type)
701
    {
702
        try {
703
            return $this->innerGateway->deleteRelation($relationId, $type);
704
        } catch (DBALException $e) {
705
            throw new RuntimeException('Database error', 0, $e);
706
        } catch (PDOException $e) {
707
            throw new RuntimeException('Database error', 0, $e);
708
        }
709
    }
710
711
    /**
712
     * Inserts a new relation database record.
713
     *
714
     * @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...
715
     *
716
     * @return int ID the inserted ID
717
     */
718
    public function insertRelation(RelationCreateStruct $struct)
719
    {
720
        try {
721
            return $this->innerGateway->insertRelation($struct);
722
        } catch (DBALException $e) {
723
            throw new RuntimeException('Database error', 0, $e);
724
        } catch (PDOException $e) {
725
            throw new RuntimeException('Database error', 0, $e);
726
        }
727
    }
728
729
    /**
730
     * Returns all Content IDs for a given $contentTypeId.
731
     *
732
     * @param int $contentTypeId
733
     *
734
     * @return int[]
735
     */
736
    public function getContentIdsByContentTypeId($contentTypeId)
737
    {
738
        try {
739
            return $this->innerGateway->getContentIdsByContentTypeId($contentTypeId);
740
        } catch (DBALException $e) {
741
            throw new RuntimeException('Database error', 0, $e);
742
        } catch (PDOException $e) {
743
            throw new RuntimeException('Database error', 0, $e);
744
        }
745
    }
746
747
    /**
748
     * Load name data for set of content id's and corresponding version number.
749
     *
750
     * @param array[] $rows array of hashes with 'id' and 'version' to load names for
751
     *
752
     * @return array
753
     */
754
    public function loadVersionedNameData($rows)
755
    {
756
        try {
757
            return $this->innerGateway->loadVersionedNameData($rows);
758
        } catch (DBALException $e) {
759
            throw new RuntimeException('Database error', 0, $e);
760
        } catch (PDOException $e) {
761
            throw new RuntimeException('Database error', 0, $e);
762
        }
763
    }
764
765
    /**
766
     * Batch method for copying all relation meta data for copied Content object.
767
     *
768
     * {@inheritdoc}
769
     *
770
     * @param int $originalContentId
771
     * @param int $copiedContentId
772
     * @param int|null $versionNo If specified only copy for a given version number, otherwise all.
773
     */
774
    public function copyRelations($originalContentId, $copiedContentId, $versionNo = null)
775
    {
776
        try {
777
            return $this->innerGateway->copyRelations($originalContentId, $copiedContentId, $versionNo);
778
        } catch (DBALException $e) {
779
            throw new RuntimeException('Database error', 0, $e);
780
        } catch (PDOException $e) {
781
            throw new RuntimeException('Database error', 0, $e);
782
        }
783
    }
784
785
    /**
786
     * Remove the specified translation from all the Versions of a Content Object.
787
     *
788
     * @param int $contentId
789
     * @param string $languageCode language code of the translation
790
     */
791
    public function deleteTranslationFromContent($contentId, $languageCode)
792
    {
793
        try {
794
            return $this->innerGateway->deleteTranslationFromContent($contentId, $languageCode);
795
        } catch (DBALException $e) {
796
            throw new RuntimeException('Database error', 0, $e);
797
        } catch (PDOException $e) {
798
            throw new RuntimeException('Database error', 0, $e);
799
        }
800
    }
801
802
    /**
803
     * Delete Content fields (attributes) for the given Translation.
804
     * If $versionNo is given, fields for that Version only will be deleted.
805
     *
806
     * @param string $languageCode
807
     * @param int $contentId
808
     * @param int $versionNo (optional) filter by versionNo
809
     */
810
    public function deleteTranslatedFields($languageCode, $contentId, $versionNo = null)
811
    {
812
        try {
813
            return $this->innerGateway->deleteTranslatedFields($languageCode, $contentId, $versionNo);
814
        } catch (DBALException $e) {
815
            throw new RuntimeException('Database error', 0, $e);
816
        } catch (PDOException $e) {
817
            throw new RuntimeException('Database error', 0, $e);
818
        }
819
    }
820
821
    /**
822
     * Delete the specified Translation from the given Version.
823
     *
824
     * @param int $contentId
825
     * @param int $versionNo
826
     * @param string $languageCode
827
     */
828
    public function deleteTranslationFromVersion($contentId, $versionNo, $languageCode)
829
    {
830
        try {
831
            return $this->innerGateway->deleteTranslationFromVersion($contentId, $versionNo, $languageCode);
832
        } catch (DBALException $e) {
833
            throw new RuntimeException('Database error', 0, $e);
834
        } catch (PDOException $e) {
835
            throw new RuntimeException('Database error', 0, $e);
836
        }
837
    }
838
}
839