NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Auto-removing debugbreaks on svn commit


Joined: 10 Sep 2013
Posts: 9
Reply with quote
Hi.
In our project it had often happened that someone debugged the code on the local PC and then forgets to remove calls to debugbreak() when committing files to the repository and so we got problems on the staging server (luckily not in production). Quick googling didn't get me any ready-to-go solutions. So I wrote a tiny simple script that can be used as pre-commit hook for TortoiseSVN and whose only task is to remove the calls to debugbreak. Maybe it'll be useful for someone else, so I'm putting it on github - https:/ /github.com/ruslanbes/remove-debugbreaks (remove space between / / )

P.S. Alternative solution is to write somewhere in your application's bootstrap files:
Code:
if (! function_exists('debugbreak') ) {
function debugbreak() {}
 }

but I prefer to have clean code in the svn.


Last edited by ruslanbes on Fri Oct 11, 2013 6:14 am; edited 1 time in total
View user's profileFind all posts by ruslanbesSend private message
Veteran

Joined: 15 Nov 2003
Posts: 118
Reply with quote
I thought if the debugger is not running (no debug session cookie set), debugBreak is ignored? So on a live server, it should do nothing?
View user's profileFind all posts by joebSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
if debugger is not installed on your life server, debugbreak() function _is_ not available and therefore each call to debugbreak will raise error in php.

What ruslanbes suggests is correct -- it's safe to define your own debugbreak if function is not defined, or wrap each call with similar check.
BTW did you try regular breakpoints & initiate debugger from the IDE or from the browser's debugger toolbar?
In this case you'd not need debugbreak at all.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 10 Sep 2013
Posts: 9
Reply with quote
Wrapping each call has the primary downside that when another dev checkouts your code and suddenly gets a debug-stop it could be really annoying. )
And sometimes it's hard to use other methods (like in iframe or in the middle of the chain of redirects)
View user's profileFind all posts by ruslanbesSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
ruslanbes wrote:
Wrapping each call

why each? Can you add your own wrapper function and call it instead of debugbreak?

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
Auto-removing debugbreaks on svn commit
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic