Aimeos Context Serialization Issue
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
- MuhammadSohailAfzal
- Posts: 1
- Joined: 27 Jul 2023, 21:11
Aimeos Context Serialization Issue
Hi everyone,
I am trying to create a new queue job as laravel provided.
and the function I want to process by this job is using aimeos context object.
now whenever I tried to dispatched the job it throws and exception related to serialization of aimeos context class
Aimeos Version: 2023.07
Laravel Version: 10
I am attaching my some code might be it can help to understand the issue
ProductService
Queue Job
Dispatching the Job
I am trying to create a new queue job as laravel provided.
and the function I want to process by this job is using aimeos context object.
now whenever I tried to dispatched the job it throws and exception related to serialization of aimeos context class
PHP Version: 8.1ErrorException: serialize(): Aimeos\MShop\Context::__sleep() should return an array only containing the names of instance-variables to serialize in file D:\laragon\www\kitchen-aid\vendor\laravel\framework\src\Illuminate\Queue\Queue.php on line 158
Aimeos Version: 2023.07
Laravel Version: 10
I am attaching my some code might be it can help to understand the issue
ProductService
Code: Select all
class ProductService
{
protected $productRepository;
private $aimeosContext;
public function __construct(ERPProductRepository $productRepository)
{
$this->productRepository = $productRepository;
$this->aimeosContext = app('aimeos.context')->get(true);
}
public function syncMshopProductFromErpProduct(array $product)
{
/* @var AimeosItem $productItem */
/* @var AimeosManager $productManager */
/* @var AimeosItem[] $productItems */
$productManager = MShop::create($this->aimeosContext, 'product');
Queue Job
Code: Select all
class ProcessErpProducts implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
private ProductService $productService;
/**
* Create a new job instance.
*/
public function __construct(ProductService $productService)
{
$this->productService = $productService;
}
/**
* Execute the job.
*/
public function handle(): void
{
$product = []; //product data
$this->productService->syncMshopProductFromErpProduct($product);
}
}
Code: Select all
ProcessErpProducts::dispatch($this->productService);
Re: Aimeos Context Serialization Issue
Strange, the __sleep() method of the context object already does that:
https://github.com/aimeos/aimeos-core/b ... t.php#L102
Can you add debug output in that line to see what get_object_vars() returns?
https://github.com/aimeos/aimeos-core/b ... t.php#L102
Can you add debug output in that line to see what get_object_vars() returns?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star