Skip to content
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

Fixes serialization issues in Queue Identification #202

Merged
merged 14 commits into from
Sep 30, 2020

Conversation

ArlonAntonius
Copy link
Member

No description provided.

@ArlonAntonius ArlonAntonius added the type:bug Something isn't working label Sep 28, 2020
@@ -87,9 +88,9 @@ public function __construct(JobProcessing $event)
*/
private function unserializeToJob(string $object)
{
$stdClassObj = preg_replace('/^O:\d+:"[^"]++"/', 'O:'.strlen('stdClass').':"stdClass"', $object);
$stdClassObj = preg_replace('/^O:\d+:"[^"]++"/', 'O:'.strlen(TenancyJob::class).':"'.TenancyJob::class.'"', $object);
Copy link
Member Author

Choose a reason for hiding this comment

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

Instead of replacing with an StdClass, we are replacing to a TenancyJob, where we can control some things


return unserialize($stdClassObj);
return unserialize($stdClassObj, ['allowed_classes' => [TenancyJob::class]]);
Copy link
Member Author

Choose a reason for hiding this comment

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

This causes PHP to not unserialize the ModelIdentifiers that would cause the connections

Comment on lines +51 to +53
if (!in_array($property->getName(), ['tenant', 'tenant_identifier', 'tenant_key'])) {
continue;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Make sure we don't unserialize anything except our tenant keys :)


$property->setAccessible(true);

$property->setValue($this, unserialize(serialize($values[$name])));
Copy link
Member Author

Choose a reason for hiding this comment

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

As the value might now be an incomplete PHP Class, we serialize it and then unserialize it again to get the actual value :)

Copy link
Member

Choose a reason for hiding this comment

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

I'm sure it works, and understand what it's doing from your description, but it reads really weird

fletch3555
fletch3555 previously approved these changes Sep 28, 2020
@codecov
Copy link

codecov bot commented Sep 28, 2020

Codecov Report

Merging #202 into 1.x will decrease coverage by 0.11%.
The diff coverage is 96.15%.

@@             Coverage Diff              @@
##                1.x     #202      +/-   ##
============================================
- Coverage     99.64%   99.52%   -0.12%     
- Complexity      305      311       +6     
============================================
  Files            97       98       +1     
  Lines           834      849      +15     
============================================
+ Hits            831      845      +14     
- Misses            3        4       +1     

@ArlonAntonius ArlonAntonius merged commit c52406d into 1.x Sep 30, 2020
@ArlonAntonius ArlonAntonius deleted the fix-queue-identification branch September 30, 2020 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants