Updates

Type
Class
Namespace
craft\services
Inherits
craft\services\Updates » yii\base\Component » yii\base\BaseObject
Implements
yii\base\Configurable
Since
3.0

Updates service.

An instance of the Updates service is globally accessible in Craft via Craft::$app->updates.

View source

Public Properties

$cacheKey

Signature

public string $cacheKey = 'updates'

$hasCraftVersionChanged

Type
boolean
Access
Read-only

View source

Signature

public boolean getHasCraftVersionChanged ( )

$isCraftDbMigrationNeeded

Type
boolean
Access
Read-only

View source

Signature

public boolean getIsCraftDbMigrationNeeded ( )

$isCraftSchemaVersionCompatible

Type
boolean
Access
Read-only

View source

Signature

public boolean getIsCraftSchemaVersionCompatible ( )

$isCriticalUpdateAvailable

Type
boolean
Access
Read-only

View source

Signature

public boolean getIsCriticalUpdateAvailable ( \craft\services\bool $check = false )

$isPluginDbUpdateNeeded

Type
boolean
Access
Read-only

View source

Signature

public boolean getIsPluginDbUpdateNeeded ( )

$isUpdateInfoCached

Type
boolean
Access
Read-only

View source

Signature

public boolean getIsUpdateInfoCached ( )

$newPluginInfo

Signature

public boolean setNewPluginInfo ( craft\base\PluginInterface $plugin )

$pendingMigrationHandles

Type
string[]
Access
Read-only

View source

Signature

public string[] getPendingMigrationHandles ( $includeContent = false )

$totalAvailableUpdates

Type
integer
Access
Read-only

View source

Signature

public integer getTotalAvailableUpdates ( \craft\services\bool $check = false )

$updates

Signature

public craft\models\Updates getUpdates ( \craft\services\bool $refresh = false )

$wasCraftBreakpointSkipped

Type
boolean
Access
Read-only

View source

Signature

public boolean getWasCraftBreakpointSkipped ( )

Public Methods

MethodDescription
__call()Calls the named method which is not a class method.
__clone()This method is called after the object is created by cloning an existing one.
__construct()Constructor.
__get()Returns the value of an object property.
__isset()Checks if a property is set, i.e. defined and not null.
__set()Sets value of an object property.
__unset()Sets an object property to null.
attachBehavior()Attaches a behavior to this component.
attachBehaviors()Attaches a list of behaviors to the component.
behaviors()Returns a list of behaviors that this component should behave as.
canGetProperty()Returns a value indicating whether a property can be read.
canSetProperty()Returns a value indicating whether a property can be set.
className()Returns the fully qualified name of this class.
detachBehavior()Detaches a behavior from the component.
detachBehaviors()Detaches all behaviors from the component.
ensureBehaviors()Makes sure that the behaviors declared in behaviors() are attached to this component.
getBehavior()Returns the named behavior object.
getBehaviors()Returns all behaviors attached to this component.
getHasCraftVersionChanged()Returns whether a different Craft version has been uploaded.
getIsCraftDbMigrationNeeded()Returns whether Craft needs to run any database migrations.
getIsCraftSchemaVersionCompatible()Returns whether the uploaded DB schema is equal to or greater than the installed schema.
getIsCriticalUpdateAvailable()Returns whether a critical update is available.
getIsPluginDbUpdateNeeded()Returns whether a plugin needs to run a database update.
getIsUpdateInfoCached()Returns whether the update info is cached.
getPendingMigrationHandles()Returns a list of things with updated schema versions.
getTotalAvailableUpdates()
getUpdates()
getWasCraftBreakpointSkipped()Returns true if the version stored in craft_info is less than the minimum required version on the file system. This This effectively makes sure that a user cannot manually update past a manual breakpoint.
hasEventHandlers()Returns a value indicating whether there is any handler attached to the named event.
hasMethod()Returns a value indicating whether a method is defined.
hasProperty()Returns a value indicating whether a property is defined.
init()Initializes the object.
off()Detaches an existing event handler from this component.
on()Attaches an event handler to an event.
runMigrations()Runs the pending migrations for the given list of handles.
setNewPluginInfo()
trigger()Triggers an event.
updateCraftVersionInfo()Updates the Craft version info in the craft_info table.

getHasCraftVersionChanged()

Returns whether a different Craft version has been uploaded.

View source

Returns

boolean

Signature

public boolean getHasCraftVersionChanged ( )

getIsCraftDbMigrationNeeded()

Returns whether Craft needs to run any database migrations.

View source

Returns

boolean

Signature

public boolean getIsCraftDbMigrationNeeded ( )

getIsCraftSchemaVersionCompatible()

Returns whether the uploaded DB schema is equal to or greater than the installed schema.

View source

Returns

boolean

Signature

public boolean getIsCraftSchemaVersionCompatible ( )

getIsCriticalUpdateAvailable()

Returns whether a critical update is available.

View source

Arguments

  • $check (boolean) – Whether to check for updates if they aren't cached already

Returns

boolean

Signature

public boolean getIsCriticalUpdateAvailable ( \craft\services\bool $check = false )

getIsPluginDbUpdateNeeded()

Returns whether a plugin needs to run a database update.

View source

Returns

boolean

Signature

public boolean getIsPluginDbUpdateNeeded ( )

getIsUpdateInfoCached()

Returns whether the update info is cached.

View source

Returns

boolean

Signature

public boolean getIsUpdateInfoCached ( )

getPendingMigrationHandles()

Returns a list of things with updated schema versions. Craft CMS will be represented as "craft", plugins will be represented by their handles, and content will be represented as "content". See also runMigrations()View source

Arguments

  • $includeContent (boolean) – Whether pending content migrations should be considered

Returns

string[]

Signature

public string[] getPendingMigrationHandles ( $includeContent = false )

getTotalAvailableUpdates()

View source

Arguments

  • $check (boolean) – Whether to check for updates if they aren't cached already

Returns

integer

Signature

public integer getTotalAvailableUpdates ( \craft\services\bool $check = false )

getUpdates()

View source

Arguments

Returns

craft\models\Updates

Signature

public craft\models\Updates getUpdates ( \craft\services\bool $refresh = false )

getWasCraftBreakpointSkipped()

Returns true if the version stored in craft_info is less than the minimum required version on the file system. This This effectively makes sure that a user cannot manually update past a manual breakpoint.

View source

Returns

boolean

Signature

public boolean getWasCraftBreakpointSkipped ( )

runMigrations()

Runs the pending migrations for the given list of handles.

See also getPendingMigrationHandles()View source

Arguments

  • $handles (string[]) – The list of handles to run migrations for

Throws

Signature

public void runMigrations ( array $handles )

setNewPluginInfo()

Signature

public boolean setNewPluginInfo ( craft\base\PluginInterface $plugin )

updateCraftVersionInfo()

Updates the Craft version info in the craft_info table.

View source

Returns

boolean

Signature

public boolean updateCraftVersionInfo ( )