final class UpdateDBCommands extends DrushCommands implements SiteAliasManagerAwareInterface (View source)

Traits

SiteAliasManagerAwareTrait
ProcessManagerAwareTrait
LoggerAwareTrait
IO
ConfigAwareTrait

Constants

REQ

OPT

EXIT_SUCCESS

EXIT_FAILURE

EXIT_FAILURE_WITH_CLARITY

UPDATEDB

STATUS

BATCH_PROCESS

Properties

protected CommandData|null $commandData from  DrushCommands

Methods

bool
startBrowser(string|null $uri = null, int $sleep = 0, int|null $port = null, string|bool $browser = false)

Starts a background browser/tab for the current site or a specified URL.

static bool
programExists($program)

No description

static string
getEditor(string|null $editor = null)

No description

getConfig()

Replaces same method in ConfigAwareTrait in order to provide a DrushConfig as return type. Helps with IDE completion.

__construct()

No description

SymfonyStyle
io()

Override Robo's IO function with our custom style.

DrushLoggerManager|null
logger()

Returns a logger object.

void
printFile(string $file)

Print the contents of a file.

preHook(CommandData $commandData)

Persist commandData for use in primary command callback. Used by 'topic' commands.

printFileTopic(CommandData $commandData)

Print the contents of a file. The path comes from the @topic annotation.

HandlerStack
getStack()

Get a Guzzle handler stack that uses the Drush logger.

int
updatedb($options = ['cache-clear' => true])

Apply any database updates required (as with running update.php).

RowsOfFields|null
updatedbStatus($options = ['format' => 'table'])

List any pending database updates.

UnstructuredListData
process(string $batch_id, $options = ['format' => 'json'])

Process operations in the specified batch set.

static void
updateDoOne(string $module, int $number, array $dependency_map, array $context)

Perform one update and store the results which will later be displayed on the finished page.

static void
updateDoOnePostUpdate(string $function, array $context)

Batch command that executes a single post-update.

void
updateFinished(bool $success, array $results, array $operations)

Batch finished callback.

bool
updateBatch()

Start the database update batch process.

static void
restoreMaintMode($status)

No description

array
getUpdateList()

No description

static void
cacheRebuild()

Clears caches and rebuilds the container.

array
getUpdatedbStatus(array $options)

Returns information about available module updates.

bool
updateCheckRequirements()

Log messages for any requirements warnings/errors.

Details

bool startBrowser(string|null $uri = null, int $sleep = 0, int|null $port = null, string|bool $browser = false)

Starts a background browser/tab for the current site or a specified URL.

Uses a non-blocking Process call, so Drush execution will continue.

Parameters

string|null $uri

Optional URI or site path to open in browser. If omitted, or if a site path is specified, the current site home page uri will be prepended if the site's hostname resolves.

int $sleep
int|null $port
string|bool $browser

Return Value

bool

if browser was opened. FALSE if browser was disabled by the user or a default browser could not be found.

static bool programExists($program)

No description

Parameters

$program

Return Value

bool

static string getEditor(string|null $editor = null)

No description

Parameters

string|null $editor

Return Value

string

DrushConfig getConfig()

Replaces same method in ConfigAwareTrait in order to provide a DrushConfig as return type. Helps with IDE completion.

__construct()

No description

protected SymfonyStyle io()

Override Robo's IO function with our custom style.

Return Value

SymfonyStyle

protected DrushLoggerManager|null logger()

Returns a logger object.

Return Value

DrushLoggerManager|null

protected void printFile(string $file)

Print the contents of a file.

Parameters

string $file

Full path to a file.

Return Value

void

preHook(CommandData $commandData)

Persist commandData for use in primary command callback. Used by 'topic' commands.

Parameters

CommandData $commandData

protected printFileTopic(CommandData $commandData)

Print the contents of a file. The path comes from the @topic annotation.

Parameters

CommandData $commandData

Full path to a file.

protected HandlerStack getStack()

Get a Guzzle handler stack that uses the Drush logger.

int updatedb($options = ['cache-clear' => true])

Apply any database updates required (as with running update.php).

Parameters

$options

Return Value

int

RowsOfFields|null updatedbStatus($options = ['format' => 'table'])

List any pending database updates.

Parameters

$options

Return Value

RowsOfFields|null

UnstructuredListData process(string $batch_id, $options = ['format' => 'json'])

Process operations in the specified batch set.

Parameters

string $batch_id
$options

Return Value

UnstructuredListData

static void updateDoOne(string $module, int $number, array $dependency_map, array $context)

Perform one update and store the results which will later be displayed on the finished page.

An update function can force the current and all later updates for this module to abort by returning a $ret array with an element like: $ret['#abort'] = array('success' => FALSE, 'query' => 'What went wrong'); The schema version will not be updated in this case, and all the aborted updates will continue to appear on update.php as updates that have not yet been run.

This method is static since since it is called by _drush_batch_worker().

Parameters

string $module

The module whose update will be run.

int $number

The update number to run.

array $dependency_map

The update dependency map.

array $context

The batch context object.

Return Value

void

static void updateDoOnePostUpdate(string $function, array $context)

Batch command that executes a single post-update.

Parameters

string $function

The post-update function to execute. The batch context object.

array $context

Return Value

void

void updateFinished(bool $success, array $results, array $operations)

Batch finished callback.

Parameters

bool $success

Whether the batch ended without a fatal error.

array $results
array $operations

Return Value

void

bool updateBatch()

Start the database update batch process.

Return Value

bool

static void restoreMaintMode($status)

No description

Parameters

$status

Return Value

void

array getUpdateList()

No description

Return Value

array

static void cacheRebuild()

Clears caches and rebuilds the container.

This is called in between regular updates and post updates. Do not use drush_drupal_cache_clear_all() as the cache clearing and container rebuild must happen in the same process that the updates are run in.

Drupal core's update.php uses drupal_flush_all_caches() directly without explicitly rebuilding the container as the container is rebuilt on the next HTTP request of the batch.

Return Value

void

See also

\Drupal\system\Controller\DbUpdateController::triggerBatch()

array getUpdatedbStatus(array $options)

Returns information about available module updates.

Parameters

array $options

Return Value

array

An indexed array (aka tuple) with 3 elements:

  • An array where each item is a 4 item associative array describing a pending update.
  • An array listing the first update to run, keyed by module.
  • An array listing the available warnings, keyed by module.

bool updateCheckRequirements()

Log messages for any requirements warnings/errors.

Return Value

bool