Documentation

CRM_Extension_QueueDownloader
in package

Prepare a set of steps for downloading extension upgrades.

The general idea is:

$dl = new CRM_Extension_QueueDownloader(); $dl->addDownloads( ['ext-1' => 'https://example.com/ext-1/releases/1.2.3./zip'] ); $runner = new CRM_Queue_Runner([ 'queue' => $dl->fillQueue(), ... ]); $runner->runAllViaWeb();

== NOTE: Using subprocesses

When upgrading extensions, you MUST provide a chance to reset the PHP process (loading new PHP files).

We will assume that every task runs in a new PHP process. This is compatible with runAllViaWeb() not but runAll().

Headless clients (like cv) will need to use a suitable runner that spawns new subprocesses.

== NOTE: Sequencing

When you have multiple extensions to download/enable (and each may come with different start-state and version; and each may have differing versioned-dependencies)... then there is an interesting question about how to sequence/group the operations.

Some operations target multiple ext's concurrently (like "rebuild" or "hook_upgrade" or "enable(keys=>A,B,C)"). It's nice to lean into this style ("fetch A+B+C" then "rebuild system" then "upgrade A+B+C") because it's a good facsimile of the behavior in SCM (git/gzr/svn)-based workflows.

However, it's not perfect, and there may still be edge-cases where that doesn't work. I'm pessimistic that this class will be able to automatically form perfect+universal plans based only on a declared list of downloads.

So if a problematic edge-case comes up, how could you resolve it? The caller can decide sequencing/batching. Compare:

Ex 1: Download 'a' and 'b' in the same batch. They will be fetched, swapped, and rebuilt in tandem.

$dl->addDownloads(['a' => ..., 'b' => ...]);

Ex 2: Download 'a' and 'b' as separate batches. 'a' will be fully handled before 'b'.

$dl->addDownloads(['a' => ...]); $dl->addDownloads(['b' => ...]);

Tags
copyright

CiviCRM LLC https://civicrm.org/licensing

Table of Contents

Constants

QUEUE_PREFIX  = 'ext_upgrade_'

Properties

$batches  : array<string|int, mixed>
$cleanup  : bool
$queue  : CRM_Queue_Queue
$upId  : string
Unique ID for this batch of downloads.

Methods

__construct()  : mixed
addDownloads()  : $this
Add a set of extensions to download and enable.
addEnable()  : $this
Add a set of keys which should be enabled. (Use this if you -only- want to enable. If you are actually downloading, then use addDownloads().)
createQueue()  : CRM_Queue_Queue
fillQueue()  : CRM_Queue_Queue
Take the list of pending updates (from addDownload, addEnable)
getTitle()  : string
getStagingPath()  : string
task()  : CRM_Queue_Task
Create a CRM_Queue_Task that executes on this class.
quotedList()  : mixed

Constants

Properties

$batches

protected array<string|int, mixed> $batches = []

Ex: [0 => ['type' => 'download', 'urls' => ['my.extension' => 'https://example/my.extension-1.0.zip']]] Ex: [0 => ['type' => 'enable', 'keys' => ['my.extension']]]

$upId

Unique ID for this batch of downloads.

protected string $upId

Ex: 20250607_abcd1234abcd1234

Methods

__construct()

public __construct([bool $cleanup = true ][, CRM_Queue_Queue|null $queue = null ]) : mixed
Parameters
$cleanup : bool = true

Whether to delete temporary files and backup files at the end.

$queue : CRM_Queue_Queue|null = null

addDownloads()

Add a set of extensions to download and enable.

public addDownloads(array<string|int, mixed> $downloads[, bool $autoApply = true ]) : $this
Parameters
$downloads : array<string|int, mixed>

Ex: ['ext1' => 'https://example.com/ext1/releases/1.0.zip']

$autoApply : bool = true

TRUE if the downloader should execute the installation/upgrade routines FALSE if the downloader should only get the files and put them in place

Return values
$this

addEnable()

Add a set of keys which should be enabled. (Use this if you -only- want to enable. If you are actually downloading, then use addDownloads().)

public addEnable(array<string|int, mixed> $keys) : $this
Parameters
$keys : array<string|int, mixed>

Ex: ['my.ext1', 'my.ext2']

Return values
$this

getStagingPath()

protected getStagingPath(mixed ...$moreParts) : string
Parameters
$moreParts : mixed
Return values
string

task()

Create a CRM_Queue_Task that executes on this class.

protected task(string $title, string $method[, array<string|int, mixed> $args = [] ]) : CRM_Queue_Task
Parameters
$title : string
$method : string
$args : array<string|int, mixed> = []
Return values
CRM_Queue_Task

quotedList()

private quotedList(array<string|int, mixed> $items) : mixed
Parameters
$items : array<string|int, mixed>

        
On this page

Search results