Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezclusterfilehandler.php
Go to the documentation of this file.
1 <?php
10 class eZClusterFileHandler
11 {
21 static function instance( $filename = false )
22 {
23 if ( self::$isShutdownFunctionRegistered !== true )
24 {
25 eZExecution::addCleanupHandler( array( __CLASS__, 'cleanupGeneratingFiles' ) );
26 self::$isShutdownFunctionRegistered = true;
27 }
28
29 if( $filename !== false )
30 {
31 $optionArray = array( 'iniFile' => 'file.ini',
32 'iniSection' => 'ClusteringSettings',
33 'iniVariable' => 'FileHandler',
34 'handlerParams'=> array( $filename ) );
35
36 $options = new ezpExtensionOptions( $optionArray );
37
38 $handler = eZExtension::getHandlerClass( $options );
39
40 return $handler;
41 }
42 else
43 {
44 // return Filehandler from GLOBALS based on ini setting.
45 if ( self::$globalHandler === null )
46 {
47 $optionArray = array( 'iniFile' => 'file.ini',
48 'iniSection' => 'ClusteringSettings',
49 'iniVariable' => 'FileHandler' );
50
51 $options = new ezpExtensionOptions( $optionArray );
52
53 $handler = eZExtension::getHandlerClass( $options );
54
55 self::$globalHandler = $handler;
56 }
57 else
58 $handler = self::$globalHandler;
59
60 return $handler;
61 }
62 }
63
67 public static function resetHandler()
68 {
69 self::cleanupGeneratingFiles();
70 self::$globalHandler = null;
71 }
72
77 static function cleanupGeneratingFiles()
78 {
79 if ( count( self::$generatingFiles ) === 0 )
80 {
81 return false;
82 }
83 else
84 {
85 eZDebug::writeWarning( "Execution was stopped while one or more files were generating. This should not happen.", __METHOD__ );
86 foreach( self::$generatingFiles as $generatingFile )
87 {
88 $generatingFile->abortCacheGeneration();
89 self::removeGeneratingFile( $generatingFile );
90 }
91 return true;
92 }
93 }
94
102 public static function cleanupEmptyDirectories( $path )
103 {
104 $dirpath = eZDir::dirpath( $path );
105
106 eZDebugSetting::writeDebug( 'kernel-clustering', "eZClusterFileHandler::cleanupEmptyDirectories( '{$dirpath}' )" );
107
108 if ( is_dir( $dirpath ) )
109 {
110 eZDir::cleanupEmptyDirectories( $dirpath );
111 }
112 }
113
121 public static function addGeneratingFile( $file )
122 {
123 if ( !( $file instanceof eZDFSFileHandler ) )
124 return false; // @todo Exception
125
126 self::$generatingFiles[$file->filePath] = $file;
127 }
128
137 public static function removeGeneratingFile( $file )
138 {
139 if ( !( $file instanceof eZDFSFileHandler ) )
140 return false; // @todo Exception
141
142 if ( isset( self::$generatingFiles[$file->filePath] ) )
143 unset( self::$generatingFiles[$file->filePath] );
144 }
145
151 public static function preFork()
152 {
153 $clusterHandler = self::instance();
154
155 // disconnect DB based cluster handlers from the database
156 if ( $clusterHandler instanceof ezpDatabaseBasedClusterFileHandler )
157 {
158 $clusterHandler->disconnect();
159
160 // destroy the current handler so that it reconnects when instanciated again
161 self::$globalHandler = null;
162 }
163 }
164
169 private static $generatingFiles = array();
170
175 private static $isShutdownFunctionRegistered = false;
176
181 public static $globalHandler;
182 }
183
184 ?>
eZClusterFileHandler
Definition: ezclusterfilehandler.php:11
eZClusterFileHandler\$isShutdownFunctionRegistered
static $isShutdownFunctionRegistered
Definition: ezclusterfilehandler.php:175
eZClusterFileHandler\$globalHandler
static $globalHandler
Definition: ezclusterfilehandler.php:181
eZClusterFileHandler\addGeneratingFile
static addGeneratingFile( $file)
Definition: ezclusterfilehandler.php:121
eZClusterFileHandler\resetHandler
static resetHandler()
Definition: ezclusterfilehandler.php:67
eZClusterFileHandler\$generatingFiles
static $generatingFiles
Definition: ezclusterfilehandler.php:169
eZClusterFileHandler\cleanupGeneratingFiles
static cleanupGeneratingFiles()
Definition: ezclusterfilehandler.php:77
eZClusterFileHandler\removeGeneratingFile
static removeGeneratingFile( $file)
Definition: ezclusterfilehandler.php:137
eZClusterFileHandler\cleanupEmptyDirectories
static cleanupEmptyDirectories( $path)
Definition: ezclusterfilehandler.php:102
eZClusterFileHandler\instance
static instance( $filename=false)
Definition: ezclusterfilehandler.php:21
eZClusterFileHandler\preFork
static preFork()
Definition: ezclusterfilehandler.php:151
eZDebugSetting\writeDebug
static writeDebug( $conditionName, $string, $label="")
Definition: ezdebugsetting.php:127
eZDebug\writeWarning
static writeWarning( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:502
eZDir\dirpath
static dirpath( $filepath)
Definition: ezdir.php:129
eZDir\cleanupEmptyDirectories
static cleanupEmptyDirectories( $dir)
Definition: ezdir.php:95
eZExecution\addCleanupHandler
static addCleanupHandler( $handler)
Definition: ezexecution.php:54
eZExtension\getHandlerClass
static getHandlerClass(ezpExtensionOptions $options)
Definition: ezextension.php:531
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.