PHP Класс Piwik\Updater

Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__construct ( string | null $pathUpdateFileCore = null, string | null $pathUpdateFilePlugins = null, Updater $columnsUpdater = null ) Constructor.
addUpdateObserver ( UpdateObserver $listener ) Adds an UpdateObserver to the internal list of listeners.
executeMigration ( $file, Migration $migration )
executeMigrationQueries ( $file, $migrationQueries )
executeMigrations ( string $file, Migration[] $migrations ) Execute multiple migration queries from a single Update file.
getComponentUpdates ( ) : string[] | null Returns any updates that should occur for core and all plugins that are both loaded and installed. Also includes updates required for dimensions.
getComponentsWithNewVersion ( string[] $componentsToCheck ) : array Construct list of outdated components
getComponentsWithUpdateFile ( string[] $componentsToCheck ) : array( Returns a list of components (core | plugin) that need to run through the upgrade process.
getCurrentComponentVersion ( string $name ) : string Returns the currently installed version of a Piwik component.
getSqlQueriesToExecute ( ) : Sql[] Returns the list of SQL queries that would be executed during the update
getUpdateClassName ( $componentName, $fileVersion )
hasMajorDbUpdate ( ) : boolean Does one of the new versions involve a major database update? Note: getSqlQueriesToExecute() must be called before this method!
hasNewVersion ( string $componentName ) : boolean Component has a new version?
markComponentSuccessfullyUninstalled ( string $name ) Marks a component as successfully uninstalled. Deletes an option that looks like "version_$componentName".
markComponentSuccessfullyUpdated ( string $name, string $version, boolean $isNew = false ) Marks a component as successfully updated to a specific version in the database. Sets an option that looks like "version_$componentName".
recordComponentSuccessfullyUpdated ( string $name, string $version ) Record version of successfully completed component update
update ( string $componentName ) : array Update the named component
updateComponents ( string[] $componentsWithUpdateFile ) : array Updates multiple components, while capturing & returning errors and warnings.
updateDatabase ( string $file, array $sqlarray ) Performs database update(s)

Приватные методы

Метод Описание
executeListenerHook ( $hookName, $arguments )
executeSingleUpdateClass ( $className )
getNameInOptionTable ( string $name ) : string Returns the flag name to use in the option table to record current schema version
keepBcForOldMigrationQueryFormat ( $index, $migration )
loadComponentsWithUpdateFile ( ) : array( Construct list of update files for the outdated components

Описание методов

__construct() публичный Метод

Constructor.
public __construct ( string | null $pathUpdateFileCore = null, string | null $pathUpdateFilePlugins = null, Updater $columnsUpdater = null )
$pathUpdateFileCore string | null The path to core Update files.
$pathUpdateFilePlugins string | null The path to plugin update files. Should contain a `'%s'` placeholder for the plugin name.
$columnsUpdater Piwik\Columns\Updater The dimensions updater instance.

addUpdateObserver() публичный Метод

Adds an UpdateObserver to the internal list of listeners.
public addUpdateObserver ( UpdateObserver $listener )
$listener Piwik\Updater\UpdateObserver

executeMigration() публичный Метод

public executeMigration ( $file, Migration $migration )
$file
$migration Piwik\Updater\Migration

executeMigrationQueries() публичный Метод

Устаревший: since Piwik 3.0.0, use {@link executeMigrations()} instead.
public executeMigrationQueries ( $file, $migrationQueries )

executeMigrations() публичный Метод

Execute multiple migration queries from a single Update file.
public executeMigrations ( string $file, Migration[] $migrations )
$file string The path to the Updates file.
$migrations Piwik\Updater\Migration[] An array of migrations

getComponentUpdates() публичный Метод

Returns any updates that should occur for core and all plugins that are both loaded and installed. Also includes updates required for dimensions.
public getComponentUpdates ( ) : string[] | null
Результат string[] | null Returns the result of `getComponentsWithUpdateFile()`.

getComponentsWithNewVersion() публичный Метод

Construct list of outdated components
public getComponentsWithNewVersion ( string[] $componentsToCheck ) : array
$componentsToCheck string[] An array mapping component names to the latest locally available version. If the version is later than the currently installed version, the component must be upgraded. Example: `array('core' => '2.11.0')`
Результат array array( componentName => array( oldVersion, newVersion), [...])

getComponentsWithUpdateFile() публичный Метод

Returns a list of components (core | plugin) that need to run through the upgrade process.
public getComponentsWithUpdateFile ( string[] $componentsToCheck ) : array(
$componentsToCheck string[] An array mapping component names to the latest locally available version. If the version is later than the currently installed version, the component must be upgraded. Example: `array('core' => '2.11.0')`
Результат array(

getCurrentComponentVersion() публичный Метод

Returns the currently installed version of a Piwik component.
public getCurrentComponentVersion ( string $name ) : string
$name string The component name. Eg, a plugin name, `'core'` or dimension column name.
Результат string A semantic version.

getSqlQueriesToExecute() публичный Метод

Returns the list of SQL queries that would be executed during the update
public getSqlQueriesToExecute ( ) : Sql[]
Результат Piwik\Updater\Migration\Db\Sql[] of SQL queries

getUpdateClassName() публичный Метод

public getUpdateClassName ( $componentName, $fileVersion )

hasMajorDbUpdate() публичный Метод

Does one of the new versions involve a major database update? Note: getSqlQueriesToExecute() must be called before this method!
public hasMajorDbUpdate ( ) : boolean
Результат boolean

hasNewVersion() публичный Метод

Component has a new version?
public hasNewVersion ( string $componentName ) : boolean
$componentName string
Результат boolean TRUE if compoment is to be updated; FALSE if not

markComponentSuccessfullyUninstalled() публичный Метод

Marks a component as successfully uninstalled. Deletes an option that looks like "version_$componentName".
public markComponentSuccessfullyUninstalled ( string $name )
$name string The component name. Eg, a plugin name, `'core'` or dimension column name.

markComponentSuccessfullyUpdated() публичный Метод

Marks a component as successfully updated to a specific version in the database. Sets an option that looks like "version_$componentName".
public markComponentSuccessfullyUpdated ( string $name, string $version, boolean $isNew = false )
$name string The component name. Eg, a plugin name, `'core'` or dimension column name.
$version string The component version (should use semantic versioning).
$isNew boolean indicates if the component is a new one (for plugins)

recordComponentSuccessfullyUpdated() публичный статический Метод

Record version of successfully completed component update
public static recordComponentSuccessfullyUpdated ( string $name, string $version )
$name string
$version string

update() публичный Метод

Update the named component
public update ( string $componentName ) : array
$componentName string 'core', or plugin name
Результат array of warning strings if applicable

updateComponents() публичный Метод

Updates multiple components, while capturing & returning errors and warnings.
public updateComponents ( string[] $componentsWithUpdateFile ) : array
$componentsWithUpdateFile string[] Component names mapped with arrays of update files. Same structure as the result of `getComponentsWithUpdateFile()`.
Результат array Information about the update process, including: * **warnings**: The list of warnings that occurred during the update process. * **errors**: The list of updater exceptions thrown during individual component updates. * **coreError**: True if an exception was thrown while updating core. * **deactivatedPlugins**: The list of plugins that were deactivated due to an error in the update process.

updateDatabase() публичный статический Метод

Performs database update(s)
Устаревший:
public static updateDatabase ( string $file, array $sqlarray )
$file string Update script filename
$sqlarray array An array of SQL queries to be executed