PHP Class Piwik\Updater

显示文件 Open project: piwik/piwik Class Usage Examples

Public Methods

Method 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

Method 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 method

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 method

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

executeMigration() public method

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

executeMigrationQueries() public method

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

executeMigrations() public method

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 method

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

getComponentsWithNewVersion() public method

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

getComponentsWithUpdateFile() public method

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')`
return array(

getCurrentComponentVersion() public method

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.
return string A semantic version.

getSqlQueriesToExecute() public method

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

getUpdateClassName() public method

public getUpdateClassName ( $componentName, $fileVersion )

hasMajorDbUpdate() public method

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

hasNewVersion() public method

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

markComponentSuccessfullyUninstalled() public method

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 method

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 method

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

update() public method

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

updateComponents() public method

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()`.
return 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 method

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