Jump to content

[SOLVED] overloading die()


bobbinsbro

Recommended Posts

hi every1

i have recently joined a project in full swing ( = there's a s**t load of written code). this project runs an install script that creates and initializes a new database, creates new users in the database users table and creates a settings file.

i've been helping debug this install process, and everytime the install fails, i have to go througha routine of DROPping users from the DB, DROPping the shcema and deleting the settings file.

1 of my assignments is to write rollback code, so that when an install fails, we won't have to keep reverting changes manually.

in most cases, on script error, the php die() function is called. it is called in a whole lot of places... i was wondering if there was a way to re-declare die() at the global scope with enhanced functionality (the functionality needed to revert the crashed install), so that i don't have to go through all the files in the project (over 700 files) and change every die() function the a custom uninstall() function.

please tell me there's a way to do this... it will probably be a temporary change (changing die is unsafe in the long term, i know), but it would make the debugging of the install so much more productive.

 

what i would like to do is something like this:

<?php
//in the global scope
function die($msg){
      //drop users from database users table
      //drop schema
      //unlink('settings_file');
      echo $msg;
      exit;
}
?>

 

if you think i'm coming at this problem from the wrong direction, please share your thoughts/recommendations/ideas. they are all welcome.

 

thanx in advance,

bobbinsbro

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.