1
kerkyra
json_encode and Xoops problem
  • 2010/11/8 20:18

  • kerkyra

  • Just can't stay away

  • Posts: 553

  • Since: 2005/2/14


hallo there,

i'm trying to pass an array to js and i have come to the following problem.

if i create a function as the following

Quote:

function test()
{
$test_arr = array();

for($i=0;$i<1000;$i++)
{

$test_arr[$i]['id'] = $i;
$test_arr[$i]['name'] = "name".$i;
$test_arr[$i]['desc'] = "desc".$i;

$test_arr[$i]['img'] = "img".$i;
}

echo json_encode($test_arr);
}


in a plain php file it works like a charm.
if i include the mainfile.php of xoops on top of this function, i come up with a blank page. It only works for i<100.

If i just echo the array it works no matter what $i is.

It only fails on json_encode and for $i >100 WITH the mainfile.php included...

I tried with and without protector and it still doesn work.

Any ideas on what could cause such a weird behaviour?

Thanks

2
kerkyra
Re: json_encode and Xoops problem...solved???
  • 2010/11/8 22:52

  • kerkyra

  • Just can't stay away

  • Posts: 553

  • Since: 2005/2/14


hallo again, after digging out a lil bit i came across an include in common.php.
In common.php there is an inclusion of xlanguage/api.php which turns out to be the cause of the problem.

in api.php lines 95 and 97 is the following code

Quote:

ob_start("xlanguage_encoding");
}else{
ob_start("xlanguage_ml");
}

and thats where the whole thing was messing up.

What i did to fix this is...

on the begining of my function to show the data test() i added the following line
Quote:

ob_end_flush();


now the data is showing as expected.

My question to this is: Is this the correct way of treating this error/bug??

Should this be happening? Is there another way, perhaps more optimized/correct to fix this?

Thanks

3
ghia
Re: json_encode and Xoops problem
  • 2010/11/9 0:02

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


If you have XOOPS 2.4.x, the include in common.php is no longer needed because this is done automatically by /modules/xlanguage/preloads/core.php

4
kerkyra
Re: json_encode and Xoops problem
  • 2010/11/9 11:12

  • kerkyra

  • Just can't stay away

  • Posts: 553

  • Since: 2005/2/14


Still, the problem exists. It's not the common.php, its the api.php of xlanguage that does this...

Login

Who's Online

433 user(s) are online (318 user(s) are browsing Support Forums)


Members: 0


Guests: 433


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits