yohang / Finite

A Simple PHP Finite State Machine
http://yohan.giarel.li/Finite
MIT License
1.31k stars 188 forks source link

Finite don't work on Linux box #67

Closed ppavlovic closed 8 years ago

ppavlovic commented 10 years ago

It does work on my windows development machine (php version 5.4.27) but it doesn't work on linux test or production server with php 5.4.33 The error I'm getting is: request.CRITICAL: Uncaught PHP Exception Symfony\Component\OptionsResolver\Exception\InvalidOptionsException: "The option "disabled" does not exist. Known options are: "exclude_from", "exclude_to", "from", "on", "to"" at /var/www/vhosts/xxxxxxx.local/httpdocs/vendor/symfony/symfony/src/Symfony/Component/OptionsResolver/OptionsResolver.php line 255 {"exception":"[object](Symfony\Component\OptionsResolver\Exception\InvalidOptionsException: The option "disabled" does not exist. Known options are: "exclude_from", "exclude_to", "from", "on", "to" at /var/www/vhosts/xxxxxxx.local/httpdocs/vendor/symfony/symfony/src/Symfony/Component/OptionsResolver/OptionsResolver.php:255)"

state-machine.yml is

    callbacks:
      after:
        callback1:
          do:
            [@xxxxxxx_finite.transition_events, transitionEverytimeAfter]
hacfi commented 10 years ago

@ppavlovic That doesn’t look like the part of the config which has an error because disabled doesn’t appear in it.

ppavlovic commented 10 years ago

Yes, I know it isn't in yml config, but it defaults it to false as set in https://github.com/yohang/Finite/blob/master/src/Finite/Bundle/FiniteBundle/DependencyInjection/Configuration.php#L104 (line 104) and the OptionsResolver is "confused" by that part. Anyhow, if I set explicitly disabled in my yml, it also generates an error.

hacfi commented 10 years ago

@ppavlovic Oh..ok. I’m gonna quickly check that. If I come up with a solution I’ll create PR.

hacfi commented 10 years ago

@ppavlovic Try if adding

            ->addDefaultsIfNotSet()

to https://github.com/yohang/Finite/blob/master/src/Finite/Bundle/FiniteBundle/DependencyInjection/Configuration.php#L98 before ->children() fixes the issue.

ppavlovic commented 10 years ago

@hacfi , Thank you for the quick fix, I haven't got the time to look at it earlier. Sorry, that fix didn't helped me. What helped is adding 'disabled' => false after line 43 at https://github.com/yohang/Finite/blob/master/src/Finite/Event/CallbackHandler.php#L43

Also the line 104 at https://github.com/yohang/Finite/blob/master/src/Finite/Bundle/FiniteBundle/DependencyInjection/Configuration.php#L104 should look like

->booleanNode('disabled')->defaultFalse()->end()

although I'm not sure about defaultFalse() because it's more or less redudant after the above change is set (in CallbackHandler.php#L43)

yohang commented 9 years ago

It'll be fixed in the CallbackHandler refactoring : #51

ppavlovic commented 9 years ago

Nice!