php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65955 Invalid Json response
Submitted: 2013-10-24 07:31 UTC Modified: 2013-10-26 05:40 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: aaatoja at o2 dot pl Assigned: yohgaki (profile)
Status: Closed Package: PDO related
PHP Version: 5.4.21 OS: Linux Ubuntu
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: aaatoja at o2 dot pl
New email:
PHP Version: OS:

 

 [2013-10-24 07:31 UTC] aaatoja at o2 dot pl
Description:
------------
I have a Postgresql (v9.3) view which contains column made from json_agg() function (array_agg works fine).
My response looks like:
array(5) {
  [0] => array(2) {
    ["aggcolumn"] => NULL
    [0] => NULL
  }
  [1] => array(2) {
    ["aggcolumn"] => string(14) "["test"]]"
    [0] => string(14) "["test"]]"
  }
  [2] => array(2) {
    ["aggcolumn"] => string(34) "["test", "test2"]]]"
    [0] => string(34) "["test", "test2"]]]"
  }
  [3] => array(2) {
    ["aggcolumn"] => string(26) "["test3"]]]]"
    [0] => string(26) "["test3"]]]]"
  }
  [4] => array(2) {
    ["aggcolumn"] => string(46) "["test2", "test3"]]]]]"
    [0] => string(46) "["test2", "test3"]]]]]"
  }
}

Test script:
---------------
try {
            $dbh = new PDO($dsn, $user, $password);
            $sth = $dbh->prepare('SELECT aggcolumn FROM view_test WHERE company_id = ? AND active_flag IS TRUE');
            $sth->execute(array(10));
            $res = $sth->fetchAll();
            var_dump($res);
        } catch (PDOException $e) {
            echo 'Connection failed: ' . $e->getMessage();
        }

Expected result:
----------------
Response should be valid JSON string.

Actual result:
--------------
As You may notice every row has a value with an extra ']' at the end, based on current iteration count. That makes string invalid JSON response

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-10-24 08:27 UTC] yohgaki@php.net
-Package: PostgreSQL related +Package: PDO related
 [2013-10-24 10:26 UTC] aaatoja at o2 dot pl
-Status: Open +Status: Closed
 [2013-10-24 10:26 UTC] aaatoja at o2 dot pl
I see bug is fixed in v5.5.
 [2013-10-24 10:39 UTC] yohgaki@php.net
-Assigned To: +Assigned To: yohgaki
 [2013-10-24 10:39 UTC] yohgaki@php.net
Do you mean fixed in 5.5, but not 5.4? Then this should be re-opened.
 [2013-10-26 05:40 UTC] aaatoja at o2 dot pl
I've rechecked on OpenSuse with PHP v.5.4.20 and this problem does not exists. Maybe it was some Ubuntu specific bug.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 22:01:29 2024 UTC