Index: bin/php/updatesearchindex.php
===================================================================
--- bin/php/updatesearchindex.php	(revision 22332)
+++ bin/php/updatesearchindex.php	(working copy)
@@ -94,7 +94,8 @@
 
 print( "Starting object re-indexing\n" );
 
-require_once( 'lib/ezutils/classes/ezexecution.php' );
+//require_once( 'lib/ezutils/classes/ezexecution.php' );
+eZExecution::registerShutdownHandler();
 require_once( "lib/ezutils/classes/ezdebug.php" );
 //include_once( "kernel/classes/ezsearch.php" );
 
Index: index.php
===================================================================
--- index.php	(revision 22332)
+++ index.php	(working copy)
@@ -189,9 +189,9 @@
 }
 
 // Needed by the error handler, since the current directory is lost when
-// the callback function eZExecutionUncleanShutdownHandler is called.
-$GLOBALS['eZDocumentRoot'] = dirname( __FILE__ );
-require_once( 'lib/ezutils/classes/ezexecution.php' );
+// the callback function eZExecution::uncleanShutdownHandler is called.
+eZExecution::registerShutdownHandler( dirname( __FILE__ ) );
+
 /*
     see:
     - http://www.php.net/manual/en/function.session-set-save-handler.php
Index: index_treemenu.php
===================================================================
--- index_treemenu.php	(revision 22332)
+++ index_treemenu.php	(working copy)
@@ -75,6 +75,7 @@
 ob_start();
 error_reporting ( E_ALL );
 
+eZExecution::registerShutdownHandler( dirname( __FILE__ ) );
 eZExecution::addFatalErrorHandler( 'eZFatalError' );
 eZDebug::setHandleType( eZDebug::HANDLE_FROM_PHP );
 
Index: kernel/classes/ezscript.php
===================================================================
--- kernel/classes/ezscript.php	(revision 22332)
+++ kernel/classes/ezscript.php	(working copy)
@@ -233,7 +233,8 @@
                                                  'dir_permission'  => octdec( $iniDirPermission ),
                                                  'var_directory'   => $iniVarDirectory ) );
 
-        require_once( 'lib/ezutils/classes/ezexecution.php' );
+        //require_once( 'lib/ezutils/classes/ezexecution.php' );
+        eZExecution::registerShutdownHandler();
 
         eZExecution::addCleanupHandler( 'eZDBCleanup' );
         eZExecution::addFatalErrorHandler( 'eZFatalError' );
@@ -309,7 +310,7 @@
                     $cli = eZCLI::instance();
                     if ( $this->isLoud() )
                         $cli->warning( 'Failed to login with user ' . $userLogin );
-                    require_once( 'lib/ezutils/classes/ezexecution.php' );
+                    //require_once( 'lib/ezutils/classes/ezexecution.php' );
                     eZExecution::cleanup();
                     eZExecution::setCleanExit();
                 }
Index: kernel/content/pdf.php
===================================================================
--- kernel/content/pdf.php	(revision 22332)
+++ kernel/content/pdf.php	(working copy)
@@ -276,7 +276,7 @@
     @fpassthru( $fp );
     fclose( $fp );
 
-    require_once( 'lib/ezutils/classes/ezexecution.php' );
+    //require_once( 'lib/ezutils/classes/ezexecution.php' );
     eZExecution::cleanExit();
 }
 
Index: kernel/pdf/edit.php
===================================================================
--- kernel/pdf/edit.php	(revision 22332)
+++ kernel/pdf/edit.php	(working copy)
@@ -41,7 +41,7 @@
     $pdfExport = eZPDFExport::fetch( $Params['PDFExportID'] );
     if ( $pdfExport && $pdfExport->attribute( 'status' ) == eZPDFExport::CREATE_ONFLY ) // only generate OnTheFly if status set correctly
     {
-        require_once( 'lib/ezutils/classes/ezexecution.php' );
+        //require_once( 'lib/ezutils/classes/ezexecution.php' );
         generatePDF( $pdfExport );
         eZExecution::cleanExit();
     }
Index: lib/ezdb/classes/ezdbinterface.php
===================================================================
--- lib/ezdb/classes/ezdbinterface.php	(revision 22332)
+++ lib/ezdb/classes/ezdbinterface.php	(working copy)
@@ -984,7 +984,7 @@
             $this->RecordError = $oldRecordError;
 
             // Stop execution immediately while allowing other systems (session etc.) to cleanup
-            require_once( 'lib/ezutils/classes/ezexecution.php' );
+            //require_once( 'lib/ezutils/classes/ezexecution.php' );
             eZExecution::cleanup();
             eZExecution::setCleanExit();
 
Index: lib/ezfile/classes/ezfile.php
===================================================================
--- lib/ezfile/classes/ezfile.php	(revision 22332)
+++ lib/ezfile/classes/ezfile.php	(working copy)
@@ -239,7 +239,7 @@
 
             @readfile( $file );
 
-            require_once( 'lib/ezutils/classes/ezexecution.php' );
+            //require_once( 'lib/ezutils/classes/ezexecution.php' );
             eZExecution::cleanExit();
         }
         else
Index: lib/ezpdf/classes/class.pdf.php
===================================================================
--- lib/ezpdf/classes/class.pdf.php	(revision 22332)
+++ lib/ezpdf/classes/class.pdf.php	(working copy)
@@ -2605,7 +2605,7 @@
 
         echo $tmp;
 
-        require_once( 'lib/ezutils/classes/ezexecution.php' );
+        //require_once( 'lib/ezutils/classes/ezexecution.php' );
         eZExecution::cleanExit();
     }
 
Index: lib/ezutils/classes/ezexecution.php
===================================================================
--- lib/ezutils/classes/ezexecution.php	(revision 22332)
+++ lib/ezutils/classes/ezexecution.php	(working copy)
@@ -50,7 +50,7 @@
     */
     static function setCleanExit()
     {
-        $GLOBALS['eZExecutionCleanExit'] = true;
+        self::$hasCleanExit = true;
     }
 
     /*!
@@ -74,19 +74,15 @@
     */
     static function addCleanupHandler( $handler )
     {
-        $handlers =& eZExecution::cleanupHandlers();
-        $handlers[] = $handler;
+        self::$cleanupHandlers[] = $handler;
     }
 
     /*!
      \return An array with cleanup handlers.
     */
-    static function &cleanupHandlers()
+    static function cleanupHandlers()
     {
-        $handlers =& $GLOBALS['eZExecutionCleanupHandlers'];
-        if ( !isset( $handlers ) )
-            $handlers = array();
-        return $handlers;
+        return self::$cleanupHandlers;
     }
 
     /*!
@@ -97,19 +93,15 @@
     */
     static function addFatalErrorHandler( $handler )
     {
-        $handlers =& eZExecution::fatalErrorHandlers();
-        $handlers[] = $handler;
+        self::$fatalErrorHandlers[] = $handler;
     }
 
     /*!
      \return An array with fatal error handlers.
     */
-    static function &fatalErrorHandlers()
+    static function fatalErrorHandlers()
     {
-        $handlers =& $GLOBALS['eZExecutionFatalErrorHandlers'];
-        if ( !isset( $handlers ) )
-            $handlers = array();
-        return $handlers;
+        return self::$fatalErrorHandlers;
     }
 
     /*!
@@ -117,7 +109,7 @@
     */
     static function isCleanExit()
     {
-        return $GLOBALS['eZExecutionCleanExit'];
+        return self::$hasCleanExit;
     }
 
     /*!
@@ -131,37 +123,52 @@
         exit;
     }
 
-}
+    /*!
+     Exit handler which called after the script is done, if it detects
+     that eZ Publish did not exit cleanly it will issue an error message
+     and display the debug.
+    */
+    static function uncleanShutdownHandler()
+    {
+        // Need to change the current directory, since this information is lost
+        // when the callbackfunction is called. eZDocumentRoot is set in ::registerShutdownHandler
+        if ( self::$eZDocumentRoot !== null )
+        {
+            chdir( self::$eZDocumentRoot );
+        }
 
-
-/*!
- Exit handler which called after the script is done, if it detects
- that eZ Publish did not exit cleanly it will issue an error message
- and display the debug.
-*/
-function eZExecutionUncleanShutdownHandler()
-{
-    // Need to change the current directory, since this information is lost
-    // when the callbackfunction is called. eZDocumentRoot is set in index.php.
-    if ( isset( $GLOBALS['eZDocumentRoot'] ) )
-    {
-        $documentRoot = $GLOBALS['eZDocumentRoot'];
-        chdir( $documentRoot );
+        if ( eZExecution::isCleanExit() )
+            return;
+        eZExecution::cleanup();
+        $handlers = eZExecution::fatalErrorHandlers();
+        foreach ( $handlers as $handler )
+        {
+            if ( function_exists( $handler ) )
+                $handler();
+        }
     }
 
-    if ( eZExecution::isCleanExit() )
-        return;
-    eZExecution::cleanup();
-    $handlers =& eZExecution::fatalErrorHandlers();
-    foreach ( $handlers as $handler )
+    /*!
+     Register ::uncleanShutdownHandler as shutdown function
+    */
+    static public function registerShutdownHandler( $documentRoot = false )
     {
-        if ( function_exists( $handler ) )
-            $handler();
+        if ( $documentRoot )
+        {
+            self::$eZDocumentRoot = $documentRoot;
+        }
+        if ( !self::$shutdownHandle )
+        {
+            register_shutdown_function( array('eZExecution', 'uncleanShutdownHandler') );
+            self::$shutdownHandle = true;
+        }
     }
-}
 
-register_shutdown_function( 'eZExecutionUncleanShutdownHandler' );
-
-$GLOBALS['eZExecutionCleanExit'] = false;
+    static private $eZDocumentRoot = null;
+    static private $hasCleanExit = false;
+    static private $shutdownHandle = false;
+    static private $fatalErrorHandlers = array();
+    static private $cleanupHandlers = array();
+}
 
-?>
+?>
\ No newline at end of file
Index: lib/ezutils/classes/ezhttptool.php
===================================================================
--- lib/ezutils/classes/ezhttptool.php	(revision 22332)
+++ lib/ezutils/classes/ezhttptool.php	(working copy)
@@ -360,7 +360,7 @@
             header( 'Content-Location: ' . $uri );
 
             fpassthru( $fp );
-            require_once( 'lib/ezutils/classes/ezexecution.php' );
+            //require_once( 'lib/ezutils/classes/ezexecution.php' );
             eZExecution::cleanExit();
         }
         else
Index: update/common/scripts/updatecontentobjectname.php
===================================================================
--- update/common/scripts/updatecontentobjectname.php	(revision 22332)
+++ update/common/scripts/updatecontentobjectname.php	(working copy)
@@ -287,7 +287,7 @@
 
 //include_once( "lib/ezutils/classes/ezmodule.php" );
 // eZModule::setGlobalPathList( array( "kernel" ) );
-require_once( 'lib/ezutils/classes/ezexecution.php' );
+eZExecution::registerShutdownHandler( );
 require_once( "lib/ezutils/classes/ezdebug.php" );
 
 //include_once( 'kernel/classes/ezcontentobjecttreenode.php' );
Index: webdav.php
===================================================================
--- webdav.php	(revision 22332)
+++ webdav.php	(working copy)
@@ -122,7 +122,7 @@
 // Check and proceed only if WebDAV functionality is enabled:
 if ( $enable === 'true' )
 {
-    require_once( 'lib/ezutils/classes/ezexecution.php' );
+    eZExecution::registerShutdownHandler( dirname( __FILE__ ) );
     eZExecution::addCleanupHandler( 'eZDBCleanup' );
     eZExecution::addFatalErrorHandler( 'eZFatalError' );
     eZDebug::setHandleType( eZDebug::HANDLE_FROM_PHP );
@@ -135,7 +135,6 @@
         eZExecution::cleanExit();
     }
     //include_once( "lib/ezutils/classes/ezmodule.php" );
-    require_once( 'lib/ezutils/classes/ezexecution.php' );
     require_once( "lib/ezutils/classes/ezsession.php" );
     require_once( "access.php" );
     require_once( "kernel/common/i18n.php" );
