Skip to content

Updates

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

Updates service.

An instance of the service is available via Craft::$app->updates.

View source

Public Properties

PropertyDescription
areMigrationsPendingboolean
behaviorsyii\base\Behavior – List of behaviors attached to this component.
cacheKeystring
hasCraftVersionChangedboolean
isCraftDbMigrationNeededboolean – Whether Craft needs to run any database migrations
isCraftSchemaVersionCompatibleboolean – Whether the uploaded DB schema is equal to or greater than the installed schema
isCraftUpdatePendingboolean
isCriticalUpdateAvailableboolean – Whether a critical update is available
isPluginDbUpdateNeededboolean – Whether a plugin needs to run a database update
isPluginUpdatePendingboolean
isUpdateInfoCachedboolean – Whether the update info is cached
isUpdatePendingboolean
newPluginInfocraft\base\PluginInterface
pendingMigrationHandlesstring[]
totalAvailableUpdatesinteger
updatescraft\models\Updates
wasCraftBreakpointSkippedboolean – Whether the build stored in craft_info is less than the minimum required build on the file system

areMigrationsPending

Type
boolean
Default value
null
Access
Read-only
Since
3.5.15

View source

cacheKey

Type
string
Default value
'updates'

View source

hasCraftVersionChanged

Type
boolean
Default value
null
Access
Read-only

View source

isCraftDbMigrationNeeded

Type
boolean
Default value
null

Whether Craft needs to run any database migrations

View source

isCraftSchemaVersionCompatible

Type
boolean
Default value
null

Whether the uploaded DB schema is equal to or greater than the installed schema

View source

isCraftUpdatePending

Type
boolean
Default value
null
Access
Read-only
Since
4.0.0

View source

isCriticalUpdateAvailable

Type
boolean
Default value
null

Whether a critical update is available

View source

isPluginDbUpdateNeeded

Type
boolean
Default value
null

Whether a plugin needs to run a database update

View source

isPluginUpdatePending

Type
boolean
Default value
null
Access
Read-only
Since
4.0.0

View source

isUpdateInfoCached

Type
boolean
Default value
null

Whether the update info is cached

View source

isUpdatePending

Type
boolean
Default value
null
Access
Read-only
Since
3.6.15

View source

newPluginInfo

Type
craft\base\PluginInterface
Default value
null
Access
Write-only

View source

pendingMigrationHandles

Type
string[]
Default value
null
Access
Read-only

View source

totalAvailableUpdates

Type
integer
Default value
null
Access
Read-only

View source

updates

Type
craft\models\Updates
Default value
null
Access
Read-only

View source

wasCraftBreakpointSkipped

Type
boolean
Default value
null

Whether the build stored in craft_info is less than the minimum required build on the file system

View source

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 a component property.
__isset()Checks if a property is set, i.e. defined and not null.
__set()Sets the value of a component property.
__unset()Sets a component property to be 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.
cacheUpdates()Caches new update info.
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.
getAreMigrationsPending()Returns whether there are any pending migrations.
getBehavior()Returns the named behavior object.
getBehaviors()Returns all behaviors attached to this component.
getHasCraftVersionChanged()Returns whether a different Craft version has been uploaded.
getIsCraftSchemaVersionCompatible()Returns whether the uploaded DB schema is equal to or greater than the installed schema.
getIsCraftUpdatePending()Returns whether Craft needs to run any database migrations.
getIsCriticalUpdateAvailable()Returns whether a critical update is available.
getIsPluginUpdatePending()Returns whether a plugin needs to run a database update.
getIsUpdateInfoCached()Returns whether the update info is cached.
getIsUpdatePending()Returns whether any Craft or plugin updates are pending.
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.
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 for this component.
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.

cacheUpdates()

Since
3.3.16

Caches new update info.

View source

Arguments

Returns

craft\models\Updates

getAreMigrationsPending()

Since
3.5.15

Returns whether there are any pending migrations.

View source

Arguments

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

Returns

boolean

getHasCraftVersionChanged()

Returns whether a different Craft version has been uploaded.

View source

Returns

boolean

getIsCraftSchemaVersionCompatible()

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

View source

Returns

boolean

getIsCraftUpdatePending()

Since
4.0.0

Returns whether Craft needs to run any database migrations.

View source

Returns

boolean

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

getIsPluginUpdatePending()

Since
4.0.0

Returns whether a plugin needs to run a database update.

View source

Returns

boolean

getIsUpdateInfoCached()

Returns whether the update info is cached.

View source

Returns

boolean

getIsUpdatePending()

Since
3.6.15

Returns whether any Craft or plugin updates are pending.

View source

Returns

boolean

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[]

getTotalAvailableUpdates()

View source

Arguments

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

Returns

integer

getUpdates()

View source

Arguments

Returns

craft\models\Updates

getWasCraftBreakpointSkipped()

Returns true if the version stored in craft_info is less than the minimum required version on the file system.

This effectively makes sure that a user cannot manually update past a manual breakpoint.

View source

Returns

boolean

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

setNewPluginInfo()

DEPRECATED

Deprecated in 3.7.13. Use craft\services\Plugins::updatePluginVersionInfo() instead.

View source

Arguments

Returns

boolean

updateCraftVersionInfo()

Updates the Craft version info in the craft_info table.

View source

Returns

boolean