API / Minn\Ops / UpgraderRun

UpgraderRun final readonly class

Minn\Ops\UpgraderRun · public/minn/src/Minn/Ops/UpgraderRun.php · 113 lines

The engine's own installs and updates, run through the reference's upgraders (Plugin_Upgrader, Theme_Upgrader) so plugins hear every hook a WordPress install or update tells them: the REST plugin route, Minn Admin's install, upload and update routes, the CLI verbs and the automatic updates all come here. The Minn update service's packages are fetched over the engine's own client (Packages::fetch: https, the service's host, a size cap) and handed to the upgrader as a file through upgrader_pre_download, so where Minn gets code is never the plugin-filterable HTTP API's to change. A package from anywhere else is installed only when its publisher answered upgrader_pre_download with a copy it checked (or refused it): nobody's word, no install. A package from the service passes Archive's checks before the upgrader unpacks it; a local file (an upload, checked by Packages) is the upgrader's to read. The upgrader's refusals come back as the engine's REST errors, in the words its routes already use.

Constants and properties

privatereadonly Minn\Ops\Packages $packages

Promoted from the constructor.

Public

new__construct(Minn\Ops\Packages $packages)#
methodinstall(string $kind, string $package, array $args = array ( )): array#

Installs a package (or, with overwrite_package, replaces the folder it lands on): its folder and the sha256 of a package fetched from the service, '' otherwise.

$argsarray<string, mixed>the upgrader's install arguments
@return array{folder: string, sha256: string}
methodupdate(string $kind, string $item, string $package): string#

Applies the offer the update transient holds for one plugin (file) or theme (folder), as Minn Admin does on WordPress: a plugin through bulk_upgrade, a theme through upgrade. The sha256 of the package, '' when it did not come from the service.

Internals 3

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

privateguarded(string $package, string $sha256, Closure $call): mixed#

Runs $call with the engine's say over the download: the service's package fetched here, any other remote one only on its publisher's answer. $sha256 is set when the service's package was fetched.

privaterefusal(string $kind, WP_Ajax_Upgrader_Skin $skin, mixed $answer, WP_Upgrader $upgrader): Minn\RestError#

The upgrader's refusal in the engine's words: a taken folder says what is there and what came.

privatetaken(string $kind, string $destination, WP_Upgrader $upgrader): Minn\RestError#

The refusal for a folder already taken, naming what is there and what the package holds.