API / Minn\Runtime / Upgrade

Upgrade final class

Minn\Runtime\Upgrade · public/minn/src/Minn/Runtime/Upgrade.php · 349 lines

What WP_Upgrader does with a package (probe upgrader), for the facade's upgraders and so for everything that installs or updates a plugin or a theme. run() is the whole pass: the options through upgrader_package_options, the package downloaded and unpacked into wp-content/upgrade/, put in place by install(), the result through upgrader_install_package_result and told to the skin, and, for a single item, upgrader_process_complete. The steps a subclass may replace (fs_connect, download_package, unpack_package, install_package, clear_destination) are called on the upgrader itself, as the reference calls them, so a plugin's own upgrader class is honoured.

An update names the folder it replaces (hook_extra temp_backup); that copy is moved to wp-content/upgrade-temp-backup/<dir>/<slug> before the destination is cleared, moved back when the new one fails, and removed once the pass is over. The reference keeps it for a weekly event to clear and puts it back at shutdown; Minn keeps nothing and restores at once.

Constants and properties

privateRUN = array ( 'package' => '', 'destination' => '', 'clear_destination' => false, 'clear_working' => true, 'abort_if_destination_exists' => true, 'is_multi' => false, 'hook_extra' => array ( ), )

The run options in the reference's order, which upgrader_package_options sees.

Public

staticrun(WP_Upgrader $upgrader, array $options): mixed#

WP_Upgrader::run; false when the filesystem cannot be reached.

staticbulk(WP_Upgrader $upgrader, array $items, array $offers, array $how): array|false#

The bulk pass of Plugin_Upgrader and Theme_Upgrader: the skin opened, maintenance mode on when an active item is replaced, each item with an offer run as one of many (one without is up to date, answered true), the pass stopped when the filesystem refuses, then maintenance off, the update cache cleaned, upgrader_process_complete told the whole list, and the skin closed. False when the filesystem cannot be reached.

$itemslist<string>plugin files or theme folders
$offersarray<string, mixed>item => the offer (its package)
$howarray{directories: list<string>, maintenance: bool, prepare: \Closure(string): array{0: string, 1: array}, clean: \Closure(): void, complete: array}
@return array<string, mixed>|false
staticinstall(WP_Upgrader $upgrader, array $args): WP_Error|array#

WP_Upgrader::install_package: the unpacked folder chosen (its one folder, or the working folder when it holds several things), offered to upgrader_pre_install and upgrader_source_selection, the destination cleared or refused when something is there, the folder moved in (and walked by the symbol gate at its next check), and the result offered to upgrader_post_install.

staticunpack(WP_Upgrader $upgrader, string $package): WP_Error|string#

WP_Upgrader::unpack_package, without the package's deletion (the caller's): the upgrade folder emptied of what earlier passes left, the package unzipped into a folder named for it, and an archive that will not open refused in the upgrader's words with the reader's reason.

staticclear(WP_Upgrader $upgrader, string $remote): WP_Error|bool#

WP_Upgrader::clear_destination: whatever is at the destination removed; true when nothing is left there.

staticmaintenanceOn(WP_Upgrader $upgrader): void#

Maintenance mode on, as a bulk update of active plugins turns it on: the .maintenance file the front door reads.

staticmaintenanceOff(WP_Upgrader $upgrader): void#

Maintenance mode off; said only when it was on.

Internals 10

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privatedestinationFor(string $destination, string $source): string#

The folder the item lands in: a folder named for the package inside a known parent, otherwise the destination itself.

privateclearOrRefuse(WP_Upgrader $upgrader, string $remote, array $args): WP_Error|bool#

Clears the destination (an update's copy set aside first), or refuses when something is there and must not be replaced.

privatemove(string $source, string $remote, WP_Upgrader $upgrader): WP_Error|bool#

The source moved (or, across filesystems, copied) to the destination; an existing destination is merged into.

privatecopyInto(string $from, string $to): bool#
privatereport(WP_Upgrader $upgrader, mixed $result, array $extra): void#

The run's outcome told to the skin; an update's set-aside copy put back on failure, removed on success.

privatesetAside(WP_Upgrader $upgrader, array $backup): WP_Error|true#

Moves an update's current copy to the backup folder (one left there by an earlier pass is replaced).

privateputBack(array $backup): void#
privateforget(array $backup): void#
privatebackedUp(array $backup, string $end): ?string#

Where an update's copy lives ('from') and where it is set aside ('to'), or null when the update names none.

privatelisting(string $folder): array#

A folder's entries in the order the filesystem gives them, as the reference's dirlist reads them (no sorting).

@return list<string>