Skip to content

Allows JSON unserializing to be associative or object #28192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

jajajaime
Copy link

Description (*)

Allows a developer to pass an optional boolean argument when unserializing a JSON string, so it can be returned as object or associative. Keeps associative as default for backwards compatibility.

Related Pull Requests

Fixed Issues (if relevant)

Manual testing scenarios (*)

  1. Create code that unserializes json string while passing the extra argument of false

Questions or comments

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

@m2-assistant
Copy link

m2-assistant bot commented May 11, 2020

Hi @jajajaime. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Guide documentation.

@ihor-sviziev
Copy link
Contributor

ihor-sviziev commented May 12, 2020

I remember we had some architecture discussions in magento/architecture#254, magento/magento-coding-standard#91 and previously in magento/architecture#161.

AFAIK no real decision was done yet. @lenaorobei do we have any updates on that?

@@ -32,9 +32,9 @@ public function serialize($data)
* @inheritDoc
* @since 100.2.0
*/
public function unserialize($string)
public function unserialize($string, $assoc = true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Such change is not allowed: https://devdocs.magento.com/guides/v2.3/contributor-guide/backward-compatible-development/

Let's first find out whether we need such functionality at all.

@ihor-sviziev
Copy link
Contributor

@orlangur please explain why you moved this PR to "on hold" status.

@lenaorobei
Copy link
Contributor

Unfortunately, we cannot accept this PR since it violates backward compatibility policy.

There were some discussions regarding introduction new JSON contract, but there is no resolution yet. Please see details here magento/architecture#254

@lenaorobei lenaorobei closed this May 18, 2020
@m2-assistant
Copy link

m2-assistant bot commented May 18, 2020

Hi @jajajaime, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@jajajaime
Copy link
Author

@lenaorobei is this because of "Adding parameters in public methods"? If so, I think it should be on a case by case basis, as creating a new class or interface would create more work for devs to switch to the new one in this case.

@orlangur
Copy link
Contributor

orlangur commented Jun 1, 2020

@jajajaime backward compatibility policy is mandatory, no exception.

when unserializing a JSON string, so it can be returned as object or associative

Please create a proposal in architecture repo first to describe why it needs to be returned as object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants