-
-
Notifications
You must be signed in to change notification settings - Fork 91
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
Conversation
@@ -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); |
There was a problem hiding this comment.
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]]); |
There was a problem hiding this comment.
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
if (!in_array($property->getName(), ['tenant', 'tenant_identifier', 'tenant_key'])) { | ||
continue; | ||
} |
There was a problem hiding this comment.
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]))); |
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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
Codecov Report
@@ 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 |
No description provided.