2
2
namespace Drush \Commands \core ;
3
3
4
4
use Consolidation \Log \ConsoleLogLevel ;
5
+ use DrushBatchContext ;
5
6
use Consolidation \OutputFormatters \StructuredData \RowsOfFields ;
6
7
use Consolidation \OutputFormatters \StructuredData \UnstructuredListData ;
7
8
use Consolidation \SiteAlias \SiteAliasManagerAwareInterface ;
@@ -169,14 +170,16 @@ public function process($batch_id, $options = ['format' => 'json'])
169
170
*
170
171
* This method is static since since it is called by _drush_batch_worker().
171
172
*
172
- * @param $module
173
+ * @param string $module
173
174
* The module whose update will be run.
174
- * @param $number
175
+ * @param int $number
175
176
* The update number to run.
176
- * @param $context
177
- * The batch context array
177
+ * @param array $dependency_map
178
+ * The update dependency map.
179
+ * @param DrushBatchContext $context
180
+ * The batch context object.
178
181
*/
179
- public static function updateDoOne ($ module , $ number , $ dependency_map , & $ context )
182
+ public static function updateDoOne ($ module , $ number , array $ dependency_map , DrushBatchContext $ context )
180
183
{
181
184
$ function = $ module . '_update_ ' . $ number ;
182
185
@@ -202,9 +205,13 @@ public static function updateDoOne($module, $number, $dependency_map, &$context)
202
205
Database::startLog ($ function );
203
206
}
204
207
205
- Drush::logger ()->notice ("Update started: $ function " );
208
+ if (empty ($ context ['results ' ][$ module ][$ number ]['type ' ])) {
209
+ Drush::logger ()->notice ("Update started: $ function " );
210
+ }
211
+
206
212
$ ret ['results ' ]['query ' ] = $ function ($ context ['sandbox ' ]);
207
213
$ ret ['results ' ]['success ' ] = true ;
214
+ $ ret ['type ' ] = 'update ' ;
208
215
} catch (\Throwable $ e ) {
209
216
// PHP 7 introduces Throwable, which covers both Error and Exception throwables.
210
217
$ ret ['#abort ' ] = ['success ' => false , 'query ' => $ e ->getMessage ()];
@@ -263,10 +270,10 @@ public static function updateDoOne($module, $number, $dependency_map, &$context)
263
270
*
264
271
* @param string $function
265
272
* The post-update function to execute.
266
- * @param array $context
267
- * The batch context.
273
+ * @param DrushBatchContext $context
274
+ * The batch context object .
268
275
*/
269
- public static function updateDoOnePostUpdate ($ function , & $ context )
276
+ public static function updateDoOnePostUpdate ($ function , DrushBatchContext $ context )
270
277
{
271
278
$ ret = [];
272
279
@@ -284,10 +291,13 @@ public static function updateDoOnePostUpdate($function, &$context)
284
291
list ($ module , $ name ) = explode ('_post_update_ ' , $ function , 2 );
285
292
module_load_include ('php ' , $ module , $ module . '.post_update ' );
286
293
if (function_exists ($ function )) {
287
- Drush::logger ()->notice ("Update started: $ function " );
294
+ if (empty ($ context ['results ' ][$ module ][$ name ]['type ' ])) {
295
+ Drush::logger ()->notice ("Update started: $ function " );
296
+ }
288
297
try {
289
298
$ ret ['results ' ]['query ' ] = $ function ($ context ['sandbox ' ]);
290
299
$ ret ['results ' ]['success ' ] = true ;
300
+ $ ret ['type ' ] = 'post_update ' ;
291
301
292
302
if (!isset ($ context ['sandbox ' ]['#finished ' ]) || (isset ($ context ['sandbox ' ]['#finished ' ]) && $ context ['sandbox ' ]['#finished ' ] >= 1 )) {
293
303
\Drupal::service ('update.post_update_registry ' )->registerInvokedUpdates ([$ function ]);
@@ -328,7 +338,7 @@ public static function updateDoOnePostUpdate($function, &$context)
328
338
// Setting this value will output an error message.
329
339
// @see \DrushBatchContext::offsetSet()
330
340
$ context ['error_message ' ] = "Update failed: $ function " ;
331
- } else {
341
+ } elseif ( $ context [ ' finished ' ] == 1 && empty ( $ ret [ ' #abort ' ])) {
332
342
// Setting this value will output a success message.
333
343
// @see \DrushBatchContext::offsetSet()
334
344
$ context ['message ' ] = "Update completed: $ function " ;
0 commit comments