Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

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