Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Console shell mode cache issue with doctrine:fixtures:load #2847

Closed
OlivierCuyp opened this Issue · 13 comments

5 participants

@OlivierCuyp

Hi I'm quite new on Symfony.

I just wanted to notify a small issue I noticed trying the console shell mode (app/console -s).
Here is the story :

  • I made a mistake in my jobeet tutorial fixture file.
  • So I fixed it and reran doctrine:fixtures:load from the console shell.
  • The console answered me the same error (expiresAt cannot be NULL).
  • So I ran a cache:clear and again the same error.
  • Then i quite the console shell-mode (ctrl+d) and run on my linux shell : php app/console doctrine:fixtures:load.
  • And there it worked without any issue ...

So I might have missed something in the documentation but the behavior seems strange to me.

PS: I have setup the ACL on the logs and cache folders as recommended in the documentation

@fabpot
Owner

In the shell, there is no way to reload already loaded PHP files, so the cache:clear command has no effect on these classes. That's a limitation of the shell and why it worked on the CLI directly.

@fabpot fabpot closed this
@stof
Collaborator

cache:clear cannot be used properly in the shell as the shell will keep old classes in memory (it is the same PHP process).

@OlivierCuyp

Right, it makes sense.
Thanks for the fast reaction.
I'm not sure if this is present in the documentation but if not, it would be nice to have a small note on this.

@Seldaek

Wouldn't it be better if the shell ran all commands through Process instead of using the same process? It's not the first time someone runs into this issue.

@fabpot
Owner

@Seldaek: I will investigate that possibility.

@stof
Collaborator

@fabpot another solution could be to throw an exception in cache:clear if it is launched from the shell (it may be easier than using Process which gave as many headaches). Not sure if the application can tell us it is wrapped in a shell though

@OlivierCuyp

@stof correct me if I'm wrong but more than the cache issue, since all the classes are already loaded whatever I change in my code I won't see the result when running Symfony shell commands, right ?

@stof
Collaborator

if you change the classes, indeed.

@trompette

Instead of using the Process class, maybe leveraging the runkit extension could be an alternative.

@trompette

BTW, @stof idea to throw an exception is good.

Going further, an interface ShellIncompatible could be introduced to handle those scenarios :

  • an application not wrapped in a shell can run all registered commands.
  • an application wrapped in a shell can unregister commands implementing the interface.

Comments?

@Seldaek

That doesn't work, everything is potentially "shell incompatible". If you touch code while it's in memory, it doesn't update. Simple as that. The shell should not be used for stuff that is in development IMO, unless it's fixed using external processes.

@trompette

I'm thinking of another use case: a command that launch the built-in shell should not be available in this shell to prevent "inception".

@OlivierCuyp

@Seldaek If the shell mode shouldn't be used in development, it makes it a bit useless since you won't use it in production (i guess) ?
It's a bit sad shell mode is a really nice feature (I love the autocomplete).

@canni canni referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@canni canni referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@canni canni referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@canni canni referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@canni canni referenced this issue from a commit
@canni canni [Console] Enable process isolantion in Shell
Bug fix: no
BC break: no
Feature addition: yes
Symfony2 test pass: yes
Fixes the following tickets: #2848 #2847
Todo: -

See tickets for reference, need help with testing, because I don't know how to test this :)
e9b4c58
@fabpot fabpot referenced this issue from a commit
@fabpot fabpot merged branch canni/command_in_process (PR #2894)
Commits
-------

e9b4c58 [Console] Enable process isolantion in Shell

Discussion
----------

[Console] Enable process isolantion in Shell

Bug fix: no
BC break: no
Feature addition: yes
Symfony2 test pass: yes
Fixes the following tickets: #2848 #2847
Todo: Write unit tests

See tickets for reference, need help with unit testing, because I don't know how to test this :)

---------------------------------------------------------------------------

by canni at 2011-12-16T09:36:32Z

I've tested this with different scenarios like "inception" (invoking shell from shell - will not work) ;) and others, everything seems to work great.

As I have no idea on how to pack this with unit testing some help needed, also as I don't have any windows in home ;) need someone to test it on MS os.
And we should decide, do we want process isolation by default? (This will not break the BC, break only the "expected behavior" - colorful output and "interactivity")

---------------------------------------------------------------------------

by canni at 2011-12-18T15:14:26Z

I've rebased this branch to match current `HEAD` and I've added usage of new process builder, for better portability an shell arg escaping.

---------------------------------------------------------------------------

by fabpot at 2012-02-02T08:28:32Z

@canni: Can you squash your commits before I merge this PR? Thanks.

---------------------------------------------------------------------------

by canni at 2012-02-02T09:07:16Z

@fabpot @stof done.
687703d
@vicb vicb referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@mmucklo mmucklo referenced this issue from a commit
@canni canni [Console] Enable process isolantion in Shell
Bug fix: no
BC break: no
Feature addition: yes
Symfony2 test pass: yes
Fixes the following tickets: #2848 #2847
Todo: -

See tickets for reference, need help with testing, because I don't know how to test this :)
f993d6f
@mmucklo mmucklo referenced this issue from a commit
@fabpot fabpot merged branch canni/command_in_process (PR #2894)
Commits
-------

e9b4c58 [Console] Enable process isolantion in Shell

Discussion
----------

[Console] Enable process isolantion in Shell

Bug fix: no
BC break: no
Feature addition: yes
Symfony2 test pass: yes
Fixes the following tickets: #2848 #2847
Todo: Write unit tests

See tickets for reference, need help with unit testing, because I don't know how to test this :)

---------------------------------------------------------------------------

by canni at 2011-12-16T09:36:32Z

I've tested this with different scenarios like "inception" (invoking shell from shell - will not work) ;) and others, everything seems to work great.

As I have no idea on how to pack this with unit testing some help needed, also as I don't have any windows in home ;) need someone to test it on MS os.
And we should decide, do we want process isolation by default? (This will not break the BC, break only the "expected behavior" - colorful output and "interactivity")

---------------------------------------------------------------------------

by canni at 2011-12-18T15:14:26Z

I've rebased this branch to match current `HEAD` and I've added usage of new process builder, for better portability an shell arg escaping.

---------------------------------------------------------------------------

by fabpot at 2012-02-02T08:28:32Z

@canni: Can you squash your commits before I merge this PR? Thanks.

---------------------------------------------------------------------------

by canni at 2012-02-02T09:07:16Z

@fabpot @stof done.
a697285
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.