Home » PEAR » PEAR » Bug #10261
Transaction handling fails to halt/rollback on certain errors
Details
| Submitted | 2007-03-04 11:35 UTC |
|---|---|
| From | timj at php dot net |
| Assigned | cellog |
| Status | Closed |
| Package | PEAR |
| PHP Version | 5.1.6 |
| Roadmaps | 1.5.2 |
Comments
[2007-03-04 11:35 UTC] timj at php dot net
Description:
------------
The PEAR transaction handler fails to halt/roll back on some critical errors.
Consider package X, which requires package Y. If I do "pear install X", and the installation of "Y" fails then I would expect PEAR to roll back the whole transaction and not to continue installing X. Instead, for some types of installation errors, PEAR will report X as being correctly installed even though it's required dependency Y failed to install.
A 100% reproducible test scenario is available.
Test script:
---------------
This test script reproduces the described scenario, where by way of illustration, "X" is DB_ldap and "Y" is DB. However, there is nothing special about these particular packages; they just happen to be a simple and convenient example.
Start with a clean PEAR install. Assume that 1.7.9 is the latest version of PEAR::DB. We manually force an error such that the place where PEAR expects to download DB-1.7.9.tgz to is unwriteable. (For those not familiar with UNIX, the below creates an unwriteable empty file called "DB-1.7.9.tgz" in the PEAR download directory)
$ pear config-get download_dir
/path/to/download
$ touch /path/to/download/DB-1.7.9.tgz
$ chmod 000 /path/to/download/DB-1.7.9.tgz
$ pear install --onlyreqdeps DB_ldap
Expected result:
----------------
Once PEAR realises that it is not possible to install a dependency of DB_ldap, it should abort the whole transaction and NOT proceed to install DB_ldap with missing dependencies.
Actual result:
--------------
pear/DB_ldap: Skipping required dependency "pear/PEAR", is already installed
downloading DB_ldap-1.1.1.tgz ...
Starting to download DB_ldap-1.1.1.tgz (7,950 bytes)
.....done: 7,950 bytes
downloading DB-1.7.9.tgz ...
Could not download from "http://pear.php.net/get/DB-1.7.9.tgz", cannot download "pear/DB" (could not open /path/to/download/DB-1.7.9.tgz for writing)
Error: cannot download "pear/DB"
+ create dir /path/to/pear/DB
about to commit 4 file operations
successfully committed 4 file operations
install ok: channel://pear.php.net/DB_ldap-1.1.1
[tim@langesund pear2]$ pear -c pearrc list
Installed packages, channel pear.php.net:
=========================================
Package Version State
Archive_Tar 1.3.2 stable
Console_Getopt 1.2.2 stable
DB_ldap 1.1.1 stable
PEAR 1.5.0 stable
Structures_Graph 1.0.2 stable
Note how DB_ldap has been installed *without* its required dependency DB! The transaction should have been aborted and rolled back at the point where PEAR reported "Error: cannot download "pear/DB"".