magento2-CronjobManager icon indicating copy to clipboard operation
magento2-CronjobManager copied to clipboard

Declaration incompatible

Open fballiano opened this issue 4 years ago • 5 comments

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 avatar Mar 20 '20 10:03 fballiano

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

fballiano avatar Mar 20 '20 10:03 fballiano

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?

Ethan3600 avatar Mar 22 '20 12:03 Ethan3600

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..)

fballiano avatar Mar 22 '20 13:03 fballiano

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

designerdgr avatar Apr 01 '20 13:04 designerdgr

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);
 
 }

fredden avatar May 12 '20 22:05 fredden