Skip to content

Commit

Permalink
[BUGFIX] Always return a string for PHP 8.1
Browse files Browse the repository at this point in the history
The following deprecation occurred in PHP 8.1:
PHP Runtime Deprecation Notice: trim(): Passing null to parameter #1 ($string) of type string is deprecated.

This happens in various places:
* Using stdWrap_field() or in stdWrap() places
* BackendUtility (e.g. new IRRE elements)
* ExtensionManager

Resolves: #96354
Releases: main, 11.5
Change-Id: Ie5c721784b51ed5493c8d9e1d557b08611263f6b
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72659
Tested-by: core-ci <typo3@b13.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Benni Mack <benni@typo3.org>
  • Loading branch information
brotkrueml authored and bmack committed Dec 15, 2021
1 parent 08ecbd7 commit 8c7227c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
16 changes: 10 additions & 6 deletions typo3/sysext/backend/Classes/Utility/BackendUtility.php
Expand Up @@ -629,12 +629,16 @@ public static function getTCAtypeValue($table, $row)
$field = $GLOBALS['TCA'][$table]['ctrl']['type'] ?? '';
if (str_contains($field, ':')) {
[$pointerField, $foreignTableTypeField] = explode(':', $field);
// Get field value from database if field is not in the $row array
if (!isset($row[$pointerField])) {
$localRow = self::getRecord($table, $row['uid'], $pointerField);
$foreignUid = $localRow[$pointerField];
} else {
$foreignUid = $row[$pointerField];
// Check if the record has been persisted already
$foreignUid = 0;
if (isset($row['uid'])) {
// Get field value from database if field is not in the $row array
if (!isset($row[$pointerField])) {
$localRow = self::getRecord($table, $row['uid'], $pointerField);
$foreignUid = $localRow[$pointerField];
} else {
$foreignUid = $row[$pointerField];
}
}
if ($foreignUid) {
$fieldConfig = $GLOBALS['TCA'][$table]['columns'][$pointerField]['config'];
Expand Down
6 changes: 3 additions & 3 deletions typo3/sysext/core/Classes/Package/Package.php
Expand Up @@ -138,11 +138,11 @@ protected function loadFlagsFromComposerManifest()
protected function createPackageMetaData(PackageManager $packageManager)
{
$this->packageMetaData = new MetaData($this->getPackageKey());
$description = $this->getValueFromComposerManifest('description');
$description = (string)$this->getValueFromComposerManifest('description');
$this->packageMetaData->setDescription($description);
$this->packageMetaData->setTitle($this->getValueFromComposerManifest('title') ?? $description);
$this->packageMetaData->setVersion($this->getValueFromComposerManifest('version'));
$this->packageMetaData->setPackageType($this->getValueFromComposerManifest('type'));
$this->packageMetaData->setVersion((string)$this->getValueFromComposerManifest('version'));
$this->packageMetaData->setPackageType((string)$this->getValueFromComposerManifest('type'));
$requirements = $this->getValueFromComposerManifest('require');
if ($requirements !== null) {
foreach ($requirements as $requirement => $version) {
Expand Down
Expand Up @@ -1287,7 +1287,7 @@ public function stdWrap($content = '', $conf = [])
unset($this->stopRendering[$this->stdWrapRecursionLevel]);
$this->stdWrapRecursionLevel--;

return $content;
return (string)$content;
}

/**
Expand Down Expand Up @@ -1443,7 +1443,7 @@ public function stdWrap_data($_ = '', $conf = [])
*/
public function stdWrap_field($content = '', $conf = [])
{
return $this->getFieldVal($conf['field']);
return (string)$this->getFieldVal($conf['field']);
}

/**
Expand Down Expand Up @@ -5784,8 +5784,8 @@ public function getQuery($table, $conf, $returnQueryArray = false)
foreach ($properties as $property) {
$conf[$property] = trim(
isset($conf[$property . '.'])
? $this->stdWrap($conf[$property] ?? '', $conf[$property . '.'] ?? [])
: ($conf[$property] ?? '')
? (string)$this->stdWrap($conf[$property] ?? '', $conf[$property . '.'] ?? [])
: (string)($conf[$property] ?? '')
);
if ($conf[$property] === '') {
unset($conf[$property]);
Expand Down

0 comments on commit 8c7227c

Please sign in to comment.