update_authorize_update_batch_finished($success, $results)
Batch callback: Performs actions when the authorized update batch is done.
This processes the results and stashes them into SESSION such that authorize.php will render a report. Also responsible for putting the site back online and clearing the update status storage after a successful update.
Parameters
$success: TRUE if the batch operation was successful; FALSE if there were errors.
$results: An associative array of results from the batch operation.
File
- core/modules/update/update.authorize.inc, line 209
- Callbacks and related functions invoked by authorize.php to update projects.
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | function update_authorize_update_batch_finished( $success , $results ) { foreach ( $results [ 'log' ] as $messages ) { if (! empty ( $messages [ '#abort' ])) { $success = FALSE; } } $offline = \Drupal::state()->get( 'system.maintenance_mode' ); if ( $success ) { // Now that the update completed, we need to clear the available update data // and recompute our status, so prevent show bogus results. _update_authorize_clear_update_status(); // Take the site out of maintenance mode if it was previously that way. if ( $offline && isset( $_SESSION [ 'maintenance_mode' ]) && $_SESSION [ 'maintenance_mode' ] == FALSE) { \Drupal::state()->set( 'system.maintenance_mode' , FALSE); $page_message = array ( 'message' => t( 'Update was completed successfully. Your site has been taken out of maintenance mode.' ), 'type' => 'status' , ); } else { $page_message = array ( 'message' => t( 'Update was completed successfully.' ), 'type' => 'status' , ); } } elseif (! $offline ) { $page_message = array ( 'message' => t( 'Update failed! See the log below for more information.' ), 'type' => 'error' , ); } else { $page_message = array ( 'message' => t( 'Update failed! See the log below for more information. Your site is still in maintenance mode.' ), 'type' => 'error' , ); } // Since we're doing an update of existing code, always add a task for // running update.php. $url = Url::fromRoute( 'system.db_update' ); $results [ 'tasks' ][] = t( 'Your modules have been downloaded and updated.' ); $results [ 'tasks' ][] = [ '#type' => 'link' , '#url' => $url , '#title' => t( 'Run database updates' ), // Since this is being called outsite of the primary front controller, // the base_url needs to be set explicitly to ensure that links are // relative to the site root. // @todo Simplify with https://www.drupal.org/node/2548095 '#options' => [ 'absolute' => TRUE, 'base_url' => $GLOBALS [ 'base_url' ], ], '#access' => $url ->access(\Drupal::currentUser()) ]; // Unset the variable since it is no longer needed. unset( $_SESSION [ 'maintenance_mode' ]); // Set all these values into the SESSION so authorize.php can display them. $_SESSION [ 'authorize_results' ][ 'success' ] = $success ; $_SESSION [ 'authorize_results' ][ 'page_message' ] = $page_message ; $_SESSION [ 'authorize_results' ][ 'messages' ] = $results [ 'log' ]; $_SESSION [ 'authorize_results' ][ 'tasks' ] = $results [ 'tasks' ]; $_SESSION [ 'authorize_page_title' ] = t( 'Update manager' ); } |
Please login to continue.