Skip to content

Error due to parameter array #472

@DavidBruchmann

Description

@DavidBruchmann

In the Backend this entry of the Log is always triggered:

Core: Error handler (FE): PHP Warning: Array to string conversion in /var/www/html/vendor/typo3/cms-core/Classes/Utility/GeneralUtility.php line 1026

In the named method of GeneralUtility I debugged it:

$arr (json for debugging): {
    "src":"\/fileadmin\/T3SB\/Resources\/Public\/JavaScript\/bootstrap.bundle.min.js?1772612148",
    "jsFile.":{
        "async":"1"
    }
}
$attributeValue (json for debugging): {
    "async":"1"
}
USED in GeneralUtilit::implodeAttributes():
    (string)$attributeValue: Array
                             ^^^^^ this Array is triggering the ERROR[12:27 PM]

The nested structure in the first part above ($arr) is responsible for the entry.

I debugged it like this:

(\TYPO3\CMS\Core\Utility\GeneralUtility)

public static function implodeAttributes(array $arr, bool $xhtmlSafe = false, bool $keepBlankAttributes = false): string
    {
        if ($xhtmlSafe) {
            $newArr = [];
            foreach ($arr as $attributeName => $attributeValue) {
                $attributeName = strtolower($attributeName);
                if (!isset($newArr[$attributeName])) {
                    // DEBUGGING START
                    if (is_array($attributeValue)) {
                        file_put_contents('debug_implodeAttributes.log', '$arr: ' . json_encode($arr) . "\n", FILE_APPEND);
                        file_put_contents('debug_implodeAttributes.log', '$attributeValue: ' . json_encode($attributeValue) . "\n", FILE_APPEND);
                        file_put_contents('debug_implodeAttributes.log', '(string)$attributeValue: ' . (string)$attributeValue . "\n", FILE_APPEND);
                        file_put_contents('debug_implodeAttributes.log', "\n", FILE_APPEND);
                    }
                    // DEBUGGING END
                    $newArr[$attributeName] = htmlspecialchars((string)$attributeValue);
                }
            }
            $arr = $newArr;
        }
        $list = [];
        foreach ($arr as $attributeName => $attributeValue) {
            if ((string)$attributeValue !== '' || $keepBlankAttributes) {
                $list[] = $attributeName . '="' . $attributeValue . '"';
            }
        }
        return implode(' ', $list);
    }

I think the structure of the array should be changed in t3sbootstrap.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions