Blesta Source Documentation

Upgrades extends Model

Handles the upgrade process to bring the current database up to the requirements of the installed files.

Table of Contents

Properties

$environment

Methods

__construct() Setup
compareVersions() Compares to semantic version numbers and returns the result
errors() Return all errors
getEnvironment() Fetches the current tasks environment
getMappings() Returns all upgrade mappings
getUpgrades() Generates a mapping of all files
parseVersion() Parse the given semantic version number
processObject() Processes the given object, passes the callback to the object by passing the current task count being executed and the total number of tasks to be executed for that object.
processSql() Processes the given SQL file, executes the given callback after each query by passing the current query number being executed and the total number of queries to be executed for that file.
setEnvironment() Set the environment where the task are going to be executed
start() Starts the upgrade process
startExtensions() Starts the upgrade process for extensions
clearNavigationCache() Clears the staff navigation cache
processExtension() Processes the upgrade for each module installed in the system
Properties

$environment

private string $environment = 'upgrade'

The environment where the upgrade is being executed, it could be "install" or "upgrade"

Methods

__construct()

Setup

public __construct([array<string|int, mixed> $db_info = null ]) : mixed
Parameters
$db_info : array<string|int, mixed> = null

The database connection information (optional)

compareVersions()

Compares to semantic version numbers and returns the result

public compareVersions(string $a, string $b) : array<string|int, mixed>
Parameters
$a : string

A semantic version number

$b : string

A semantic version number

Return values
array<string|int, mixed>

An array containing the comparison of the two versions, including:

  • major How major $a compares to $b (>, <, =)
  • minor How minor $a compares to $b (>, <, =)
  • patch How patch $a compares to $b (>, <, =)
  • pre How pre release $a compares to $b (>, <, =)
  • build How build meta data $a compare to $b (>, <, =)
  • diff How $a and $b differ (major, minor, patch, pre, build, null if versions are identical)
  • latest Either $a or $b, whichever is newer

errors()

Return all errors

public errors() : array<string|int, mixed>
Return values
array<string|int, mixed>

An array of errors

getEnvironment()

Fetches the current tasks environment

public getEnvironment() : string
Return values
string

The environment where the tasks are running

getMappings()

Returns all upgrade mappings

public getMappings() : array<string|int, mixed>
Return values
array<string|int, mixed>

An array in key/value pairs where each key is the version from and each value is the version to

getUpgrades()

Generates a mapping of all files

public getUpgrades(string $from, string $to) : mixed
Parameters
$from : string

The version to start the upgrade from

$to : string

The version to upgrade to, null to upgrade to latest version

Tags
throws
Exception

Thrown if the required upgrade files are not present

parseVersion()

Parse the given semantic version number

public parseVersion(string $v) : array<string|int, mixed>
Parameters
$v : string

The version to parse

Return values
array<string|int, mixed>

An array containing version info:

  • major
  • minor
  • patch
  • pre
  • build

processObject()

Processes the given object, passes the callback to the object by passing the current task count being executed and the total number of tasks to be executed for that object.

public processObject(string $obj[, callable $callback = null ]) : mixed
Parameters
$obj : string

The full path to the SQL file to execute

$callback : callable = null

The callback to execute after each task in the upgrade process

processSql()

Processes the given SQL file, executes the given callback after each query by passing the current query number being executed and the total number of queries to be executed for that file.

public processSql(string $file[, callable $callback = null ]) : mixed
Parameters
$file : string

The full path to the SQL file to execute

$callback : callable = null

The callback to execute after each query

Tags
throws
PDOExcetion

if any query fails

setEnvironment()

Set the environment where the task are going to be executed

public setEnvironment(string $environment) : mixed
Parameters
$environment : string

The environment where the upgrade tasks are running, "install" or "upgrade"

start()

Starts the upgrade process

public start(string $from, string $to[, callable $callback = null ][, bool $extensions = true ]) : mixed
Parameters
$from : string

The version to start the upgrade from

$to : string

The version to upgrade to, null to upgrade to latest version

$callback : callable = null

The callback to execute after each task in the upgrade process (for each version)

$extensions : bool = true

True to include extensions on the upgrade, false otherwise (default, true)

startExtensions()

Starts the upgrade process for extensions

public startExtensions([callable $callback = null ]) : mixed
Parameters
$callback : callable = null

The callback to execute after each task in the upgrade process (for each version)

clearNavigationCache()

Clears the staff navigation cache

private clearNavigationCache() : mixed

processExtension()

Processes the upgrade for each module installed in the system

private processExtension(mixed $type[, callable $callback = null ]) : mixed
Parameters
$type : mixed
$callback : callable = null

The callback to execute after each extension is processed

Tags
subpackage

components.upgrades

copyright

Copyright (c) 2010, Phillips Data, Inc.

license

http://www.blesta.com/license/ The Blesta License Agreement

link

Blesta


        
On this page

Search results