Hi,
I have a jobs website we import jobs to. When doing a Batch Task, we add a Command for “import” which is working absolutely fine.
However, we added a new command for “delete”, but for some reason we keep getting this error, and it makes absolutely no sense as to why… because its built in the same way.
Could not decode message: Cannot create an instance of "Concrete\TLA\JobImport\Logging\Command\JobDeletedCommand" from serialized data because its constructor requires parameter "pageId" to be present.
Below is the line adding it to the Batch - this is working fine, and the page id is there, I can echo it out etc… Also, if I replace this whole line with an ImportCommand, it works fine, so nothing wrong here.
...
$this->batch->add(new JobDeletedCommand($page->getCollectionID()));
...
The simple command. Here you see the constructor has the right paramaters.
<?php
namespace Concrete\TLA\JobImport\Logging\Command;
use Concrete\Core\Foundation\Command\Command;
defined('C5_EXECUTE') or die("Access Denied.");
class JobDeletedCommand extends Command
{
protected $pageId;
public function __construct($pageId)
{
$this->pageId = $pageId;
}
public function getPageToDelete()
{
return $this->pageId;
}
}
Next is the Handler, which again, is an empty handler as I commented out logic to check it wasnt causing it.
<?php
namespace Concrete\TLA\JobImport\Logging\Command;
use Concrete\Core\Command\Task\Output\OutputAwareInterface;
use Concrete\Core\Command\Task\Output\OutputAwareTrait;
defined('C5_EXECUTE') or die("Access Denied.");
class JobDeletedCommandHandler implements OutputAwareInterface
{
use OutputAwareTrait;
public function __invoke(JobDeletedCommand $command)
{
//$pageToDelete = \Page::getByID($command->getPageToDelete());
//$jobId = $pageToDelete->getAttribute('job_id');
//$this->output->write(t('Deleting Job ID: %s', $jobId));
//$pageToDelete->delete();
}
}
So, why is Concrete telling me I am not passing the constructor to the Command… I CLEARLY am.
As mentioned, my ImportCommand works fine and looks like this:
<?php
namespace Concrete\TLA\JobImport\Logging\Command;
use Concrete\Core\Foundation\Command\Command;
defined('C5_EXECUTE') or die("Access Denied.");
class ImportCommand extends Command
{
protected $fileID;
protected $update;
protected $jobPath;
public function __construct(array $jobData, bool $update, string $jobPath)
{
$this->jobData = $jobData;
$this->update = $update;
$this->jobPath = $jobPath;
}
public function getJobData(): array
{
return $this->jobData;
}
public function getJobPath(): string
{
return $this->jobPath;
}
public function isUpdate(): bool
{
return $this->update;
}
}
Am I missing something obvious? Or is there something weird going on here?