Skip to content
This repository has been archived by the owner on Apr 4, 2019. It is now read-only.

Skip bootstrap.php.cache/classes cache in debug mode #85

Merged
merged 1 commit into from
Apr 7, 2014

Conversation

bdunogier
Copy link
Member

http://jira.ez.no/browse/https://jira.ez.no/browse/EZP-22590

bootstrap.php.cache and classes cache can really get in the way with interactive debugging sessions.

This changes the front controller so that when debugging, if the \ XDEBUG_SESSION` cookie is set, the cache files above won't be loaded, so that the actual, original files can be stepped through.

Points to sort out

  • What about other debugging methods / extensions ? Different cookie ? We skip cache in debug mode, no debugger condition
  • Does it cover all scenarios (command line / web). Yep, no conditions on cookie.
  • Create story, if acceptable

$useDebugging = $environment === "dev";
}

$isInteractiveDebugging = !$useDebugging ? false : isset( $_COOKIE['XDEBUG_SESSION'] );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find the use of ternary operator a bit confusing.
I'd do :

$isInteractiveDebugging = false;
if ( $useDebugging && isset( $_COOKIE['XDEBUG_SESSION'] ) )
{
    $isInteractiveDebugging = true;
    $loader = require_once __DIR__ . '/../ezpublish/autoload.php';
}
else
{
    $loader = require_once __DIR__ . '/../ezpublish/bootstrap.php.cache';
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

especially combined with negation in the predicate ;-)

on a more serious note: is this opening the door a bit to DOS attacks?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had the same concern, but it is activated only if you are using ez in dev mode.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't accept concerns, I accept use-cases.

More seriously, no, not that I can think of. Nothing changes unless you're either in the dev env, or have the USE_DEBUGGING env var set. Even if you open the dev env to a large audience for some reason, it won't enable remote debugging or anything, nor open up your ports. It just won't use bootrap.php.cache nor classes cache, and this will decrease performances.

But it still requires access to the dev env, which is something you don't have to fear DDOS attacks on.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lolautruche your syntax makes sense, I'll try.

@lolautruche
Copy link
Contributor

+1 besides my nitpick.

Very useful.

@yannickroger
Copy link
Contributor

+1

@bdunogier
Copy link
Member Author

@lolautruche is the logic okay with you now ?

@gggeek was my answer satisfying to you ?

@gggeek
Copy link
Contributor

gggeek commented Dec 5, 2013

Absolutely. It seems I had missed the 'it only works in dev mode' bit - exactly for the reason I was complaining about: I got the code wrong! ;-D

@lolautruche
Copy link
Contributor

yes, perfect!

@andrerom
Copy link
Contributor

andrerom commented Dec 5, 2013

+0.1 There are some slightly crude things in here like hardcoding xdebug cookies(as also reflected in the task list), and also I know @lsmith77 has been involved in similar discussion on symfony-standard so would be nice to hear his take on this topic.

@lsmith77
Copy link

lsmith77 commented Dec 5, 2013

i fought and lost symfony/symfony-standard#437

@bdunogier
Copy link
Member Author

Well, after reading the battle report, it doesn't have to end the same way in this time & space :-)

Those cookies are standard and well defined, and there is no security hit. From a SWOT perspective, no weaknesses and no threats, but clear Opportunities from a developer experience perspective.

We must also take care to make it clear that the front controller is one of the files that SHOULD be modified. It's kinda of the whole point here... we can and should provide a really good, out of the box one, that will let people use our software decently before they start taking it apart.

And about XDEBUG_COOKIE, it isn't even configurable on xdebug.

@andrerom
Copy link
Contributor

andrerom commented Dec 5, 2013

And about XDEBUG_COOKIE, it isn't even configurable on xdebug.

No, point was more on the line that maybe we should just skip cache when in debug no matter which cookies are present or not, cleaner.

You should consider benchmarking this btw, might have a direct impact on APC when includes are conditional instead.

@lolautruche
Copy link
Contributor

Good point

@bdunogier
Copy link
Member Author

I could agree with this alternative. There is no real point in using cached files during dev, they'll just require extra time to be built anyway.

Is that fine by everybody ? Ditch the $_COOKIE test, and skip caching if $useDebugging == true ?

@bdunogier
Copy link
Member Author

Are you guys fine with the latest version of the patch ?

@bdunogier
Copy link
Member Author

@andrerom ?

@andrerom
Copy link
Contributor

andrerom commented Dec 6, 2013

yes, only thing would be to benchmark it with a apache restart in between to wipe apc cache.

@bdunogier
Copy link
Member Author

Hmm, is something actually missing or not ?

@andrerom
Copy link
Contributor

Well mentioned a few times; benchmark to make sure there is no negative impact on prod would be good.

@bdunogier
Copy link
Member Author

Benchmark the index in prod with & without the newly added checks, right ?

@lolautruche
Copy link
Contributor

Yes 👍

@bchoquet-heliopsis
Copy link

+10 : debugging is a bummer with classes cache

@andrerom
Copy link
Contributor

andrerom commented Apr 2, 2014

+1

@lolautruche
Copy link
Contributor

Let's merge this @bdunogier !

bootstrap.php.cache and classes cache can really
get in the way with interactive debugging sessions.

This changes the front controller so that when debugging,
real classes are used instead of caches.
bdunogier added a commit that referenced this pull request Apr 7, 2014
Skip bootstrap.php.cache/classes cache in debug mode
@bdunogier bdunogier merged commit 1304eff into master Apr 7, 2014
@bdunogier bdunogier deleted the improvement/interactive_debugging branch April 7, 2014 16:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

7 participants