-
Notifications
You must be signed in to change notification settings - Fork 6
Fixes composer installation errors due to problematic configuration files #5
Fixes composer installation errors due to problematic configuration files #5
Conversation
…iles If a module configuration file contains elements that depend on autoloading and/or elements that are clearly not configuration, calling `include` on it can lead to failure to complete a composer installation/removal action. This patch modifies the logic to tokenize the configuration file and look for problematic elements; when encountered, the (un)installer will skip including that configuration file, and instead emit a warning.
.travis.yml
Outdated
@@ -47,18 +48,22 @@ matrix: | |||
- php: hhvm | |||
|
|||
before_install: | |||
- if [[ $TRAVIS_PHP_VERSION != "hhvm" && $TEST_COVERAGE != 'true' ]]; then phpenv config-rm xdebug.ini ; fi | |||
- if [[ $TEST_COVERAGE != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi | |||
- travis_retry composer self-update |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is redundant. Travis update composer automatically, please see:
https://travis-ci.org/zfcampus/zf-asset-manager/jobs/296348988#L473
https://travis-ci.org/zfcampus/zf-asset-manager/jobs/296348988#L478
…_manager configuration If a configuration file does not contain `asset_manager` configuration, we do not need to do anything with it in the first place, and do not need to emit warnings. If the file contains any class pseudo-constant usage (e.g. `AssetInstallerFactory::class`), we do not need to flag the file as unusable, as PHP will resolve these regardless of autoloading. As such, we'll only have issues with class constants, static members, and cases where we are calling `new` or extending or implementing classes or interfaces.
src/UnparseableTokensTrait.php
Outdated
]; | ||
|
||
/** | ||
* @var string $packageConfigPath |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@param
instead of @var
src/UnparseableTokensTrait.php
Outdated
} | ||
|
||
/** | ||
* @var string $packageConfigPath |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above, @param
instead of @var
…dumping Per conversations with @Xerkus, this patch modifies the `Plugin` class to create closures around each install, uninstall, and update event in order to delay their execution until the `post-autoload-dump` event executes. What that event executes, it will: - loop through all uninstall closures and execute them. - loop through all install closures and execute them. This approach should solve autoloading issues (e.g., when resolving class constants).
Uninstall operations should not suffer the same autoloading issues, as the autoloader will already be in place. However, if they run during post-autoload-dump, they _will_ have issues. As such, this commit modifies the logic to run uninstall operations immediately, instead of memoizing them to run later.
src/Plugin.php
Outdated
} | ||
|
||
/** | ||
* Updates assets provided by the package, if any. | ||
* | ||
* Uninstalls any previously installed assets for the package, and then | ||
* runs an install for the package. | ||
* memoizes an install operation to run post-autoload-dump. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No typo: read about memoization on wikipedia. 😄
src/UnparseableTokensTrait.php
Outdated
} | ||
|
||
// ::class notation is okay | ||
if ($token[0] === T_DOUBLE_COLON |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this check is no longer needed
src/UnparseableTokensTrait.php
Outdated
* @param string|array Token to test as a class pseudoconstant | ||
* @return bool | ||
*/ | ||
private function isClassPseudoConstant($token) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, no longer needed
Moves the uninstall operations originally in the post-package-update hook to a pre-package-update hook. This should autoloading stays the same (in cases where classes, class constants, config files, etc. disappear).
Prevents deprecation notices.
Forward port #5 Conflicts: CHANGELOG.md
If a module configuration file contains elements that depend on autoloading and/or elements that are clearly not configuration, calling
include
on it can lead to failure to complete a composer installation/removal action.This patch modifies the logic as follows:
asset_manager
configuration, it is skipped.exec()
andeval()
calls; these raise warnings by the installer if detected.Plugin
class now aggregates install operations as closures around the relevant events, and executes these during apost-autoload-dump
plugin hook; this fixes autoloading issues. Uninstall operations still occur immediately as the relevant uninstall and update events.Fixes #4