Install items and handlers
This page is for developers who read or write the <install> part of a package, and for administrators who want to
know what an install will do to a site. It answers: what an install item is, which code runs it, and what each
handler changes.
Contents
- Install items
- How a handler is found
- The shipped handlers
- What happens to one item
- Conflicts: an item that meets something existing
- Handlers in the setup wizard and in ezpm
- The step installers of the administration
- Related pages
Install items
An install item is one <item> of the <install> list in package.xml:
<install>
<item type="ezcontentclass" filename="class-article" sub-directory="ezcontentclass"/>
<item type="ezcontentobject" filename="contentobjects" sub-directory="ezcontentobject"/>
<item type="ezextension" filename="extension-ezwebin" sub-directory="ezextension"/>
<item type="ezfile" collection="default"/>
</install>type names the handler. sub-directory and filename name the item's document,
<package>/<sub-directory>/<filename>.xml. The <uninstall> list has the same form. Items run in the order they are
listed; eZPackage::installUnaudited() skips an item whose type, filename and sub-directory repeat an earlier
one.
How a handler is found
eZPackage::packageHandler( $type ) looks the type up in settings/package.ini:
[PackageSettings]
HandlerAlias[ezcontentclass]=eZContentClassPackageHandler
HandlerAlias[ezcontentobject]=eZContentObjectPackageHandler
HandlerAlias[eziniaddon]=eZINIAddonPackageHandler
HandlerAlias[ezfile]=eZFilePackageHandler
HandlerAlias[ezini]=eZFilePackageHandler
HandlerAlias[ezdesign]=eZFilePackageHandler
HandlerAlias[eztemplate]=eZFilePackageHandler
HandlerAlias[ezthumbnail]=eZFilePackageHandler
HandlerAlias[ezsql]=eZDBPackageHandler
HandlerAlias[ezextension]=eZExtensionPackageHandler
HandlerAlias[ezinstallscript]=eZInstallScriptPackageHandlerThe class is created through eZExtension::getHandlerClass() and kept for the request. A type without an entry
has no handler: the install of that item fails with "No package handler found for install item type '...'". Because
this is an INI array, another handler can be registered with a further HandlerAlias[<type>]=<class> entry in an
override or an extension's package.ini.append.php; the class must extend eZPackageHandler
(kernel/classes/ezpackagehandler.php).
The shipped handlers
| Item type | Handler | Folder | Install | Uninstall |
|---|---|---|---|---|
ezcontentclass | eZContentClassPackageHandler | kernel/classes/packagehandlers/ezcontentclass/ | Creates the class from its document, with its attributes, in its class groups. An identifier that is taken gets _1, _2 ... | Removes the class matched by remote ID, after a confirmation when objects of it exist |
ezcontentobject | eZContentObjectPackageHandler | .../ezcontentobject/ | Creates the objects listed in contentobjects.xml (<object-files-list>, one object-<remote id>.xml each) below the top nodes, then installs templates, overrides and fetch aliases the document carries | Removes the objects |
ezextension | eZExtensionPackageHandler | .../ezextension/ | Copies <sub-directory>/<name>/ to extension/<name>/, regenerates the extension autoloads and adds the name to ActiveExtensions[] in settings/override/site.ini.append.php | Deletes extension/<name>/, removes it from ActiveExtensions[], regenerates the autoloads |
ezfile, ezini, ezdesign, eztemplate, ezthumbnail | eZFilePackageHandler | .../ezfile/ | Copies every file of the item's collection to its place: design/<design>/templates, images, stylesheets, fonts; settings/[override/][siteaccess/<name>/]; or a plain path. Thumbnails are not copied. INI files can get variables set | from 6.0.15 on: removes the files its install created and nobody changed since (see the note below) |
ezsql | eZDBPackageHandler | .../ezdb/ | Runs sql/[<database-type>/]<filename> through eZDB::insertFile(); with a database-type of another engine than the current one the file is not run and the item returns failure | nothing: SQL cannot be reversed; the item counts as not uninstalled |
eziniaddon | eZINIAddonPackageHandler | .../eziniaddon/ | Writes INI blocks of a siteaccess, turning remote IDs into the IDs of this site | nothing: the blocks stay; the item counts as not uninstalled |
ezinstallscript | eZInstallScriptPackageHandler | .../ezinstallscript/ | Nothing: returns success. The script is run by a step installer (below) | nothing |
The files differ in what they read: ezcontentclass, ezcontentobject, ezextension and eziniaddon read the
item's document before install() is called (extractInstallContent()), the others do not.
Note
Before 6.0.15, eZFilePackageHandler, eZDBPackageHandler and eZINIAddonPackageHandler had no uninstall()
of their own: the base method did nothing and returned no value, which eZPackage::uninstall() counted as an
item that did not uninstall, and files, SQL and INI changes stayed on the site. From 6.0.15 on:
eZFilePackageHandler::uninstall()removes a file only when its install created it (it did not exist before; the install remembers it in the install data asinstalled_files), its path is relative and inside the installation, its content is unchanged since, and that content is one of the package's own files. Everything else stays: a file the install replaced, a file the site changed, an INI file that got variables at install time, and the directories. A package installed before 6.0.15 has nothing remembered, so nothing is removed.eZDBPackageHandlerandeZINIAddonPackageHandlerhave anuninstall()that changes nothing and says why in the debug output: SQL cannot be reversed automatically, and INI blocks may hold the site's own values since. The item still counts as not uninstalled; remove those changes by hand.
What happens to one item
eZPackage::installItem() does this for every item:
- Find the handler; fail when there is none.
- When the handler extracts content, read
<sub-directory>/<filename>.xml(or its.jsontwin); fail when it cannot be read. - Open a database transaction.
- Call the handler's
install()with the package, the item and the install parameters. - Commit on success; roll back when the handler returns false, leaves the transaction invalid, or throws.
The whole package fails at the first failing item unless the install parameters say continue-on-error. A package
whose items all succeeded is recorded as installed in the ezpackage table (name, <number>-<release>, date). What
the handlers remember for the uninstall is kept as install data (<install-data>).
Conflicts: an item that meets something existing
Handlers report a conflict through $installParameters['error'] with a code, a description and the actions a person
may choose. The administration's install page shows them; the choice can be remembered for the rest of the run.
| Handler | Conflict | Actions offered |
|---|---|---|
ezcontentclass | A class with the same remote ID exists | Replace (with a warning about the objects that go with it), Update existing class (attributes added and updated, none removed), Skip, Keep existing and create a new one |
ezextension | extension/<name>/ exists | Replace extension, Skip |
ezextension | The name is not a valid extension name | none: the item fails |
With non-interactive set, nobody can answer, so a handler takes its non-interactive branch:
ezcontentclass skips a class that exists ("Non-interactive installs (e.g. CLI) must not destructively replace
existing classes"), while ezextension replaces an existing extension directory.
Handlers in the setup wizard and in ezpm
The Create sites step installs each required package with these parameters
(kernel/setup/steps/ezstep_create_sites.php):
array( 'use_dates_from_package' => true,
'site_access_map' => array( '*' => $userSiteaccessName ),
'top_nodes_map' => array( '*' => 2 ),
'design_map' => array( '*' => $userDesignName ),
'language_map' => $languageMap,
'restore_dates' => true,
'user_id' => $user->attribute( 'contentobject_id' ),
'non-interactive' => true );ezpm install uses the same kind of map with the siteaccess of the run and top node 2 (or the destination node
given), also non-interactive. Both therefore skip classes that exist and replace extensions that exist.
The step installers of the administration
Beside the handlers, settings/package.ini [InstallerSettings] names step installers for the administration's
install page:
[InstallerSettings]
HandlerList[]=ezcontentobject
HandlerList[]=ezinstallscript
HandlerAlias[ezcontentobject]=eZContentObjectPackageInstaller
HandlerAlias[ezinstallscript]=eZInstallScriptPackageInstaller
InstallBatchMaxItems=12
InstallBatchTimeBudgetSeconds=6They live in kernel/classes/packageinstallers/ and add pages to the install (for example, choosing where content
goes). InstallBatchMaxItems and InstallBatchTimeBudgetSeconds split a long install into batches; see
package installer batching.
Related pages
- Site package basics
- Site packages: start here
- package.xml reference
- Import versus install
- Installing and uninstalling
- Packages guide, 7. Installing and uninstalling
- Contribute your site package
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
Become an Exponential Partner
Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.