Ethan3600 / magento2-CronjobManager

Cron Job Manager for Magento 2
https://packagist.org/packages/ethanyehuda/magento2-cronjobmanager
Open Software License 3.0
339 stars 72 forks source link

Declaration incompatible #137

Closed fballiano closed 1 year ago

fballiano commented 4 years ago

Hi, I'm upgrading to 1.9.1 (on M2.2.6 CE) but, when running setup:upgrade I get this error:

PHP Fatal error: Declaration of EthanYehuda\CronjobManager\Api\ScheduleManagementInterface\Proxy::execute(int $scheduleId) must be compatible with EthanYehuda\CronjobManager\Api\ScheduleManagementInterface::execute(int $scheduleId): bool in /Users/fab/Projects/xxxxxxxx/generated/code/EthanYehuda/CronjobManager/Api/ScheduleManagementInterface/Proxy.php on line 7

Is there something wrong in what I'm doing? Thanks!

fballiano commented 4 years ago

it happens on 1.9.0 and 1.9.1, but doesn't happen on 1.8.1

Ethan3600 commented 4 years ago

Hi @fballiano, thanks for reporting this issue. What version of PHP are you using? Have you tried this on later versions of Magento 2.2.x?

fballiano commented 4 years ago

It's a 7.1.something cause M2.2 can't run on more modern version sadly.

At the moment I can't try on 2.2.11 cause it's a production store so we can't really update it quickly (we have staging/dev environments but..)

designerdgr commented 4 years ago

Just installed the extension on M2.2.4 and i get the same error on setup:upgrade

fredden commented 4 years ago

This looks like the same issue reported in #128. There it's mentioned that this is a bug in Magento versions 2.2.x, fixed from (at least) 2.2.9 onward - see https://github.com/Ethan3600/magento2-CronjobManager/issues/128#issuecomment-515703542.

We have encountered this bug with a site we recently inherited on v2.2.2. We applied the following via composer-patches while we work on getting the site upgraded to v2.2.11.

patch to remove type declarations ``` diff --git a/Api/ScheduleManagementInterface.php b/Api/ScheduleManagementInterface.php index cef5e5d..65351b3 100644 --- a/Api/ScheduleManagementInterface.php +++ b/Api/ScheduleManagementInterface.php @@ -16,12 +16,12 @@ interface ScheduleManagementInterface * @throws NoSuchEntityException * @throws CouldNotSaveException */ - public function execute(int $scheduleId): bool; + public function execute(int $scheduleId); /** * @return string[] */ - public function listJobs(): array; + public function listJobs(); /** * @param string $jobCode @@ -35,31 +35,31 @@ interface ScheduleManagementInterface * @param int|null $time * @return Schedule */ - public function createSchedule(string $jobCode, $time = null): Schedule; + public function createSchedule(string $jobCode, $time = null); /** * @param string $jobCode * @return Schedule */ - public function scheduleNow(string $jobCode): Schedule; + public function scheduleNow(string $jobCode); /** * @param string $jobCode * @param int $time * @return Schedule */ - public function schedule(string $jobCode, int $time): Schedule; + public function schedule(string $jobCode, int $time); /** * @return bool */ - public function flush(): bool; + public function flush(); /** * @param int $jobId * @param int $timestamp * @return bool */ - public function kill(int $jobId, int $timestamp): bool; + public function kill(int $jobId, int $timestamp); } ```