Warnings on array parameter and headers already sent by

Popular automatic website translation tool

Warnings on array parameter and headers already sent by

Postby acyba » Thu May 26, 2016 5:31 pm

Hello,

I think there is an issue when you have a 2 levels array parameter in your URL.
For example an URL like [url]http://www.mydomain.com?param[lvl1][lvl2]=value[/url]

There are the following warnings when trying to translate the page:
Warning: urlencode() expects parameter 1 to be string, array given in /srv/www/vhosts/www.domain.com/www/gtranslate/gtranslate.php on line 25

Warning: Cannot modify header information - headers already sent by (output started at /srv/www/vhosts/www.domain.com/www/gtranslate/gtranslate.php:25) in /srv/www/vhosts/www.domain.com/www/gtranslate/gtranslate.php on line 141

How can we solve this?

Best regards
acyba
 
Posts: 6
Joined: Wed Apr 06, 2016 1:36 pm

Re: Warnings on array parameter and headers already sent by

Postby Edvard » Thu May 26, 2016 9:36 pm

Hi,

Can you provide a link to live example?

Thanks!
Regards,

Edvard Ananyan - GTranslate Team

Please leave your feedback on your CMS plugin directory. It is very important for us!
Google Translate Joomla
Google Translate WordPress
Google Translate Drupal
Edvard
Site Admin
 
Posts: 4403
Joined: Mon Jun 28, 2010 1:54 pm
Location: Yerevan, Armenia

Re: Warnings on array parameter and headers already sent by

Postby acyba » Fri May 27, 2016 12:46 pm

Hello,

Sure, here is a link: [url]https://www.acyba.com/fr/?param[lvl1][lvl2]=value[/url]
You will have the same issue on any page of the site if you add this kind of parameter in the URL.
Best regards
acyba
 
Posts: 6
Joined: Wed Apr 06, 2016 1:36 pm

Re: Warnings on array parameter and headers already sent by

Postby Edvard » Fri May 27, 2016 10:50 pm

Hi,

Try to replace
Code: Select all
$get_params = array();
foreach($_GET as $key => $val) {
    if($key != 'glang' and $key != 'gurl') {
        if(is_array($val))
            foreach($val as $v)
                $get_params[] = $key.'[]='.urlencode($v);
        else
            $get_params[] = $key.'='.urlencode($val);
    }
}

if(count($get_params)) {
    $page_url .= '?' . implode('&', $get_params);
}


with
Code: Select all
$get_params = $_GET;
if(isset($get_params['glang']))
   unset($get_params['glang']);
if(isset($get_params['gurl']))
    unset($get_params['gurl']);

if(count($get_params)) {
   $page_url .= '?' . http_build_query($get_params);
}


in gtranslate/gtranslate.php file.
Regards,

Edvard Ananyan - GTranslate Team

Please leave your feedback on your CMS plugin directory. It is very important for us!
Google Translate Joomla
Google Translate WordPress
Google Translate Drupal
Edvard
Site Admin
 
Posts: 4403
Joined: Mon Jun 28, 2010 1:54 pm
Location: Yerevan, Armenia

Re: Warnings on array parameter and headers already sent by

Postby acyba » Tue May 31, 2016 11:22 am

Hello,

Thanks a lot for this code. This is now working.
Best regards
acyba
 
Posts: 6
Joined: Wed Apr 06, 2016 1:36 pm

Re: Warnings on array parameter and headers already sent by

Postby Edvard » Tue May 31, 2016 9:00 pm

You are welcome. Good to hear that.
Regards,

Edvard Ananyan - GTranslate Team

Please leave your feedback on your CMS plugin directory. It is very important for us!
Google Translate Joomla
Google Translate WordPress
Google Translate Drupal
Edvard
Site Admin
 
Posts: 4403
Joined: Mon Jun 28, 2010 1:54 pm
Location: Yerevan, Armenia


  • Related Topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 0 guests

cron