update_invoke_post_update($function, &$context)
Executes a single hook_post_update_NAME().
Parameters
string $function: The function name, that should be executed.
array $context: The batch context array.
File
- core/includes/update.inc, line 228
- Drupal database update API.
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 | function update_invoke_post_update( $function , & $context ) { $ret = []; // If this update was aborted in a previous step, or has a dependency that was // aborted in a previous step, go no further. if (! empty ( $context [ 'results' ][ '#abort' ])) { return ; } list( $module , $name ) = explode ( '_post_update_' , $function , 2); module_load_include( 'php' , $module , $module . '.post_update' ); if (function_exists( $function )) { try { $ret [ 'results' ][ 'query' ] = $function ( $context [ 'sandbox' ]); $ret [ 'results' ][ 'success' ] = TRUE; if (!isset( $context [ 'sandbox' ][ '#finished' ]) || (isset( $context [ 'sandbox' ][ '#finished' ]) && $context [ 'sandbox' ][ '#finished' ] >= 1)) { \Drupal::service( 'update.post_update_registry' )->registerInvokedUpdates([ $function ]); } } // @TODO We may want to do different error handling for different exception // types, but for now we'll just log the exception and return the message // for printing. catch (Exception $e ) { watchdog_exception( 'update' , $e ); $variables = Error::decodeException( $e ); unset( $variables [ 'backtrace' ]); $ret [ '#abort' ] = [ 'success' => FALSE, 'query' => t( '%type: @message in %function (line %line of %file).' , $variables ), ]; } } if (isset( $context [ 'sandbox' ][ '#finished' ])) { $context [ 'finished' ] = $context [ 'sandbox' ][ '#finished' ]; unset( $context [ 'sandbox' ][ '#finished' ]); } if (!isset( $context [ 'results' ][ $module ][ $name ])) { $context [ 'results' ][ $module ][ $name ] = array (); } $context [ 'results' ][ $module ][ $name ] = array_merge ( $context [ 'results' ][ $module ][ $name ], $ret ); if (! empty ( $ret [ '#abort' ])) { // Record this function in the list of updates that were aborted. $context [ 'results' ][ '#abort' ][] = $function ; } $context [ 'message' ] = t( 'Post updating @module' , [ '@module' => $module ]); } |
Please login to continue.