@@ -100,6 +100,11 @@ class ProcessCronQueueObserver implements ObserverInterface
100
100
*/
101
101
protected $ timezone ;
102
102
103
+ /**
104
+ * @var \Symfony\Component\Process\PhpExecutableFinder
105
+ */
106
+ protected $ phpExecutableFinder ;
107
+
103
108
/**
104
109
* @param \Magento\Framework\ObjectManagerInterface $objectManager
105
110
* @param ScheduleFactory $scheduleFactory
@@ -109,6 +114,7 @@ class ProcessCronQueueObserver implements ObserverInterface
109
114
* @param \Magento\Framework\App\Console\Request $request
110
115
* @param \Magento\Framework\ShellInterface $shell
111
116
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $timezone
117
+ * @param \Symfony\Component\Process\PhpExecutableFinder $phpExecutableFinder
112
118
*/
113
119
public function __construct (
114
120
\Magento \Framework \ObjectManagerInterface $ objectManager ,
@@ -118,7 +124,8 @@ public function __construct(
118
124
\Magento \Framework \App \Config \ScopeConfigInterface $ scopeConfig ,
119
125
\Magento \Framework \App \Console \Request $ request ,
120
126
\Magento \Framework \ShellInterface $ shell ,
121
- \Magento \Framework \Stdlib \DateTime \TimezoneInterface $ timezone
127
+ \Magento \Framework \Stdlib \DateTime \TimezoneInterface $ timezone ,
128
+ \Symfony \Component \Process \PhpExecutableFinder $ phpExecutableFinder
122
129
) {
123
130
$ this ->_objectManager = $ objectManager ;
124
131
$ this ->_scheduleFactory = $ scheduleFactory ;
@@ -128,6 +135,7 @@ public function __construct(
128
135
$ this ->_request = $ request ;
129
136
$ this ->_shell = $ shell ;
130
137
$ this ->timezone = $ timezone ;
138
+ $ this ->phpExecutableFinder = $ phpExecutableFinder ;
131
139
}
132
140
133
141
/**
@@ -147,6 +155,8 @@ public function execute(\Magento\Framework\Event\Observer $observer)
147
155
$ currentTime = $ this ->timezone ->scopeTimeStamp ();
148
156
$ jobGroupsRoot = $ this ->_config ->getJobs ();
149
157
158
+ $ phpPath = $ this ->phpExecutableFinder ->find () ?: 'php ' ;
159
+
150
160
foreach ($ jobGroupsRoot as $ groupId => $ jobsRoot ) {
151
161
if ($ this ->_request ->getParam ('group ' ) !== null
152
162
&& $ this ->_request ->getParam ('group ' ) !== '\'' . ($ groupId ) . '\''
@@ -160,7 +170,7 @@ public function execute(\Magento\Framework\Event\Observer $observer)
160
170
) == 1
161
171
)) {
162
172
$ this ->_shell ->execute (
163
- ' php %s cron:run --group= ' . $ groupId . ' -- ' . CLI ::INPUT_KEY_BOOTSTRAP . '= '
173
+ $ phpPath . ' %s cron:run --group= ' . $ groupId . ' -- ' . CLI ::INPUT_KEY_BOOTSTRAP . '= '
164
174
. self ::STANDALONE_PROCESS_STARTED . '=1 ' ,
165
175
[
166
176
BP . '/bin/magento '
0 commit comments