testing for issues that will occur and will make a patch.

Comments

keichee’s picture

StatusFileSize
new43.83 KB

first patch..

no issues after installation and further testing..

marcingy’s picture

Status: Active » Postponed (maintainer needs more info)

Em why?

keichee’s picture

because json is much better* than serialize

*better means:
no more conversion when transferring data from php to javascript and vice versa
much more cleaner looks
objects are easier, faster to code rather than array.
minimal coding is required comparing arrays vs json in php and javascript.

even this wont be approved to core instantly, can someone please initiate the simple test if it fails or succeed?

marcingy’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

Serialised is straight forward and simple there is no rational reason to do this.

marcingy’s picture

Category: bug » feature
Priority: Critical » Normal
Status: Closed (won't fix) » Needs review

Actually...

Status: Needs review » Needs work

The last submitted patch, json_encode_decode.patch, failed testing.

keichee’s picture

wow.. thanks..

keichee’s picture

Title: Need to update serialize and unserialize to json_encode and json_decode functions » use objects instead of arrays
marcingy’s picture

Status: Needs work » Closed (won't fix)

Marking as won't fix because this is sounding like changes for changes sake.

keichee’s picture

im still trying to make a patch, seems like drupal_json_encode and decode looks like changing arrays to objects that's why i changed the subject.

marcingy’s picture

No json handles both arrays and objects. The issue is that it can't handle mixed cases so an object that contains array will not work - serialise can handle this case hence the won't fix. Plus this change negates your argument about array compares.....

Serializing data is much simpler in php as it is native representations of php data, there is really no benefit of converting json functions.

keichee’s picture

Title: use objects instead of arrays » change serialize deserialize to drupal_json_encode drupal_json_decode
Status: Closed (won't fix) » Patch (to be ported)
StatusFileSize
new48.72 KB

this patch is really _worth_ it.. at last no more serialize, deserialize
database saves blobs as json strings
and fixed array_map syntax error bugs
deleted unnecessary replace functions in drupal_json_encode

checked in mysql and sqlite installations = working flawless

hope this patch will be applicable too to D7 and D6

please check and hope to implement after majority agrees ^_^

damien tournoud’s picture

Status: Patch (to be ported) » Closed (duplicate)

json_encode() / json_decode() is *not* equivalent with serialize() / unserialize():

  • The latter handles most of the PHP data structures, while the former only handles Javascript arrays (a type of data that doesn't exist in PHP) and Javascript plain objects (that are relatively similar to PHP arrays).
  • The latter is binary safe, while the former only handles valid Unicode strings (try json_encode(chr(255)), for example

This is definitely not something that can be backported to neither Drupal 7 nor Drupal 6 (because *all* the objects currently stored in the database will have to be changed). For Drupal 8, this is a duplicate of #839444: Make serializer customizable for Cache\DatabaseBackend, if you want to make a case for json_encode() vs. serialize() you will have to prove (by benchmark of otherwise) that even with its limitations json_encode() is better.

keichee’s picture

can someone please initiate testing to my patch?

keichee’s picture

Status: Closed (duplicate) » Needs review
StatusFileSize
new48.72 KB

please download the benchmark at
https://github.com/jbergstroem/instabench

please download the php version PHP 5.4.0alpha1 (latest version) in PHP

The latter handles most of the PHP data structures, while the former only handles Javascript arrays (a type of data that doesn't exist in PHP) and Javascript plain objects (that are relatively similar to PHP arrays).
> i think there are two PHP data structures, arrays and objects which json handles better

The latter is binary safe, while the former only handles valid Unicode strings (try json_encode(chr(255)), for example
> if there will be error in the code, i will later all invalid unicode strings to json friendly version

please do see the benchmark as serialize are intensively used by drupal, if this benchmark is correct, drupal will be 2.7x faster

D:\php-5.4.0alpha1-Win32-VC9-x86>php.exe ..\nginx-1.0.4\html\jbergstroem-instabe
nch-5f828f9\test.php
InstaBench 0.1 (PHP 5.4.0alpha1)

Benchmarking results (10000 iterations)
=======================================
   serialize: 7507ms (baseline)
  var_export: 19096ms (0.4x slower)
 json_encode: 2794ms (2.7x faster)

i definitely want to choose 2.7x faster drupal and later problem unicode strings like chr(255)
how about others?

please check attached patch if will succeed, many thanks

Status: Needs review » Needs work

The last submitted patch, drupal_json_encode_decode.patch, failed testing.

damien tournoud’s picture

Status: Needs work » Closed (duplicate)

This is still a duplicate of #839444: Make serializer customizable for Cache\DatabaseBackend. Please don't open that issue again.

keichee’s picture

posted on the duplicate issue, hopefully patch will succeed to core