Skip to content

Commit

Permalink
bug #23213 Fixed composer resources between web/cli (iltar)
Browse files Browse the repository at this point in the history
This PR was merged into the 3.3 branch.

Discussion
----------

Fixed composer resources between web/cli

| Q             | A
| ------------- | ---
| Branch?       | 3.3
| Bug fix?      | yes
| New feature?  | no (reverts one)
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #23212
| License       | MIT
| Doc PR        | ~

This is a possible fix for the flawed module check for the composer resource. As this is the easiest fix, I've created a PR ready to be merged.

Commits
-------

9e04712 Fixed composer resources between web/cli
  • Loading branch information
fabpot committed Jun 16, 2017
2 parents 1d304d2 + 9e04712 commit 772ab3d
Showing 1 changed file with 2 additions and 18 deletions.
20 changes: 2 additions & 18 deletions src/Symfony/Component/Config/Resource/ComposerResource.php
Expand Up @@ -18,16 +18,13 @@
*/
class ComposerResource implements SelfCheckingResourceInterface, \Serializable
{
private $versions;
private $vendors;

private static $runtimeVersion;
private static $runtimeVendors;

public function __construct()
{
self::refresh();
$this->versions = self::$runtimeVersion;
$this->vendors = self::$runtimeVendors;
}

Expand All @@ -51,36 +48,23 @@ public function isFresh($timestamp)
{
self::refresh();

if (self::$runtimeVersion !== $this->versions) {
return false;
}

return self::$runtimeVendors === $this->vendors;
}

public function serialize()
{
return serialize(array($this->versions, $this->vendors));
return serialize($this->vendors);
}

public function unserialize($serialized)
{
list($this->versions, $this->vendors) = unserialize($serialized);
$this->vendors = unserialize($serialized);
}

private static function refresh()
{
if (null !== self::$runtimeVersion) {
return;
}

self::$runtimeVersion = array();
self::$runtimeVendors = array();

foreach (get_loaded_extensions() as $ext) {
self::$runtimeVersion[$ext] = phpversion($ext);
}

foreach (get_declared_classes() as $class) {
if ('C' === $class[0] && 0 === strpos($class, 'ComposerAutoloaderInit')) {
$r = new \ReflectionClass($class);
Expand Down

0 comments on commit 772ab3d

Please sign in to comment.