Class JMS\DiExtraBundle\Config\FastDirectoriesResource contains 5 abstract methods #28

Open
cedriclombardot opened this Issue Jun 20, 2012 · 29 comments

Comments

Projects
None yet
@cedriclombardot

Hi,

Updating my deps i've this error :

Fatal error: Class JMS\DiExtraBundle\Config\FastDirectoriesResource contains 5 abstract methods and must therefore be declared abstract or implement the remaining methods (Symfony\Component\Config\Resource\ResourceInterface::getModificationTime, Symfony\Component\Config\Resource\ResourceInterface::exists, Symfony\Component\Config\Resource\ResourceInterface::getId, ...) in XXX/symfony/vendor/jms/di-extra-bundle/JMS/DiExtraBundle/Config/FastDirectoriesResource.php on line 78
@cedriclombardot

This comment has been minimized.

Show comment
Hide comment
@jonathaningram

This comment has been minimized.

Show comment
Hide comment
@jonathaningram

jonathaningram Jun 20, 2012

FYI @schmittjoh this occurs when updating, say, via Composer.

FYI @schmittjoh this occurs when updating, say, via Composer.

@luishdez

This comment has been minimized.

Show comment
Hide comment
@luishdez

luishdez Jun 21, 2012

Same problem in the assetic bundle symfony/AsseticBundle#85 , this is because

Symfony\Component\Config\Resource\ResourceInterface

has been updated recently.

Same problem in the assetic bundle symfony/AsseticBundle#85 , this is because

Symfony\Component\Config\Resource\ResourceInterface

has been updated recently.

@symfonyluxury

This comment has been minimized.

Show comment
Hide comment
@symfonyluxury

symfonyluxury Jun 21, 2012

so, how to resolve it? bundle maintainer?

so, how to resolve it? bundle maintainer?

@jonathaningram

This comment has been minimized.

Show comment
Hide comment
@jonathaningram

jonathaningram Jun 21, 2012

@symfonyluxury Until @schmittjoh can verify the fix, I have temporarily updated these two files (I think that they could be close to correct, but need confirmation from Johannes):

<?php

/*
 * Copyright 2011 Johannes M. Schmitt <schmittjoh@gmail.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace JMS\DiExtraBundle\Config;

use JMS\DiExtraBundle\Finder\PatternFinder;

use Symfony\Component\Config\Resource\ResourceInterface;

class FastDirectoriesResource implements ResourceInterface
{
    private $finder;

    private $directories;
    private $filePattern;
    private $files = array();

    public function __construct(array $directories, $filePattern = null)
    {
        $this->finder = new PatternFinder('.*', '*.php');
        $this->finder->setRegexPattern(true);

        $this->directories = $directories;
        $this->filePattern = $filePattern ?: '*';
    }

    public function __toString()
    {
        return implode(', ', $this->directories);
    }

    public function getResource()
    {
        return $this->directories;
    }

    public function update()
    {
        $this->files = $this->getFiles();
    }

    public function isFresh($timestamp)
    {
        $files = $this->getFiles();

        if (array_diff($this->files, $files) || array_diff($files, $this->files)) {
            return false;
        }

        foreach ($files as $file) {
            if (filemtime($file) > $timestamp) {
                return false;
            }
        }

        return true;
    }

    public function exists()
    {
        return true;
    }

    public function getId()
    {
        return md5('jms_di_extra'.$this->filePattern.$this->files);
    }

    public function getModificationTime()
    {
        return -1;
    }

    public function serialize()
    {
        $resourceMap = array(
            'filePattern' => $this->filePattern,
            'files'       => $this->files,
        );

        return serialize($resourceMap);
    }

    public function unserialize($serialized)
    {
        $resourceMap = unserialize($serialized);

        $this->filePattern = $resourceMap['filePattern'];
        $this->files = $resourceMap['files'];
    }

    private function getFiles()
    {
        return $this->finder->findFiles($this->directories);
    }
}
<?php

/*
 * Copyright 2011 Johannes M. Schmitt <schmittjoh@gmail.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace JMS\DiExtraBundle\Config;

use JMS\DiExtraBundle\Finder\PatternFinder;
use Symfony\Component\Config\Resource\ResourceInterface;

class ServiceFilesResource implements ResourceInterface
{
    private $files;
    private $dirs;

    public function __construct(array $files, array $dirs)
    {
        $this->files = $files;
        $this->dirs = $dirs;
    }

    public function isFresh($timestamp)
    {
        $finder = new PatternFinder('JMS\DiExtraBundle\Annotation');
        $files = $finder->findFiles($this->dirs);

        return !array_diff($files, $this->files) && !array_diff($this->files, $files);
    }

    public function __toString()
    {
        return implode(', ', $this->files);
    }

    public function getResource()
    {
        return array($this->files, $this->dirs);
    }

    public function exists()
    {
        return true;
    }

    public function getId()
    {
        return md5('jms_di_extra'.$this->files.$this->dirs);
    }

    public function getModificationTime()
    {
        return -1;
    }

    public function serialize()
    {
        $resourceMap = array(
            'files' => $this->files,
            'dirs'  => $this->dirs,
        );

        return serialize($resourceMap);
    }

    public function unserialize($serialized)
    {
        $resourceMap = unserialize($serialized);

        $this->files = $resourceMap['files'];
        $this->dirs = $resourceMap['dirs'];
    }
}

I know there's some things in there not correct, but it appears to be getting me through the day :)

@symfonyluxury Until @schmittjoh can verify the fix, I have temporarily updated these two files (I think that they could be close to correct, but need confirmation from Johannes):

<?php

/*
 * Copyright 2011 Johannes M. Schmitt <schmittjoh@gmail.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace JMS\DiExtraBundle\Config;

use JMS\DiExtraBundle\Finder\PatternFinder;

use Symfony\Component\Config\Resource\ResourceInterface;

class FastDirectoriesResource implements ResourceInterface
{
    private $finder;

    private $directories;
    private $filePattern;
    private $files = array();

    public function __construct(array $directories, $filePattern = null)
    {
        $this->finder = new PatternFinder('.*', '*.php');
        $this->finder->setRegexPattern(true);

        $this->directories = $directories;
        $this->filePattern = $filePattern ?: '*';
    }

    public function __toString()
    {
        return implode(', ', $this->directories);
    }

    public function getResource()
    {
        return $this->directories;
    }

    public function update()
    {
        $this->files = $this->getFiles();
    }

    public function isFresh($timestamp)
    {
        $files = $this->getFiles();

        if (array_diff($this->files, $files) || array_diff($files, $this->files)) {
            return false;
        }

        foreach ($files as $file) {
            if (filemtime($file) > $timestamp) {
                return false;
            }
        }

        return true;
    }

    public function exists()
    {
        return true;
    }

    public function getId()
    {
        return md5('jms_di_extra'.$this->filePattern.$this->files);
    }

    public function getModificationTime()
    {
        return -1;
    }

    public function serialize()
    {
        $resourceMap = array(
            'filePattern' => $this->filePattern,
            'files'       => $this->files,
        );

        return serialize($resourceMap);
    }

    public function unserialize($serialized)
    {
        $resourceMap = unserialize($serialized);

        $this->filePattern = $resourceMap['filePattern'];
        $this->files = $resourceMap['files'];
    }

    private function getFiles()
    {
        return $this->finder->findFiles($this->directories);
    }
}
<?php

/*
 * Copyright 2011 Johannes M. Schmitt <schmittjoh@gmail.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace JMS\DiExtraBundle\Config;

use JMS\DiExtraBundle\Finder\PatternFinder;
use Symfony\Component\Config\Resource\ResourceInterface;

class ServiceFilesResource implements ResourceInterface
{
    private $files;
    private $dirs;

    public function __construct(array $files, array $dirs)
    {
        $this->files = $files;
        $this->dirs = $dirs;
    }

    public function isFresh($timestamp)
    {
        $finder = new PatternFinder('JMS\DiExtraBundle\Annotation');
        $files = $finder->findFiles($this->dirs);

        return !array_diff($files, $this->files) && !array_diff($this->files, $files);
    }

    public function __toString()
    {
        return implode(', ', $this->files);
    }

    public function getResource()
    {
        return array($this->files, $this->dirs);
    }

    public function exists()
    {
        return true;
    }

    public function getId()
    {
        return md5('jms_di_extra'.$this->files.$this->dirs);
    }

    public function getModificationTime()
    {
        return -1;
    }

    public function serialize()
    {
        $resourceMap = array(
            'files' => $this->files,
            'dirs'  => $this->dirs,
        );

        return serialize($resourceMap);
    }

    public function unserialize($serialized)
    {
        $resourceMap = unserialize($serialized);

        $this->files = $resourceMap['files'];
        $this->dirs = $resourceMap['dirs'];
    }
}

I know there's some things in there not correct, but it appears to be getting me through the day :)

@symfonyluxury

This comment has been minimized.

Show comment
Hide comment
@symfonyluxury

symfonyluxury Jun 21, 2012

merci jonathaningram, you save me this day!!! This is nice for temporally work around <3

merci jonathaningram, you save me this day!!! This is nice for temporally work around <3

@marfillaster

This comment has been minimized.

Show comment
Hide comment
@marfillaster

marfillaster Jun 21, 2012

@jonathaningram can you create a fork so we can point a custom composer repository to yours while this is not yet fixed

@jonathaningram can you create a fork so we can point a custom composer repository to yours while this is not yet fixed

@jonathaningram

This comment has been minimized.

Show comment
Hide comment
@jonathaningram

jonathaningram Jun 21, 2012

@marfillaster I've just edited the files locally, but you should be able to create the fork yourself just as quick as I would :D - those are the only files you need to edit (I believe).

@marfillaster I've just edited the files locally, but you should be able to create the fork yourself just as quick as I would :D - those are the only files you need to edit (I believe).

@marfillaster

This comment has been minimized.

Show comment
Hide comment
@marfillaster

marfillaster Jun 21, 2012

@jonathaningram yeah, also thought of maintaining a temporary local copy of hot fixed repo.

@jonathaningram yeah, also thought of maintaining a temporary local copy of hot fixed repo.

@stof

This comment has been minimized.

Show comment
Hide comment
@stof

stof Jun 21, 2012

Contributor

@jonathaningram by creating a fork, you could send a PR to fix the classes in the bundle :)

Contributor

stof commented Jun 21, 2012

@jonathaningram by creating a fork, you could send a PR to fix the classes in the bundle :)

@jonathaningram

This comment has been minimized.

Show comment
Hide comment
@jonathaningram

jonathaningram Jun 21, 2012

@stof oh I didn't/don't mind doing the PR to try and fix it, but it's just that I wasn't entirely sure how the methods should be implemented, so I thought at the least pasting in the code would help with the PR process. I just assumed Johannes would have to create his own fork anyway if mine was wrong. And it's 5:30pm here now so I cannot stick around to go back and forth :)

On 21/06/2012, at 5:25 PM, Christophe Coevoet wrote:

@jonathaningram by creating a fork, you could send a PR to fix the classes in the bundle :)


Reply to this email directly or view it on GitHub:
#28 (comment)

@stof oh I didn't/don't mind doing the PR to try and fix it, but it's just that I wasn't entirely sure how the methods should be implemented, so I thought at the least pasting in the code would help with the PR process. I just assumed Johannes would have to create his own fork anyway if mine was wrong. And it's 5:30pm here now so I cannot stick around to go back and forth :)

On 21/06/2012, at 5:25 PM, Christophe Coevoet wrote:

@jonathaningram by creating a fork, you could send a PR to fix the classes in the bundle :)


Reply to this email directly or view it on GitHub:
#28 (comment)

@gajdaw

This comment has been minimized.

Show comment
Hide comment

gajdaw commented Jun 21, 2012

@jonathaningram thanks. Here is a branch that contains both files:

https://github.com/gajdaw/JMSDiExtraBundle/tree/issue_28_fix

@nicolas-bastien

This comment has been minimized.

Show comment
Hide comment
@nicolas-bastien

nicolas-bastien Jun 21, 2012

@gajdaw Hi so as stof sais, why you didn't make a PR if you already have done the job to correct this ?

@gajdaw Hi so as stof sais, why you didn't make a PR if you already have done the job to correct this ?

@stevelacey

This comment has been minimized.

Show comment
Hide comment
@stevelacey

stevelacey Jun 21, 2012

Using the fix I seem to be getting this when my cache is warm:

Notice: unserialize(): Error at offset 55 of 57 bytes in /vendor/symfony/symfony/src/Symfony/Component/Config/Resource/FileResource.php line 114

Is this related?

Using the fix I seem to be getting this when my cache is warm:

Notice: unserialize(): Error at offset 55 of 57 bytes in /vendor/symfony/symfony/src/Symfony/Component/Config/Resource/FileResource.php line 114

Is this related?

@aerialls aerialls referenced this issue in symfony/symfony-standard Jun 21, 2012

Closed

Fatal error runnning composer update #348

@stof

This comment has been minimized.

Show comment
Hide comment
@stof

stof Jun 21, 2012

Contributor

@stevelacey due to the serialization change, you need to remove your cache entirely after the upgrade

Contributor

stof commented Jun 21, 2012

@stevelacey due to the serialization change, you need to remove your cache entirely after the upgrade

@schmittjoh

This comment has been minimized.

Show comment
Hide comment
@schmittjoh

schmittjoh Jun 21, 2012

Owner

@jonathaningram, I think the finder is missing in the serialize method of the FastDirectoryResource, but otherwise looks good. Could you send a PR?

Owner

schmittjoh commented Jun 21, 2012

@jonathaningram, I think the finder is missing in the serialize method of the FastDirectoryResource, but otherwise looks good. Could you send a PR?

@stevelacey

This comment has been minimized.

Show comment
Hide comment
@stevelacey

stevelacey Jun 21, 2012

@stof if I remove the cache entirely the first cache-clear will succeed but then subsequent cache-clears and requests will fail with that error.

@stof if I remove the cache entirely the first cache-clear will succeed but then subsequent cache-clears and requests will fail with that error.

@francoispluchino francoispluchino referenced this issue in gajdaw/JMSDiExtraBundle Jun 21, 2012

Closed

Fix bug issue #28 #1

youbs added a commit to youbs/JMSDiExtraBundle that referenced this issue Jun 21, 2012

@stevelacey

This comment has been minimized.

Show comment
Hide comment
@stevelacey

stevelacey Jun 21, 2012

I'm still getting the same error, am I missing something or is the patch not quite there yet?

I'm still getting the same error, am I missing something or is the patch not quite there yet?

@stof

This comment has been minimized.

Show comment
Hide comment
@stof

stof Jun 21, 2012

Contributor

@stevelacey see the comment done by @schmittjoh

Contributor

stof commented Jun 21, 2012

@stevelacey see the comment done by @schmittjoh

@stevelacey

This comment has been minimized.

Show comment
Hide comment
@stevelacey

stevelacey Jun 21, 2012

@stof

"I think the finder is missing in the serialize method of the FastDirectoryResource, but otherwise looks good. Could you send a PR?"?

Looks to me that was fixed in @youbs' fork?

@stof

"I think the finder is missing in the serialize method of the FastDirectoryResource, but otherwise looks good. Could you send a PR?"?

Looks to me that was fixed in @youbs' fork?

@TomAdam

This comment has been minimized.

Show comment
Hide comment
@TomAdam

TomAdam Jun 21, 2012

I'm using @youbs' fork, and I get the same error as @stevelacey. Adding in thr finder had not fixed the problem. I have done a manual cache clear.

[ErrorException]                                                                                                    
Notice: unserialize(): Error at offset 47 of 49 bytes in /var/www/hcc/vendor/symfony/symfony/src/Symfony/Component/Config/Resource/FileResource.php line 114

TomAdam commented Jun 21, 2012

I'm using @youbs' fork, and I get the same error as @stevelacey. Adding in thr finder had not fixed the problem. I have done a manual cache clear.

[ErrorException]                                                                                                    
Notice: unserialize(): Error at offset 47 of 49 bytes in /var/www/hcc/vendor/symfony/symfony/src/Symfony/Component/Config/Resource/FileResource.php line 114
@youbs

This comment has been minimized.

Show comment
Hide comment
@youbs

youbs Jun 21, 2012

@TomAdam @stevelacey
I don't have this error, when do you get it exactly ? after clearing your cache ?

youbs commented Jun 21, 2012

@TomAdam @stevelacey
I don't have this error, when do you get it exactly ? after clearing your cache ?

@jonathaningram

This comment has been minimized.

Show comment
Hide comment
@jonathaningram

jonathaningram Jun 21, 2012

FYI thanks all for taking the PR off my hands - I was out all night hence why I didn't make the PR myself as I knew I would be unavailable to finish the fix. Night!

On 22/06/2012, at 12:37 AM, Hubert Moutotreply@reply.github.com wrote:

@TomAdam @stevelacey
I don't have this error, when do you get it exactly ? after clearing your cache ?


Reply to this email directly or view it on GitHub:
#28 (comment)

FYI thanks all for taking the PR off my hands - I was out all night hence why I didn't make the PR myself as I knew I would be unavailable to finish the fix. Night!

On 22/06/2012, at 12:37 AM, Hubert Moutotreply@reply.github.com wrote:

@TomAdam @stevelacey
I don't have this error, when do you get it exactly ? after clearing your cache ?


Reply to this email directly or view it on GitHub:
#28 (comment)

@stevelacey

This comment has been minimized.

Show comment
Hide comment
@stevelacey

stevelacey Jun 21, 2012

@youbs If I rm -rf my cache, then do a cache clear, no error, but subsequent requests and cache clears return error, so it's the warmed cache that's broken.

@youbs If I rm -rf my cache, then do a cache clear, no error, but subsequent requests and cache clears return error, so it's the warmed cache that's broken.

@TomAdam

This comment has been minimized.

Show comment
Hide comment
@TomAdam

TomAdam Jun 21, 2012

Same here. Cache builds fine if its empty, but fails to rebuild afterwards.

TomAdam commented Jun 21, 2012

Same here. Cache builds fine if its empty, but fails to rebuild afterwards.

@schmittjoh

This comment has been minimized.

Show comment
Hide comment
@schmittjoh

schmittjoh Jun 21, 2012

Owner

If you are talking about "cache clear", are you manually calling php app/console cache:clear, or does the error also occur on normal re-builds of the container in development?

Owner

schmittjoh commented Jun 21, 2012

If you are talking about "cache clear", are you manually calling php app/console cache:clear, or does the error also occur on normal re-builds of the container in development?

@stevelacey

This comment has been minimized.

Show comment
Hide comment
@stevelacey

stevelacey Jun 21, 2012

@schmittjoh I don't entirely understand the question (pretty new to version 2), but the error occurs on cache clears (after warmup), composer updates, when accessing the project in my browser and when just running app/console, in short, everywhere.

@schmittjoh I don't entirely understand the question (pretty new to version 2), but the error occurs on cache clears (after warmup), composer updates, when accessing the project in my browser and when just running app/console, in short, everywhere.

@TomAdam

This comment has been minimized.

Show comment
Hide comment
@TomAdam

TomAdam Jun 21, 2012

Well some good news! I no longer get the issue. Fabpot reverted the commit that caused this in the first place. See symfony/symfony@0d4b02e

TomAdam commented Jun 21, 2012

Well some good news! I no longer get the issue. Fabpot reverted the commit that caused this in the first place. See symfony/symfony@0d4b02e

@TomAdam

This comment has been minimized.

Show comment
Hide comment
@TomAdam

TomAdam Jun 21, 2012

Just to answer the question anyway, I noticed it any time the cache was rebuilt, so a cache:clear with a primed cache and a request after a change to a file in dev would both trigger it. You could get one request through if you wiped the cache manually.

TomAdam commented Jun 21, 2012

Just to answer the question anyway, I noticed it any time the cache was rebuilt, so a cache:clear with a primed cache and a request after a change to a file in dev would both trigger it. You could get one request through if you wiped the cache manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment