Permalink
Commits on Jan 19, 2018
  1. feature #25493 [Serializer] `default_constructor_arguments` context o…

    fabpot committed Jan 19, 2018
    …ption for denormalization (Nek-)
    
    This PR was squashed before being merged into the 4.1-dev branch (closes #25493).
    
    Discussion
    ----------
    
    [Serializer] `default_constructor_arguments` context option for denormalization
    
    | Q             | A
    | ------------- | ---
    | Branch?       | master
    | Bug fix?      | no
    | New feature?  | yes
    | BC breaks?    | no
    | Deprecations? | no
    | Tests pass?   | yes
    | Fixed tickets | (there is no RFC for this)
    | License       | MIT
    | Doc PR        | symfony/symfony-docs#8914
    
    ## Problems
    
    In the case you want to deserialize value-objects, if all the data required by its constructor are **not** given as input, the serializer will throw a simple `RuntimeException` exception. This makes impossible to catch it. (as current fix on my projects I use exception message to be sure to catch the good one X.x")
    
    The second problem is a missing feature to fill the required object with an empty one. This needs to be defined by the user because the serializer can't guess how to build it.
    
    Here is a project that exposes the problem of the current behavior. https://github.com/Nek-/api-platform-value-object
    
    ## Solutions suggested
    
    I suggest a solution in 2 parts because the second part is more touchy.
    
    1. Replace the current exception by a new specific one
    2. Add a new `empty_data` option to the context of deserialization so you can specify data for objects impossible to instantiate, this is great because the serializer no more throw exception and the validator can then work as expected and send violations to the user. This solution is inspired by forms solutions to fix the issue with value objects
    
    Here is what you can do with this feature:
    ```php
    class DummyValueObject
    {
        public function __construct($foo, $bar) { $this->foo = $foo; $this->bar = $bar; }
    }
    
    $empty = new DummyValueObject('', '');
    $result = $normalizer->denormalize(['foo' => 'Hello'], DummyValueObject::class, 'json', [
        'empty_data' => [
            DummyValueObject::class => $empty,
        ],
    ]);
    
    // It's impossible to construct a DummyValueObject with only "foo" value. So the serializer
    // will replace it with the given empty data
    ```
    
    There are 2 commits so I can quickly provide you only the first point if you want. Hope you'll like this.
    
    ## Solution after discussion
    
    1. New exception `MissingConstructorArgumentsException`
    2. New context option `default_constructor_arguments`
    
    ```php
    class DummyValueObject
    {
        public function __construct($foo, $bar) { $this->foo = $foo; $this->bar = $bar; }
    }
    
    $result = $normalizer->denormalize(['foo' => 'Hello'], DummyValueObject::class, 'json', [
        'default_constructor_arguments' => [
            DummyValueObject::class => ['foo' => '', 'bar' => ''],
        ],
    ]);
    
    // DummyValueObject is contructed with the given `foo` and empty `bar`
    ```
    
    Commits
    -------
    
    1523a85542 [Serializer]  context option for denormalization
  2. Merge branch '4.0'

    chalasr committed Jan 19, 2018
    * 4.0:
      [Serializer] fix undefined class
      [FrameworkBundle] fix DI extension tests
  3. Merge branch '3.4' into 4.0

    chalasr committed Jan 19, 2018
    * 3.4:
      [Serializer] fix undefined class
      [FrameworkBundle] fix DI extension tests
  4. [Serializer] fix undefined class

    chalasr committed Jan 19, 2018
Commits on Jan 18, 2018
  1. Merge branch '4.0'

    nicolas-grekas committed Jan 18, 2018
    * 4.0:
      [HttpKernel] DebugHandlersListener should always replace the existing exception handler
      fix the Composer API being used
      [Security] Notify that symfony/expression-language is not installed if ExpressionLanguage and ExpressionLanguagePrivider are used
      [Debug] Always decorate existing exception handlers to deal with fatal errors
      Enableable ArrayNodeDefinition is disabled for empty configuration
      Fixing a bug where the dump() function depended on bundle ordering
      [Cache] Fix handling of apcu_fetch() edgy behavior
      Add nn (Norwegian Nynorsk) translation files, and improve existing file
      Problem in phar see mergerequest #25579
      [Form] Disallow transform dates beyond the year 9999
      Avoid button label translation when it's set to false
      Copied NO language files to the new NB locale.
      [Serializer] DateTimeNormalizer handling of null and empty values (returning null or empty instead of new object)
      Fix options resolver with array allowed types
      [Console] Improve phpdoc on StyleInterface::ask()
      [TwigBridge][WIP] Pass the form-check-inline in parent
  2. Merge branch '3.4' into 4.0

    nicolas-grekas committed Jan 18, 2018
    * 3.4:
      [HttpKernel] DebugHandlersListener should always replace the existing exception handler
      fix the Composer API being used
      [Security] Notify that symfony/expression-language is not installed if ExpressionLanguage and ExpressionLanguagePrivider are used
      [Debug] Always decorate existing exception handlers to deal with fatal errors
      Enableable ArrayNodeDefinition is disabled for empty configuration
      Fixing a bug where the dump() function depended on bundle ordering
      [Cache] Fix handling of apcu_fetch() edgy behavior
      Add nn (Norwegian Nynorsk) translation files, and improve existing file
      Problem in phar see mergerequest #25579
      [Form] Disallow transform dates beyond the year 9999
      Avoid button label translation when it's set to false
      Copied NO language files to the new NB locale.
      [Serializer] DateTimeNormalizer handling of null and empty values (returning null or empty instead of new object)
      Fix options resolver with array allowed types
      [Console] Improve phpdoc on StyleInterface::ask()
      [TwigBridge][WIP] Pass the form-check-inline in parent
  3. Merge branch '3.3' into 3.4

    nicolas-grekas committed Jan 18, 2018
    * 3.3:
      [HttpKernel] DebugHandlersListener should always replace the existing exception handler
      fix the Composer API being used
      [Debug] Always decorate existing exception handlers to deal with fatal errors
      Enableable ArrayNodeDefinition is disabled for empty configuration
      Fixing a bug where the dump() function depended on bundle ordering
      [Cache] Fix handling of apcu_fetch() edgy behavior
      Add nn (Norwegian Nynorsk) translation files, and improve existing file
      Problem in phar see mergerequest #25579
      [Form] Disallow transform dates beyond the year 9999
      Copied NO language files to the new NB locale.
      [Serializer] DateTimeNormalizer handling of null and empty values (returning null or empty instead of new object)
      [Console] Improve phpdoc on StyleInterface::ask()
Commits on Jan 17, 2018
  1. bug #25287 [Serializer] DateTimeNormalizer handling of null and empty…

    fabpot committed Jan 17, 2018
    … values (returning it instead of new object) (Simperfit)
    
    This PR was merged into the 3.3 branch.
    
    Discussion
    ----------
    
    [Serializer] DateTimeNormalizer handling of null and empty values (returning it instead of new object)
    
    | Q             | A
    | ------------- | ---
    | Branch?       | 3.3
    | Bug fix?      | yes
    | New feature?  | no <!-- don't forget to update src/**/CHANGELOG.md files -->
    | BC breaks?    | no
    | Deprecations? | no <!-- don't forget to update UPGRADE-*.md files -->
    | Tests pass?   | no
    | Fixed tickets | #23964
    | License       | MIT
    | Doc PR        |
    
    I'm openning the disucussion on this as I think that should be returning null and not a new object.
    
    WDYT ?
    
    Working at home ;)
    ![img_2914](https://user-images.githubusercontent.com/3451634/33526107-ec2a6ce8-d83b-11e7-8949-f8d360ebb4b9.JPG)
    
    Commits
    -------
    
    74726f3896 [Serializer] DateTimeNormalizer handling of null and empty values (returning null or empty instead of new object)
Commits on Jan 12, 2018
  1. [Serializer] DateTimeNormalizer handling of null and empty values (re…

    Simperfit committed Dec 3, 2017
    …turning null or empty instead of new object)
Commits on Jan 10, 2018
  1. Merge branch '4.0'

    xabbuh committed Jan 10, 2018
    * 4.0: (30 commits)
      [FrameworkBundle] fix tests
      [Serializer] Fixed throwing exception with option JSON_PARTIAL_OUTPUT_ON_ERROR
      [HttpKernel] Fix session handling: decouple "save" from setting response "private"
      swap filter/function and package names
      [HttpFoundation] Always call proxied handler::destroy() in StrictSessionHandler
      [HttpKernel] Fix compile error when a legacy container is fresh again
      Add tests for the HttpKernel request collector and redirection via cookies
      Uses cookies to track the requests redirection
      Tweaked some styles in the profiler tables
      Add type string to docblock for Process::setInput()
      [Security] Fail gracefully if the security token cannot be unserialized from the session
      [Form] AbstractLayoutTest - fix DOMDocument casing
      Run simple-phpunit with --no-suggest option
      [FrameworkBundle] Fix using "annotations.cached_reader" in after-removing passes
      bumped Symfony version to 4.0.4
      updated VERSION for 4.0.3
      updated CHANGELOG for 4.0.3
      bumped Symfony version to 3.4.4
      updated VERSION for 3.4.3
      updated CHANGELOG for 3.4.3
      ...
  2. Merge branch '3.4' into 4.0

    xabbuh committed Jan 10, 2018
    * 3.4: (26 commits)
      [Serializer] Fixed throwing exception with option JSON_PARTIAL_OUTPUT_ON_ERROR
      [HttpKernel] Fix session handling: decouple "save" from setting response "private"
      swap filter/function and package names
      [HttpFoundation] Always call proxied handler::destroy() in StrictSessionHandler
      [HttpKernel] Fix compile error when a legacy container is fresh again
      Add tests for the HttpKernel request collector and redirection via cookies
      Uses cookies to track the requests redirection
      Tweaked some styles in the profiler tables
      Add type string to docblock for Process::setInput()
      [Security] Fail gracefully if the security token cannot be unserialized from the session
      [Form] AbstractLayoutTest - fix DOMDocument casing
      Run simple-phpunit with --no-suggest option
      [FrameworkBundle] Fix using "annotations.cached_reader" in after-removing passes
      bumped Symfony version to 3.4.4
      updated VERSION for 3.4.3
      updated CHANGELOG for 3.4.3
      bumped Symfony version to 3.3.16
      updated VERSION for 3.3.15
      updated CHANGELOG for 3.3.15
      bumped Symfony version to 2.8.34
      ...
  3. Merge branch '3.3' into 3.4

    xabbuh committed Jan 10, 2018
    * 3.3:
      [Serializer] Fixed throwing exception with option JSON_PARTIAL_OUTPUT_ON_ERROR
      Tweaked some styles in the profiler tables
      Add type string to docblock for Process::setInput()
      [Security] Fail gracefully if the security token cannot be unserialized from the session
      [Form] AbstractLayoutTest - fix DOMDocument casing
      Run simple-phpunit with --no-suggest option
      [FrameworkBundle] Fix using "annotations.cached_reader" in after-removing passes
      bumped Symfony version to 3.3.16
      updated VERSION for 3.3.15
      updated CHANGELOG for 3.3.15
      bumped Symfony version to 2.8.34
      updated VERSION for 2.8.33
      updated CHANGELOG for 2.8.33
      bumped Symfony version to 2.7.41
      updated VERSION for 2.7.40
      update CONTRIBUTORS for 2.7.40
      updated CHANGELOG for 2.7.40
  4. Merge branch '2.8' into 3.3

    xabbuh committed Jan 10, 2018
    * 2.8:
      [Serializer] Fixed throwing exception with option JSON_PARTIAL_OUTPUT_ON_ERROR
      Tweaked some styles in the profiler tables
      [Security] Fail gracefully if the security token cannot be unserialized from the session
      [Form] AbstractLayoutTest - fix DOMDocument casing
      bumped Symfony version to 2.8.34
      updated VERSION for 2.8.33
      updated CHANGELOG for 2.8.33
      bumped Symfony version to 2.7.41
      updated VERSION for 2.7.40
      update CONTRIBUTORS for 2.7.40
      updated CHANGELOG for 2.7.40
  5. Merge branch '2.7' into 2.8

    xabbuh committed Jan 10, 2018
    * 2.7:
      [Serializer] Fixed throwing exception with option JSON_PARTIAL_OUTPUT_ON_ERROR
      [Security] Fail gracefully if the security token cannot be unserialized from the session
      [Form] AbstractLayoutTest - fix DOMDocument casing
      bumped Symfony version to 2.7.41
      updated VERSION for 2.7.40
      update CONTRIBUTORS for 2.7.40
      updated CHANGELOG for 2.7.40
Commits on Jan 7, 2018
  1. minor #25585 Add type string to docblock for Process::setInput() (ica…

    nicolas-grekas committed Jan 7, 2018
    …nhazstring)
    
    This PR was submitted for the 3.4 branch but it was squashed and merged into the 3.3 branch instead (closes #25585).
    
    Discussion
    ----------
    
    Add type string to docblock for Process::setInput()
    
    | Q             | A
    | ------------- | ---
    | Branch?       | 3.4
    | Bug fix?      | no
    | New feature?  | no
    | BC breaks?    | no
    | Deprecations? | no
    | Tests pass?   | yes
    | Fixed tickets | none
    | License       | MIT
    | Doc PR        | none
    
    Add `string` as valid `$input` for `Process::setInput()`. Since `getInput()` will also return as string and the internal method `ProcessUtils::validateInput()` will accept a string, this should be a viable input type.
    
    Commits
    -------
    
    e3de68f2 Add type string to docblock for Process::setInput()
Commits on Jan 3, 2018
  1. Merge branch '4.0'

    fabpot committed Jan 3, 2018
    * 4.0:
      fixed years in copyright
      fix typo
  2. Merge branch '3.4' into 4.0

    fabpot committed Jan 3, 2018
    * 3.4:
      fixed years in copyright
      fix typo
  3. Merge branch '3.3' into 3.4

    fabpot committed Jan 3, 2018
    * 3.3:
      fixed years in copyright
  4. Merge branch '2.8' into 3.3

    fabpot committed Jan 3, 2018
    * 2.8:
      fixed years in copyright
  5. Merge branch '2.7' into 2.8

    fabpot committed Jan 3, 2018
    * 2.7:
      fixed years in copyright
  6. fixed years in copyright

    fabpot committed Jan 3, 2018
Commits on Jan 2, 2018
  1. Merge branch '4.0'

    nicolas-grekas committed Jan 2, 2018
    * 4.0: (23 commits)
      Clean up
      Update return type in docblock.
      PHP CS Fixer: no need to exclude xml and yml files
      PHP CS Fixer: no need to exclude json file
      [#22749] fix version in changelog
      Update LICENSE year... forever
      fixed some deprecation messages
      fixed CS
      Fixes for Oracle in PdoSessionHandler
      fixed some deprecation messages
      fixed some deprecation messages
      fixed some deprecation messages
      fixed some deprecation messages
      Remove dead code
      [TwigBundle/Brige] catch missing requirements to throw meaningful exceptions
      [DI] fix CS
      [HttpKernel] Call Response->setPrivate() instead of sending raw header() when session is started
      [FrameworkBundle] Make cache:clear "atomic" and consistent with cache:warmup
      Suggest to write an implementation if the interface cannot be autowired
      [Debug] Skip DebugClassLoader checks for already parsed files
      ...
  2. Merge branch '3.4' into 4.0

    nicolas-grekas committed Jan 2, 2018
    * 3.4:
      Clean up
      Update return type in docblock.
      PHP CS Fixer: no need to exclude xml and yml files
      PHP CS Fixer: no need to exclude json file
      Update LICENSE year... forever
      fixed some deprecation messages
      fixed CS
      Fixes for Oracle in PdoSessionHandler
      fixed some deprecation messages
      fixed some deprecation messages
      fixed some deprecation messages
      fixed some deprecation messages
      [TwigBundle/Brige] catch missing requirements to throw meaningful exceptions
      [HttpKernel] Call Response->setPrivate() instead of sending raw header() when session is started
      [FrameworkBundle] Make cache:clear "atomic" and consistent with cache:warmup
      Suggest to write an implementation if the interface cannot be autowired
      [Debug] Skip DebugClassLoader checks for already parsed files
      [2.7][DX] Use constant message contextualisation for deprecations
      Remove group options without data and fix normalization
      Remove redundant translation path
  3. Merge branch '3.3' into 3.4

    nicolas-grekas committed Jan 2, 2018
    * 3.3:
      Clean up
      Update return type in docblock.
      PHP CS Fixer: no need to exclude xml and yml files
      PHP CS Fixer: no need to exclude json file
      Update LICENSE year... forever
  4. Merge branch '2.8' into 3.3

    nicolas-grekas committed Jan 2, 2018
    * 2.8:
      Clean up
      Update return type in docblock.
      PHP CS Fixer: no need to exclude xml and yml files
      Update LICENSE year... forever
  5. Merge branch '2.7' into 2.8

    nicolas-grekas committed Jan 2, 2018
    * 2.7:
      Clean up
      Update return type in docblock.
      PHP CS Fixer: no need to exclude xml and yml files
      Update LICENSE year... forever
Commits on Dec 31, 2017
  1. Update LICENSE year... forever

    dunglas committed Dec 31, 2017
  2. Merge branch '3.3' into 3.4

    fabpot committed Dec 31, 2017
    * 3.3:
      fixed some deprecation messages
      fixed some deprecation messages
      fixed some deprecation messages
      fixed some deprecation messages
      [2.7][DX] Use constant message contextualisation for deprecations
  3. fixed some deprecation messages

    fabpot committed Dec 31, 2017
  4. fixed some deprecation messages

    fabpot committed Dec 31, 2017
  5. Merge branch '2.7' into 2.8

    fabpot committed Dec 31, 2017
    * 2.7:
      fixed some deprecation messages
  6. fixed some deprecation messages

    fabpot committed Dec 31, 2017