Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[ErrorHandler] Serialize FlattenException#38800

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
Nyholm wants to merge2 commits intosymfony:5.xfromNyholm:errorhandler-serialize

Conversation

@Nyholm
Copy link
Member

QA
Branch?5.x
Bug fix?yes
New feature?no
Deprecations?no
TicketsRelated to#38792
LicenseMIT
Doc PRNot needed

TheFlatternException is used with messenger. When it is serialized with the Serializer component we fail to restore all its properties.

WhenFlatternException::$traceAsString is null and we callFlatternException::getTraceAsString() we get an exception thrown in our face. That is what#38792 is about.

This PR does two things (sorry about that).

  1. It modifiesFlatternException::setTrace() so the serializer can populate the trace property when unserializing. I also try to rebuild the traceAsString from the$trace

  2. It modifies the PropertyAccess and PropertyInfo component to be aware of nullable setters. Ie, It findsFlatternException::setPrevious(), but that function does not allow nullable parameters, but it still try to set the valuenull and we get another exception thrown in our face.

publicfunctionsetTrace($trace,$file =null,$line =null):self
{
$this->trace = [];
if ($file)
Copy link
Member

Choose a reason for hiding this comment

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

I see that this is WIP :)

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I had to leave it after 2 hours that late last night.

I would like to get some feedback from@yceruto and/or someone that knows about property access.

Also, is it a good idea to modify a class "just because" serialization?

@nicolas-grekasnicolas-grekas added this to the5.2 milestoneOct 26, 2020
* @return $this
*/
publicfunctionsetTrace($trace,$file,$line):self
publicfunctionsetTrace($trace,$file =null,$line =null):self

Choose a reason for hiding this comment

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

Isn't this a BC break for inheriting classes? Any other idea?

derrabus reacted with thumbs up emoji
/** @var \ReflectionParameter $parameter */
$parameter =$method->getParameters()[0];
if (\array_key_exists('value',$context) &&null ===$context['value'] && !$parameter->allowsNull()) {
$errors[] =sprintf('The method "%s" in class "%s" was found but does not allow null.',$methodName,$class);
Copy link
Member

Choose a reason for hiding this comment

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

This breaksPropertyAccess test suite (see Travis's failure)

Copy link
Member

@ycerutoyceruto left a comment

Choose a reason for hiding this comment

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

Hey! As far as I understand, thisFlattenException should be handled bySymfony\Component\Messenger\Transport\Serialization\Normalizer\FlattenExceptionNormalizer andSymfony\Component\Messenger\Transport\Serialization\Serializer when the Messenger component is installed.

I did some tests using this code and it works without any other change:

useSymfony\Component\Messenger\Transport\Serialization\Normalizer\FlattenExceptionNormalizer;useSymfony\Component\Messenger\Transport\Serialization\SerializerasMessengerSerializer;// ...publicfunctiontestSerialize(){$serializer =newSerializer([newFlattenExceptionNormalizer()], [newJsonEncoder()]);$context = [MessengerSerializer::MESSENGER_SERIALIZATION_CONTEXT =>true];$flattened = FlattenException::createFromThrowable(new \LogicException('Bad things happened'));$trace =$flattened->getTraceAsString();$data =$serializer->serialize($flattened,'json',$context);$restored =$serializer->deserialize($data, FlattenException::class,'json',$context);$restoredTrace =$restored->getTraceAsString();$this->assertSame(substr($trace,0,100),substr($restoredTrace,0,100));$this->assertSame(\count(explode(\PHP_EOL,$trace)),\count(explode(\PHP_EOL,$restoredTrace)));}

The matter is that thisFlattenExceptionNormalizer doesn't exist in 5.1, but since 5.2#37087, and the related issue is talking about this error on 5.1, but also it happens in 4.3#32719

By the way, I can't reproduce the issue on 5.2:

Exception:==========(no data)

Maybe I'm missing something, but it seemsAddErrorDetailsStampListener is not registered by default, hence theErrorDetailsStamp is not added.

@Nyholm
Copy link
MemberAuthor

Thank you for the explanation. So we are closing this as "wontfix" for 4.4?

Maybe I'm missing something, but it seems AddErrorDetailsStampListener is not registered by default, hence the ErrorDetailsStamp is not added.

That is true. I though that was intentional... but Im not sure.

@yceruto
Copy link
Member

So we are closing this as "wontfix" for 4.4?

Well, it's possible to fix it if we usePropertyNormalizer to serialize/deserialize theFlattenException instance or backporting theFlattenExceptionNormalizer.

That is true. I though that was intentional... but Im not sure.

Ok it's being fixed here#38941.

@Nyholm
Copy link
MemberAuthor

Im happy with closing this issue then.

@NyholmNyholm closed thisNov 1, 2020
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot left review comments

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

@jderussejderussejderusse left review comments

@ycerutoycerutoyceruto left review comments

@dunglasdunglasAwaiting requested review from dunglas

Assignees

No one assigned

Projects

None yet

Milestone

5.2

Development

Successfully merging this pull request may close these issues.

6 participants

@Nyholm@yceruto@fabpot@nicolas-grekas@jderusse@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp