Skip to content
Snippets Groups Projects
Unverified Commit cf3f6a38 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3088403 by Mile23, Mixologic: Defensive coding: Vendor hardening plugin...

Issue #3088403 by Mile23, Mixologic: Defensive coding: Vendor hardening plugin sometimes receives AliasPackage

(cherry picked from commit 3072f841)
parent 79c71077
No related branches found
No related tags found
9 merge requests!1445Issue #2920039: Views' User Name exposed group filter validation,!1298Issue #3240993: Let layout builder render inline block translations,!774Issue #3174569: Example node template file name is incorrect,!497Issue #2463967: Use .user.ini file for PHP settings,!433Resolve #3163663 "Too many open files",!233Resolve #2693787 "Taxonomy term name",!133Resolve #2666286 "Clean up menuui",!112Resolve #3187004 "Drupaldatetime serialization issue",!53Resolve #3181870: Correct typo "the the" in "core/classList" deprecation message.
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
use Composer\Installer\PackageEvent; use Composer\Installer\PackageEvent;
use Composer\Installer\PackageEvents; use Composer\Installer\PackageEvents;
use Composer\IO\IOInterface; use Composer\IO\IOInterface;
use Composer\Package\CompletePackage; use Composer\Package\BasePackage;
use Composer\Plugin\PluginInterface; use Composer\Plugin\PluginInterface;
use Composer\Script\Event; use Composer\Script\Event;
use Composer\Script\ScriptEvents; use Composer\Script\ScriptEvents;
...@@ -150,13 +150,21 @@ public function onPostPackageUpdate(PackageEvent $event) { ...@@ -150,13 +150,21 @@ public function onPostPackageUpdate(PackageEvent $event) {
* Where the configured bin files are in the directories to be removed, remove * Where the configured bin files are in the directories to be removed, remove
* the bin config. * the bin config.
* *
* @param \Composer\Package\CompletePackage $package * @param \Composer\Package\BasePackage $package
* The package we're cleaning up. * The package we're cleaning up.
*/ */
protected function removeBinBeforeCleanup(CompletePackage $package) { protected function removeBinBeforeCleanup(BasePackage $package) {
// Only do this if there are binaries and cleanup paths. // We can process AliasPackage and Package objects, and they share the
// BasePackage parent class. However, since there is no common interface for
// these package types that allow for the setBinaries() method, and since
// BasePackage does not include the setBinaries() method, we have to make
// sure we're processing a class with a setBinaries() method.
if (!method_exists($package, 'setBinaries')) {
return;
}
$binaries = $package->getBinaries(); $binaries = $package->getBinaries();
$clean_paths = $this->config->getPathsForPackage($package->getName()); $clean_paths = $this->config->getPathsForPackage($package->getName());
// Only do this if there are binaries and cleanup paths.
if (!$binaries || !$clean_paths) { if (!$binaries || !$clean_paths) {
return; return;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment