Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
base system
Priority:
Normal
Category:
Task
Assigned:
Issue tags:
Reporter:
Created:
2 Mar 2014 at 08:23 UTC
Updated:
29 Jul 2014 at 23:25 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
sunComment #3
sun1: json.1.patch queued for re-testing.
Comment #4
sunComment #5
sun1: json.1.patch queued for re-testing.
Comment #7
sun1: json.1.patch queued for re-testing.
Comment #9
sun1: json.1.patch queued for re-testing.
Comment #11
sun1: json.1.patch queued for re-testing.
Comment #12
dawehnerI just don't see why this particular code is specific to drupal. Other projects (like drupal people writing php only projects)
could profit. Drupal\Component\Serialization could also work here.
Comment #14
sunThe only code that exists in this class is this:
All of these flags are native PHP constants:
http://www.php.net/manual/en/function.json-encode.php
http://www.php.net/manual/en/json.constants.php
This code is specific to Drupal, because the one and only purpose is to harmonize and standardize JSON-encoded strings throughout Drupal modules.
If I'd need to encode variables into JSON in my own non-Drupal component/project/code, then I assure you that I won't use a utility helper class from Drupal to do that, because that would be a totally senseless dependency —
json_encode()is readily available.Profit from what?
Comment #15
sun1: json.1.patch queued for re-testing.
Comment #16
sunHm. Perhaps we're talking past each other?
Are you saying that you'd be fine if the class was moved into
Drupal\Component\Serializationinstead ofDrupal\Core?The reason for why I'm suggesting
Drupal\Core\Serializationis that all of the serialization classes are hard-coding various flags that are, in essence, just simply no more and no less than Drupal's preferences; i.e.,json_encode()flags, because we expect most JSON to get rendered on an HTML page.Yaml\Dumperto comply with Drupal coding standards; i.e., indent 2 spaces instead of 4, and don't switch to inline YAML after a certain nesting level.serialize()does not support any flags.I assume the point where we digress is that
In order to make the concept a truly useful standalone component, we'd have to abstract the hard-coded assumptions, bloat the whole shebang with a serialization manager/configurator service and/or other ways to e.g. pass or statically set the configuration... The end result of such an effort would be something along the lines of Symfony's Serialization component, which is a super-complex beast of code.
However, if it's really just the
Componentvs.Coreaspect, and if my arguments are not able to convince you, then I'm happy to concede and simply move the serialization classes intoDrupal\Component\Serialization— I personally think that it does not make sense, but I really want/need to move forward on this.Comment #17
dawehnerThank you for your long answer and patience. It is convincing that the actual implementation is tight to the requirements of drupal, so if other projects
would like something similar they should set their own rules. We should be pragmatic here.
My point was more on an abstract level. We should try to allow other people to reuse our code and not remove that possiblity again.
Ensure to move the tests out of the component directory
Comment #18
sunMoved PHPUnit test accordingly.
Comment #19
dawehnerThank you
Comment #21
damiankloip commentedPure git reroll.
Comment #22
sunComment #24
tim.plunkett21: 2208609-21.patch queued for re-testing.
Comment #26
sunUpdated all new instances after #2093173: Remove all calls to drupal_json_decode(), use \Drupal\Component\Utility\Json::decode()
Comment #28
sunHah. HEAD is moving fast today. ;)
Comment #29
alexpottjson.28.patch no longer applies.
Comment #30
sunComment #33
sun30: json.30.patch queued for re-testing.
Comment #34
sunComment #35
alexpottjson.30.patch no longer applies.
Comment #36
sunComment #38
sun36: json.36.patch queued for re-testing.
Comment #39
sunComment #40
damiankloip commented+1, still looks good.
Comment #41
sunPatch still applies cleanly (despite the high core commit volume these days).
Comment #43
sunMerged 8.x.
Comment #44
damiankloip commentedLooks good.
Comment #45
sunAfter further discussion on #2208633: Add a Yaml class to Drupal\Component\Serialization + IRC...:
Moved
Drupal\Core\SerializationintoDrupal\Component\Serialization.Comment #46
sunUpdating issue summary accordingly.
Comment #47
sunHaha + issue title :)
Comment #49
sundiff context conflict
Comment #51
sundiff context conflict
Comment #53
sunMerged 8.x
Comment #55
sunComment #56
alexpottjson.55.patch no longer applies.
Comment #57
Jalandhar commentedRerolled patch.
Comment #58
sunManually merged, verified, and confirmed the re-roll.
Comment #59
webchickCommitted and pushed to 8.x. Thanks!
Comment #61
hass commentedhttps://drupal.org/node/2219113 is very confusing now and only ~3 weeks old.