Issue Bug Closed

#16036addQueryString does NOT work properly

Dmitry Pikhno 04/12/06, 10:26 updated 05/03/06, 12:14

Description

1) it is again does not work with realurl due to the problem that was already fixed BEFORE. (#15286)
shortly speaking: reaurl transforms _GET but does not transform QUERY_STRING
2)problems even without realurl -
“Warning: rawurlencode() expects parameter 1 to be string, array given in /typo3_src/typo3/sysext/cms/tslib/class.tslib_content.php on line 5552”

marks.PRINTLINK {
    file=fileadmin/images/icon_print.gif
    stdWrap.typolink.parameter.data = page:uid
    stdWrap.typolink.additionalParams = &type=98
    stdWrap.typolink.addQueryString = 1
    stdWrap.typolink.addQueryString.method = GET
    #stdWrap.typolink.addQueryString.exclude = cHash
    altText = print version
}

3)and bonus – double “id” in result url (with enabled “.exclude = ..” – it is ok)

bugs are in function getQueryArguments in tslib/class.tslib_content.php

this is code of updated function and it works properly(seems works good):

function getQueryArguments($conf,$overruleQueryArgs=array(),$forceArgs=FALSE) {
        $rawValues = FALSE;

        $q_in = array();
        switch((string)$conf['method'])    {
            case 'POST':
                $q_in = t3lib_div::_POST();
            break;
            case 'GET':
            default:
                foreach (explode('&',t3lib_div::implodeArrayForUrl('', t3lib_div::_GET())) as $arg)    {
                    list($k,$v) = explode('=',$arg);
                    if($v)    $q_in[$k] = $v;
                }
            break;
        }

        $q_out = array();
        $exclude = t3lib_div::trimExplode(',', $conf['exclude']);
        $exclude[] = 'id';    // never repeat id
        foreach ($q_in as $k => $v)   {
            if (!in_array($k, $exclude)) {
                if (isset($overruleQueryArgs[$k]))    {
                    $v = $overruleQueryArgs[$k];
                    unset($overruleQueryArgs[$k]);
                }
                $q_out[$k] = $v;
            }
        }
        // any remaining overrule arguments?
        if ($forceArgs)    {
            foreach ($overruleQueryArgs as $k => $v)    {
                $q_out[$k] = $v;
            }
        }
        $content = '';
        foreach ($q_out as $k => $v)    {
            $content .= '&'.$k.'='.($rawValues ? $v : rawurlencode($v));
        }
        return $content;
    }

(issue imported from #M3241)

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.