Search code examples
extbasetypo3-6.2.x

TYPO3 Extbase FE-Extension plugin failing with: PHP Warning: rawurlencode() expects parameter 1 to be string, object given


This question is based on my previous one where my entire TYPO3 website didn't work.
Now, after adjusting the php-version (5.6.17) the website itself works, but one fe-plugin of my extbase extension doesn't work - even though it's identical to the one on a copy of the website where everything works. The other fe-plugin from the same extension directly worked out of the box.

I get the following error in the frontend whenever I call a page that contains this plugin and I don't know where to start searching for the cause.
(I changed my domain to <mydomain> and my plugin name to tx_myfeplugin_nameexte in the following error snippet):

#1: PHP Warning: rawurlencode() expects parameter 1 to be string, object given in /var/www/vhosts/<my-domain>/typo3/sysext/core/Classes/Utility/GeneralUtility.php line 1641 (More information)

TYPO3\CMS\Core\Error\Exception thrown in file
/var/www/vhosts/<my-domain>/typo3/sysext/core/Classes/Error/ErrorHandler.php in line 101.

49 TYPO3\CMS\Core\Error\ErrorHandler::handleError(2, "rawurlencode() expects parameter 1 to be string, object given", "/var/www/vhosts/<my-domain>…po3/sysext/core/Classes/Utility/GeneralUtility.php", 1641, array)

48 rawurlencode(TYPO3\CMS\Extbase\Persistence\Generic\QueryResult)


/var/www/vhosts/<my-domain>/typo3/sysext/core/Classes/Utility/GeneralUtility.php:

01639:    } else {
01640:     if (!$skipBlank || (string)$AVal !== '') {

01641:      $str .= '&' . ($rawurlencodeParamName ? rawurlencode($thisKeyName) : $thisKeyName) . '=' . rawurlencode($AVal);

01642:     }
01643:    }


47 TYPO3\CMS\Core\Utility\GeneralUtility::implodeArrayForUrl("tx_myfeplugin_nameexte", array, "", boolean, boolean)


/var/www/vhosts/<my-domain>/typo3/sysext/core/Classes/Utility/GeneralUtility.php:

01636:    $thisKeyName = $name ? $name . '[' . $Akey . ']' : $Akey;
01637:    if (is_array($AVal)) {

01638:     $str = self::implodeArrayForUrl($thisKeyName, $AVal, $str, $skipBlank, $rawurlencodeParamName);

01639:    } else {
01640:     if (!$skipBlank || (string)$AVal !== '') {

Did someone have the same error before or has an idea what I should try to do to fix this?

Thanks to the answer I guess I fixed it, because the error is not appearing any longer, by adding the following lines at line 1707 in file GeneralUtility.php:

if ($AVal instanceof \TYPO3\CMS\Extbase\Persistence\Generic\QueryResult) {
   $AVal = $AVal->toArray();
}

Solution

  • lets have a look to the source:

    foreach ($theArray as $Akey => $AVal) {
        $thisKeyName = $name ? $name . '[' . $Akey . ']' : $Akey;
        if (is_array($AVal)) {
               $str = self::implodeArrayForUrl($thisKeyName, $AVal, $str, $skipBlank, $rawurlencodeParamName);
            } else {
                if (!$skipBlank || (string)$AVal !== '') {
                    $str .= '&' . ($rawurlencodeParamName ? rawurlencode($thisKeyName) : $thisKeyName . '=' . rawurlencode($AVal);
            }
        }
    }
    

    The array you give has to be a multidimensional array as it represents the parts of the url. Every element is testet being an array, so you could debug $AVal being an object but an array. I guess that there could be an stdObject from any conversion you made before. Debugging will help you.

    Second, what is the reporting you set in the install tool. Set it to production, will ist work then?