PhileCMS / Phile

A flat file CMS with a swappable parser and template engine.
https://philecms.github.io/
Other
256 stars 48 forks source link

Fatal error: Cannot use Phile\Core\Event as Event... #243

Closed bricebou closed 9 years ago

bricebou commented 9 years ago

Hi,

I've worked on a little website locally (on a Xubuntu up to date) without any difficulties.

But I've just tried to put this project online on a new shared hosting at OVH and I have this error

Fatal error: Cannot use Phile\Core\Event as Event because the name is already in use in /home/leffetcozy/www/lib/Phile/Core.php on line 7

when I try to activate any plugin. I didn't have this issue on my local installation.

On this shared hosting, I've activated php 5.5 (here is the phpinfo : http://leffetcoleoptere.bz/phpinfo.php).

Any idea how I can make it work ?

Thanks.

bricebou commented 9 years ago

Hi again,

I found out it was the "call" to events in plugins that was causing this bug. It's quite strange to have different behaviors between local installation and the one on my shared hosting.

I have an issue rewriting this kind of "call" to events for the phileTags plugin (https://github.com/pschmitt/phileTags).

I've tried to do this (inspired by this fixed issue with another plugin : https://github.com/infostreams/snippets/issues/2):

public function __construct() {
        if (!class_exists('\Phile\Core\Event')) {
            // Phile < 1.5 => register event
            \Phile\Event::registerEvent('config_loaded', $this);
            \Phile\Event::registerEvent('before_render_template', $this);
            \Phile\Event::registerEvent('after_read_file_meta', $this);
            \Phile\Event::registerEvent('request_uri', $this);
            $this->config = \Phile\Registry::get('Phile_Settings');

            // init
            $this->tag_separator = ',';
            $this->tag_template = 'tag';
        }
    }

but I can't figure a way to pass all these events to something like that:

protected $events = ['before_parse_content' => 'on']; // Register event (Phile >= 1.5)

Thanks for your help.

Schlaefer commented 9 years ago

I'm not sure about the difference local vs webserver, but can you make sure that both run the latest version 1.5.2. The issue triggering this was introduced in 1.5.0 and should be patched since 1.5.1.

bricebou commented 9 years ago

Thanks ! After upgrading to Phile 1.5.2, this issue is no longer an issue... :)

I'm closing this issue but I have a "side" question: I've installed Phile using composer as it is explained in the documentation:

composer create-project --no-dev phile-cms/phile

but running a composer update doesn't update Phile. I've tried to specify composer update phile-cms/phile but I have this message:

Package "phile-cms/phile" listed for update is not installed. Ignoring.

How can I upgrade Phile using composer ?

Thanks again.

Schlaefer commented 9 years ago

Thanks ! After upgrading to Phile 1.5.2, this issue is no longer an issue... :)

Great. :)

How can I upgrade Phile using composer ?

I'm afraid you can't update Phile through composer at the moment. With create-package composer checks-out a package and installs all its dependencies. After that composer can update those dependencies, but not the package itself.

For an update to work the "Phile core" would have to be a dependency in a "Phile boilerplate site" package. That's the reason for the error message you saw: Phile is currently not installed as dependency composer can update.

There is #133 which points in that direction, but it hasn't caught on yet.

bricebou commented 9 years ago

Thanks a lot for these precisions.