-
-
Notifications
You must be signed in to change notification settings - Fork 52
Description
I am attempting to use the new Base64 serializer/encoder to serialize and encode my workflow objects. To do this, I added this line to the config/workflows.php
file in my Laravel project:
'serializer' => Workflow\Serializers\Base64::class,
When I test this, it seems that the workflows are encoded using Y::class
instead of Base64::class
as I intended. I traced the process and found what I think is an issue in Serializer.php
. Specifically, the call to config('serializer')
needs to be changed to config('workflows.serializer')
:
public static function __callStatic(string $name, array $arguments)
{
if ($name === 'unserialize') {
if (str_starts_with($arguments[0], 'base64:')) {
$instance = Base64::getInstance();
} else {
$instance = Y::getInstance();
}
} else {
$instance = config('serializer', Y::class)::getInstance();
}
if (method_exists($instance, $name)) {
return $instance->{$name}(...$arguments);
}
}
When I make this change, my workflows are successfully serialized using Base64:
# Current code in this package
$instance = config('serializer', Y::class)::getInstance();
# This is what I changed it to (from 'serializer' to 'workflows.serializer')
$instance = config('workflows.serializer', Y::class)::getInstance();
I don't have experience developing a Laravel package, so I am unfamiliar with accessing configurations for packages. Is this a typo in the package, and should the package include the prefix of workflows
, or does Laravel automatically add that to any code that is executed from within the package?
I'm not sure if this is a bug or not. What do you think, @rmcdaniel ? It seems like a bug unless Laravel is supposed to do some magic here.