Skip to content

Commit

Permalink
[BUGFIX] Prevent error when overlay is not available
Browse files Browse the repository at this point in the history
This fixes:

Core: Error handler (BE): PHP Warning: Trying to access array offset on value of type null in /var/www/vendor/apache-solr-for-typo3/solr/Classes/ContentObject/Relation.php line 311
  • Loading branch information
magicsunday authored and dkd-kaehm committed Dec 11, 2024
1 parent a3da67a commit f42ea47
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Classes/ContentObject/Relation.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,15 @@ protected function resolveRelatedValue(
string $foreignTableName = '',
): array {
if ($this->getLanguageUid() > 0 && !empty($foreignTableName)) {
$relatedRecord = $this->getFrontendOverlayService()->getOverlay($foreignTableName, $relatedRecord);
$overlayRelatedRecord = $this->getFrontendOverlayService($parentContentObject)->getOverlay($foreignTableName, $relatedRecord);

Check failure on line 306 in Classes/ContentObject/Relation.php

View workflow job for this annotation

GitHub Actions / TYPO3 12 on PHP 8.1

Method ApacheSolrForTypo3\Solr\ContentObject\Relation::getFrontendOverlayService() invoked with 1 parameter, 0 required.

Check failure on line 306 in Classes/ContentObject/Relation.php

View workflow job for this annotation

GitHub Actions / TYPO3 12.4.x-dev on PHP 8.1

Method ApacheSolrForTypo3\Solr\ContentObject\Relation::getFrontendOverlayService() invoked with 1 parameter, 0 required.

Check failure on line 306 in Classes/ContentObject/Relation.php

View workflow job for this annotation

GitHub Actions / TYPO3 12 on PHP 8.2

Method ApacheSolrForTypo3\Solr\ContentObject\Relation::getFrontendOverlayService() invoked with 1 parameter, 0 required.

Check failure on line 306 in Classes/ContentObject/Relation.php

View workflow job for this annotation

GitHub Actions / TYPO3 12.4.x-dev on PHP 8.2

Method ApacheSolrForTypo3\Solr\ContentObject\Relation::getFrontendOverlayService() invoked with 1 parameter, 0 required.

Check failure on line 306 in Classes/ContentObject/Relation.php

View workflow job for this annotation

GitHub Actions / TYPO3 12 on PHP 8.3

Method ApacheSolrForTypo3\Solr\ContentObject\Relation::getFrontendOverlayService() invoked with 1 parameter, 0 required.

Check failure on line 306 in Classes/ContentObject/Relation.php

View workflow job for this annotation

GitHub Actions / TYPO3 12.4.x-dev on PHP 8.3

Method ApacheSolrForTypo3\Solr\ContentObject\Relation::getFrontendOverlayService() invoked with 1 parameter, 0 required.

Check failure on line 306 in Classes/ContentObject/Relation.php

View workflow job for this annotation

GitHub Actions / TYPO3 12 on PHP 8.4

Method ApacheSolrForTypo3\Solr\ContentObject\Relation::getFrontendOverlayService() invoked with 1 parameter, 0 required.

Check failure on line 306 in Classes/ContentObject/Relation.php

View workflow job for this annotation

GitHub Actions / TYPO3 12.4.x-dev on PHP 8.4

Method ApacheSolrForTypo3\Solr\ContentObject\Relation::getFrontendOverlayService() invoked with 1 parameter, 0 required.
}

// sys_page->getLanguageOverlay() may return NULL if overlays were activated but no overlay
// was found and LanguageAspect was NOT set to MIXED
//
// If so rely on original record data
if (is_array($overlayRelatedRecord)) {

Check failure on line 313 in Classes/ContentObject/Relation.php

View workflow job for this annotation

GitHub Actions / TYPO3 12 on PHP 8.1

Variable $overlayRelatedRecord might not be defined.

Check failure on line 313 in Classes/ContentObject/Relation.php

View workflow job for this annotation

GitHub Actions / TYPO3 12.4.x-dev on PHP 8.1

Variable $overlayRelatedRecord might not be defined.

Check failure on line 313 in Classes/ContentObject/Relation.php

View workflow job for this annotation

GitHub Actions / TYPO3 12 on PHP 8.2

Variable $overlayRelatedRecord might not be defined.

Check failure on line 313 in Classes/ContentObject/Relation.php

View workflow job for this annotation

GitHub Actions / TYPO3 12.4.x-dev on PHP 8.2

Variable $overlayRelatedRecord might not be defined.

Check failure on line 313 in Classes/ContentObject/Relation.php

View workflow job for this annotation

GitHub Actions / TYPO3 12 on PHP 8.3

Variable $overlayRelatedRecord might not be defined.

Check failure on line 313 in Classes/ContentObject/Relation.php

View workflow job for this annotation

GitHub Actions / TYPO3 12.4.x-dev on PHP 8.3

Variable $overlayRelatedRecord might not be defined.

Check failure on line 313 in Classes/ContentObject/Relation.php

View workflow job for this annotation

GitHub Actions / TYPO3 12 on PHP 8.4

Variable $overlayRelatedRecord might not be defined.

Check failure on line 313 in Classes/ContentObject/Relation.php

View workflow job for this annotation

GitHub Actions / TYPO3 12.4.x-dev on PHP 8.4

Variable $overlayRelatedRecord might not be defined.
$relatedRecord = $overlayRelatedRecord;
}

$contentObject = clone $parentContentObject;
Expand Down

0 comments on commit f42ea47

Please sign in to comment.