1

Background

Recently I upgraded php to version 5.5. Within this upgrade module for json was moved out from php5 package into a new package php5-json. So I installed it.

Now the connection with firephp (and firebug).
Before sending, firephp::log encodes the variable with json_encode.
There might occur an issue with json_encode. The json_encode may fail to encode the input variable. This might happen in a string with unencoded unicode or a string with some ill encoded characters.

Behaviour in previous version of php

  • In firebug instead of the value with the wrong coding white space appears.
  • After the wrong value firebug continues to display next values which arrived from firephp.

Behaviour with separate php5-json

  • When the ill encoded value arrives to firebug, following error message appears:

    SyntaxError: JSON.parse: unexpected character
    chrome://firephp/content/lib/renderer.js
    Line 159

  • After this listing logs from firephp stops.

Question

I understand that there was an 'unexpected character'. But I'd just like to move on and see the following messages. Not stop on the first unexpected character.
What shall I do to solve the issue? Or at least get back to the previous bevior?

Software versions:

  • Debian testing jessie
  • Linux host 3.10-2-amd64 #1 SMP Debian 3.10.5-1 (2013-08-07) x86_64 GNU/Linux
  • php5 5.5.1+dfsg-2
  • php5-json 1.3.1+dfsg-1
  • iceweasel 22.0
  • FirePHPCore-0.3.2
  • Firebug 1.11.4
  • Firephp 0.7.2

Edit:

I also can see in Firebug header X-Wf-1-1-1-2:

[{"Type":"LOG","Label":"$someVar","File":"/home/GIT/www/some/path/someFile.php","Line":"156"},]

Which does miss the value part and thus is not valid JSON, which is why the rendering fails.

The header with the correct message, which gets printed:

[{"Type":"LOG","Label":"POST data","File":"/home/GIT/www/some/path/someFile.php","Line":"22"},{"data":{"myarray":["117"]},"getA":"true","getB":"true"}]

Edit2:

I submitted this as a bug in Debian 719942. But it doesn't seem that someone is willing to have a look at it :-(

1 Answer 1

0

Background:

There is a licensing conflict with Linux distributions over a clause in Crockford's license which states:
The Software shall be used for Good, not Evil.
This does not agree with the Free Software Foundation’s (FSF) freedom 0:
The freedom to run the program for any purpose. (source)

The solution to it shall be a newly written library pecl-json-c packaged as php5-json. The newly used json library doesn't seem to be compatible with firephp. But if you will use software for Good, not Evil, you might want to restore the original Crockford's library.

Steps to restore the Crockford's library

1) Get the original json 1.2.1 library and unzip it.
2) Install php5-dev (in Debian sudo apt-get install php5-dev) which comes with phpize tool. (source: How to create PHP extensions).
3) As jacekk suggests you need to replace one occurrence of function_entry in json.c with zend_function_entry.
4) As Star suggests you need to replace ZVAL_DELREF with Z_DELREF_P in three places in file JSON_parser.c.
5) Then you change directory to the json-1.2.1 and run

phpize
./configure
make

6) Unfortunatelly you can't remove the package php5-json, because it will take with it the whole php. Instead you need to locate the library json.so (dpkg -L php5-json | grep json.so will do).
7) As the root replace the Remi's json.so with Crockford's json.so you just compiled.

Drawbacks

With the next upgrade of php5-json you'll get back Remi's library.
You are now using non-free software.
You are messing-up with your system.
Some people claim that the Remi's library has more features, which is probably true, because the Crockford's library is from 2005.

1
  • This bugreport links to firephp 0.3.3 which solves the firephp issue.
    – sumid
    Apr 27, 2014 at 16:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .