PHP Class Piwik\Updater

Afficher le fichier Open project: piwik/piwik Class Usage Examples

Méthodes publiques

Méthode Description
__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)

Private Methods

Méthode Description
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

Method Details

__construct() public méthode

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() public méthode

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

executeMigration() public méthode

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

executeMigrationQueries() public méthode

Deprecation: since Piwik 3.0.0, use {@link executeMigrations()} instead.
public executeMigrationQueries ( $file, $migrationQueries )

executeMigrations() public méthode

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() public méthode

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
Résultat string[] | null Returns the result of `getComponentsWithUpdateFile()`.

getComponentsWithNewVersion() public méthode

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')`
Résultat array array( componentName => array( oldVersion, newVersion), [...])

getComponentsWithUpdateFile() public méthode

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')`
Résultat array(

getCurrentComponentVersion() public méthode

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.
Résultat string A semantic version.

getSqlQueriesToExecute() public méthode

Returns the list of SQL queries that would be executed during the update
public getSqlQueriesToExecute ( ) : Sql[]
Résultat Piwik\Updater\Migration\Db\Sql[] of SQL queries

getUpdateClassName() public méthode

public getUpdateClassName ( $componentName, $fileVersion )

hasMajorDbUpdate() public méthode

Does one of the new versions involve a major database update? Note: getSqlQueriesToExecute() must be called before this method!
public hasMajorDbUpdate ( ) : boolean
Résultat boolean

hasNewVersion() public méthode

Component has a new version?
public hasNewVersion ( string $componentName ) : boolean
$componentName string
Résultat boolean TRUE if compoment is to be updated; FALSE if not

markComponentSuccessfullyUninstalled() public méthode

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() public méthode

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() public static méthode

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

update() public méthode

Update the named component
public update ( string $componentName ) : array
$componentName string 'core', or plugin name
Résultat array of warning strings if applicable

updateComponents() public méthode

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()`.
Résultat 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() public static méthode

Performs database update(s)
Deprecation:
public static updateDatabase ( string $file, array $sqlarray )
$file string Update script filename
$sqlarray array An array of SQL queries to be executed