Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
eZDFSFileHandler Class Reference
Inheritance diagram for eZDFSFileHandler:

## Public Member Functions
| __construct ( $filePath=false)
| disconnect ()
| loadMetaData ( $force=false)
| fileStore ( $filePath, $scope=false, $delete=false, $datatype=false)
| fileStoreContents ( $filePath, $contents, $scope=false, $datatype=false)
| storeContents ( $contents, $scope=false, $datatype=false, $storeLocally=false)
| fileFetch ( $filePath)
| fetchUnique ()
| fetch ( $noLocalCache=false)
| fileFetchContents ( $filePath)
| fetchContents ()
| processCache ( $retrieveCallback, $generateCallback=null, $ttl=null, $expiry=null, $extraData=null)
| isExpired ( $expiry, $curtime, $ttl)
| isLocalFileExpired ( $expiry, $curtime, $ttl)
| isDBFileExpired ( $expiry, $curtime, $ttl)
| storeCache ( $fileData)
| processFile ( $callback, $expiry=false, $extraData=null)
| stat ()
| size ()
| dataType ()
| mtime ()
| name ()
| fileDeleteByWildcard ( $wildcard)
| fileDeleteByDirList ( $dirList, $commonPath, $commonSuffix)
| fileDelete ( $path, $fnamePart=false)
| delete ()
| fileDeleteLocal ( $path)
| deleteLocal ()
| purge ( $printCallback=false, $microsleep=false, $max=false, $expiry=false)
| fileExists ( $path, $checkDFSFile=false)
| exists ( $checkDFSFile=false)
| passthrough ( $startOffset=0, $length=false)
| fileCopy ( $srcPath, $dstPath)
| fileLinkCopy ( $srcPath, $dstPath, $symLink)
| fileMove ( $srcPath, $dstPath)
| move ( $dstPath)
| getFileList ( $scopes=false, $excludeScopes=false, $limit=false, $path=false)
| startCacheGeneration ()
| endCacheGeneration ( $rename=true)
| abortCacheGeneration ()
| checkCacheGenerationTimeout ()
| __get ( $propertyName)
| requiresClusterizing ()
| requiresPurge ()
| fetchExpiredItems ( $scopes, $limit=array(0, 100), $expiry=false)
| hasStaleCacheSupport ()
| applyServerUri ( $filePath)
Public Member Functions inherited from eZClusterFileHandlerInterface
| fileExists ( $path)
| exists ()
| passthrough ()
| getFileList ( $scopes=false, $excludeScopes=false)

## Static Public Member Functions
static | isFileExpired ( $fname, $mtime, $expiry, $curtime, $ttl)
static | cleanPath ( $path)

## Public Attributes
const | LOCAL_CACHE = 1
const | INFOCACHE_MAX = 200
| $filePath = null

## Protected Member Functions
| _cacheType ()

## Protected Attributes
| $realFilePath = null
| $useStaleCache = false
| $remainingCacheGenerationTime = false
| $generationStartTimestamp = false
| $_metaData = null
| $_cacheType = null

## Static Protected Attributes
static | $dbbackend = null
static | $nonExistantStaleCacheHandling = null

## Detailed Description

Handles file operations for Distributed File Systems (f.e. NFS)

Uses a dual DB / FS approach:

- files metadata are DB based
- files data are read/written to a local mount point (outside var/)
- actual files are locally written, exactly like the DB handler does

Glossary of terms used in the internal doc:

- DFS: Distributed File System. Local NFS mount point
- DB: MetaData database
- LFS: Local file system (var)

Since
  4.2.0

Definition at line 27 of file ezdfsfilehandler.php.

## Constructor & Destructor Documentation

## ◆ __construct()

eZDFSFileHandler::__construct | ( |  | $filePath = `false` | ) |

Constructor

If provided with $filePath, will use this file for further operations. If not given, the file* methods must be used instead

Parameters

  string | $filePath | Path of the file to handle

Exceptions

  eZDBNoConnectionException | DB connection failed

Definition at line 53 of file ezdfsfilehandler.php.

References $filePath, cleanPath(), eZExtension\getHandlerClass(), and eZDebugSetting\writeDebug().

## Member Function Documentation

## ◆ __get()

eZDFSFileHandler::__get | ( |  | $propertyName | ) |

Magic getter

Definition at line 1396 of file ezdfsfilehandler.php.

References $_cacheType, $_metaData, _cacheType(), and loadMetaData().

## ◆ _cacheType()

eZDFSFileHandler::_cacheType | ( |  | ) |
| protected

Determines the cache type based on the current file's path

Returns
  string viewcache, cacheblock or misc

Definition at line 1383 of file ezdfsfilehandler.php.

Referenced by __get().

## ◆ abortCacheGeneration()

eZDFSFileHandler::abortCacheGeneration | ( |  | ) |

Aborts the current cache generation process.

Does so by rolling back the current transaction, which should be the .generating file lock

Implements eZClusterFileHandlerInterface.

Definition at line 1359 of file ezdfsfilehandler.php.

References $realFilePath, eZClusterFileHandler\removeGeneratingFile(), and eZDebugSetting\writeDebug().

Referenced by storeCache().

## ◆ applyServerUri()

eZDFSFileHandler::applyServerUri | ( |  | $filePath | ) |

Transforms $filePath so that it contains a valid href to the file, wherever it is stored.

Parameters

  string | $filePath | Example: /var/site/storage/images/example.png

Returns
  string http://static.example.com/var/site/storage/images/example.png

Implements eZClusterFileHandlerInterface.

Definition at line 1464 of file ezdfsfilehandler.php.

References $filePath.

## ◆ checkCacheGenerationTimeout()

eZDFSFileHandler::checkCacheGenerationTimeout | ( |  | ) |

Checks if the .generating file was changed, which would mean that generation timed out. If not timed out, refreshes the timestamp so that storage won't be stolen

Implements eZClusterFileHandlerInterface.

Definition at line 1373 of file ezdfsfilehandler.php.

References eZDebugSetting\writeDebug().

Referenced by storeCache().

## ◆ cleanPath()

static eZDFSFileHandler::cleanPath | ( |  | $path | ) |
| static

Returns a clean version of input $path.

- Backslashes are turned into slashes.
- Multiple consecutive slashes are turned into one slash.
- Ending slashes are removed.

Examples:

- my\windows\path => my/windows/path
- extra//slashes/\are/fixed => extra/slashes/are/fixed
- ending/slashes/ => ending/slashes

Todo:
  -ceZDFSFileHandler write unit test

Returns
  string cleaned up $path

Definition at line 1273 of file ezdfsfilehandler.php.

Referenced by __construct(), fileCopy(), fileDelete(), fileDeleteByDirList(), fileDeleteByWildcard(), fileExists(), fileFetch(), fileFetchContents(), fileLinkCopy(), fileMove(), fileStore(), fileStoreContents(), and move().

## ◆ dataType()

eZDFSFileHandler::dataType | ( |  | ) |

Returns file mime-type / content-type.

Returns
  string|null

Implements eZClusterFileHandlerInterface.

Definition at line 938 of file ezdfsfilehandler.php.

References eZDebugSetting\writeDebug().

## ◆ delete()

eZDFSFileHandler::delete | ( |  | ) |

Deletes specified file/directory.

If a directory specified it is deleted recursively.

Implements eZClusterFileHandlerInterface.

Definition at line 1040 of file ezdfsfilehandler.php.

References $filePath, and eZDebugSetting\writeDebug().

## ◆ deleteLocal()

eZDFSFileHandler::deleteLocal | ( |  | ) |

Deletes a file that has been fetched before.

Implements eZClusterFileHandlerInterface.

Definition at line 1064 of file ezdfsfilehandler.php.

References $filePath, eZClusterFileHandler\cleanupEmptyDirectories(), and eZDebugSetting\writeDebug().

## ◆ disconnect()

eZDFSFileHandler::disconnect | ( |  | ) |

Disconnects the cluster handler from the database

Implements ezpDatabaseBasedClusterFileHandler.

Definition at line 113 of file ezdfsfilehandler.php.

## ◆ endCacheGeneration()

eZDFSFileHandler::endCacheGeneration | ( |  | $rename = `true` | ) |

Ends the cache generation started by startCacheGeneration().

Implements eZClusterFileHandlerInterface.

Definition at line 1327 of file ezdfsfilehandler.php.

References $realFilePath, eZClusterFileHandler\removeGeneratingFile(), eZDebugSetting\writeDebug(), and eZDebug\writeError().

Referenced by storeCache().

## ◆ exists()

eZDFSFileHandler::exists | ( |  | $checkDFSFile = `false` | ) |

Check if given file/dir exists.

Parameters

  bool | $checkDFSFile | if true, also check on the DFS

See also
  eZDFSFileHandler::fileExists()

Returns
  bool

Definition at line 1164 of file ezdfsfilehandler.php.

References eZDebugSetting\writeDebug().

## ◆ fetch()

eZDFSFileHandler::fetch | ( |  | $noLocalCache = `false` | ) |

Fetches file from DFS and saves it in FS under the same name.

Parameters

  bool | $noLocalCache |

Implements eZClusterFileHandlerInterface.

Definition at line 317 of file ezdfsfilehandler.php.

References fileFetch().

Referenced by processCache().

## ◆ fetchContents()

eZDFSFileHandler::fetchContents | ( |  | ) |

Returns file contents.

Returns
  string|bool contents string, or false in case of an error.

Implements eZClusterFileHandlerInterface.

Definition at line 339 of file ezdfsfilehandler.php.

References $contents, $filePath, and eZDebugSetting\writeDebug().

## ◆ fetchExpiredItems()

eZDFSFileHandler::fetchExpiredItems | ( |  | $scopes,
|  |  | $limit = `array( 0 , 100 )`,
|  |  | $expiry = `false`
| ) |  |

Fetches the first $limit expired files from the DB

Parameters

  array | $scopes | Array of scopes to fetch from
  array | $limit | A 2 items array( offset, limit )
  int | $expiry | Number of seconds, only items older than this will be returned

Returns
  array(filepath)

Since
  4.5.0

Definition at line 1454 of file ezdfsfilehandler.php.

References $limit.

## ◆ fetchUnique()

eZDFSFileHandler::fetchUnique | ( |  | ) |

Fetches file from db and saves it in FS under a unique name

Returns
  string filename with path of a saved file. You can use this filename to get contents of file from filesystem.

Implements eZClusterFileHandlerInterface.

Definition at line 303 of file ezdfsfilehandler.php.

References $filePath, and eZDebugSetting\writeDebug().

Referenced by processCache().

## ◆ fileCopy()

eZDFSFileHandler::fileCopy | ( |  | $srcPath,
|  |  | $dstPath
| ) |  |

Copy file.

Implements eZClusterFileHandlerInterface.

Definition at line 1187 of file ezdfsfilehandler.php.

References cleanPath(), and eZDebugSetting\writeDebug().

## ◆ fileDelete()

eZDFSFileHandler::fileDelete | ( |  | $path,
|  |  | $fnamePart = `false`
| ) |  |

Deletes specified file/directory.

Parameters

  string | $path | the file path to delete
  bool | string | $fnamePart | If set to true, $path is a directory and its content is deleted. If it is a string, this string is appended a wildcard and used for deletion

Returns
  void

Todo:
  -ceZDFSFileHandler write unit test

Implements eZClusterFileHandlerInterface.

Definition at line 1015 of file ezdfsfilehandler.php.

References cleanPath(), and eZDebugSetting\writeDebug().

## ◆ fileDeleteByDirList()

eZDFSFileHandler::fileDeleteByDirList | ( |  | $dirList,
|  |  | $commonPath,
|  |  | $commonSuffix
| ) |  |

Deletes a list of files based on directory / filename components

Parameters

  array | $dirList | Array of directory that will be prefixed with $commonPath when looking for files
  string | $commonPath | Starting path common to every delete request
  string | $commonSuffix | Suffix appended to every delete request

Returns
  void

Todo:
  -ceZDFSFileHandler write unit test

Implements eZClusterFileHandlerInterface.

Definition at line 991 of file ezdfsfilehandler.php.

References cleanPath(), and eZDebugSetting\writeDebug().

## ◆ fileDeleteByWildcard()

eZDFSFileHandler::fileDeleteByWildcard | ( |  | $wildcard | ) |

Deletes a list of files by wildcard

Parameters

  string | $wildcard | The wildcard used to look for files. Can contain and ?

Returns
  void

Todo:
  -ceZDFSFileHandler write unit test

Implements eZClusterFileHandlerInterface.

Definition at line 972 of file ezdfsfilehandler.php.

References cleanPath(), eZDebugSetting\writeDebug(), and eZDebug\writeWarning().

## ◆ fileDeleteLocal()

eZDFSFileHandler::fileDeleteLocal | ( |  | $path | ) |

Deletes a file that has been fetched before.

Implements eZClusterFileHandlerInterface.

Definition at line 1053 of file ezdfsfilehandler.php.

References eZClusterFileHandler\cleanupEmptyDirectories(), and eZDebugSetting\writeDebug().

Referenced by processCache().

## ◆ fileExists()

eZDFSFileHandler::fileExists | ( |  | $path,
|  |  | $checkDFSFile = `false`
| ) |  |

Check if given file/dir exists.

Parameters

  string | $path | File path to test existence for
  bool | $checkDFSFile | if true, also check on the DFS

See also
  eZDFSFileHandler::exists()

Returns
  bool

Definition at line 1151 of file ezdfsfilehandler.php.

References cleanPath(), and eZDebugSetting\writeDebug().

## ◆ fileFetch()

eZDFSFileHandler::fileFetch | ( |  | $filePath | ) |

Fetches file from DFS and saves it in LFS under the same name.

Parameters

  string | $filePath |

Returns
  string|false the file path, or false if fetching failed

Implements eZClusterFileHandlerInterface.

Definition at line 265 of file ezdfsfilehandler.php.

References $filePath, cleanPath(), and eZDebugSetting\writeDebug().

Referenced by fetch().

## ◆ fileFetchContents()

eZDFSFileHandler::fileFetchContents | ( |  | $filePath | ) |

Returns file contents.

Returns
  bool|string contents string, or false in case of an error.

Implements eZClusterFileHandlerInterface.

Definition at line 326 of file ezdfsfilehandler.php.

References $contents, $filePath, cleanPath(), and eZDebugSetting\writeDebug().

## ◆ fileLinkCopy()

eZDFSFileHandler::fileLinkCopy | ( |  | $srcPath,
|  |  | $dstPath,
|  |  | $symLink
| ) |  |

Create symbolic or hard link to file.

Implements eZClusterFileHandlerInterface.

Definition at line 1200 of file ezdfsfilehandler.php.

References cleanPath(), and eZDebugSetting\writeDebug().

## ◆ fileMove()

eZDFSFileHandler::fileMove | ( |  | $srcPath,
|  |  | $dstPath
| ) |  |

Move file.

Implements eZClusterFileHandlerInterface.

Definition at line 1212 of file ezdfsfilehandler.php.

References cleanPath(), and eZDebugSetting\writeDebug().

## ◆ fileStore()

eZDFSFileHandler::fileStore | ( |  | $filePath,
|  |  | $scope = `false`,
|  |  | $delete = `false`,
|  |  | $datatype = `false`
| ) |  |

Stores a file by path to the backend

Parameters

  string | $filePath | Path to the file being stored.
  string | $scope | Means something like "file category". May be used to clean caches of a certain type.
  bool | $delete | true if the file should be deleted after storing.
  string | $datatype |

Returns
  void

Implements eZClusterFileHandlerInterface.

Definition at line 185 of file ezdfsfilehandler.php.

References $filePath, cleanPath(), and eZDebugSetting\writeDebug().

## ◆ fileStoreContents()

eZDFSFileHandler::fileStoreContents | ( |  | $filePath,
|  |  | $contents,
|  |  | $scope = `false`,
|  |  | $datatype = `false`
| ) |  |

Store file contents.

Parameters

  string | $filePath | Path to the file being stored.
  string | $contents | Binary file content
  string | $scope | "file category". May be used by cache management
  string | $datatype | Datatype for the file. Also used to clean cache up

Returns
  void

Implements eZClusterFileHandlerInterface.

Definition at line 213 of file ezdfsfilehandler.php.

References $contents, $filePath, cleanPath(), and eZDebugSetting\writeDebug().

## ◆ getFileList()

eZDFSFileHandler::getFileList | ( |  | $scopes = `false`,
|  |  | $excludeScopes = `false`,
|  |  | $limit = `false`,
|  |  | $path = `false`
| ) |  |

Get list of files stored in database.

Used in bin/php/clusterize.php.

Parameters

  array | $scopes | return only files that belong to any of these scopes
  boolean | $excludeScopes | if true, then reverse the meaning of $scopes, which is
  array | $limit | limits the search to offset limit[0], limit limit[1]
  string | $path | filter to include entries only including $path return only files that do not belong to any of the scopes listed in $scopes

Definition at line 1251 of file ezdfsfilehandler.php.

References $limit, and eZDebugSetting\writeDebug().

## ◆ hasStaleCacheSupport()

eZDFSFileHandler::hasStaleCacheSupport | ( |  | ) |

Indicates if the handler supports the stalecache feature

Returns
  bool true if it does, false otherwise

Implements eZClusterFileHandlerInterface.

Definition at line 1459 of file ezdfsfilehandler.php.

## ◆ isDBFileExpired()

eZDFSFileHandler::isDBFileExpired | ( |  | $expiry,
|  |  | $curtime,
|  |  | $ttl
| ) |  |

Calculates if the DB file is expired or not.

Parameters

  int | $expiry | Time when file is to be expired, a value of -1 will disable this check.
  int | $curtime | The current time to check against.
  int | $ttl | Number of seconds the data can live, set to null to disable TTL.

Returns
  bool

Implements eZClusterFileHandlerInterface.

Definition at line 773 of file ezdfsfilehandler.php.

References isFileExpired().

Referenced by processCache().

## ◆ isExpired()

eZDFSFileHandler::isExpired | ( |  | $expiry,
|  |  | $curtime,
|  |  | $ttl
| ) |  |

Calculates if the current file data is expired or not.

Parameters

  int | $expiry | Time when file is to be expired, a value of -1 will disable this check.
  int | $curtime | The current time to check against.
  int | $ttl | Number of seconds the data can live, set to null to disable TTL.

Returns
  bool

Implements eZClusterFileHandlerInterface.

Definition at line 749 of file ezdfsfilehandler.php.

References isFileExpired().

## ◆ isFileExpired()

static eZDFSFileHandler::isFileExpired | ( |  | $fname,
|  |  | $mtime,
|  |  | $expiry,
|  |  | $curtime,
|  |  | $ttl
| ) |  |
| static

Calculates if the file data is expired or not.

Parameters

  string | $fname | Name of file, available for easy debugging.
  int | $mtime | Modification time of file, can be set to false if file does not exist.
  int | $expiry | Time when file is to be expired, a value of -1 will disable this check.
  int | $curtime | The current time to check against.
  int | $ttl | Number of seconds the data can live, set to null to disable TTL.

Returns
  bool

Implements eZClusterFileHandlerInterface.

Definition at line 725 of file ezdfsfilehandler.php.

Referenced by isDBFileExpired(), isExpired(), and isLocalFileExpired().

## ◆ isLocalFileExpired()

eZDFSFileHandler::isLocalFileExpired | ( |  | $expiry,
|  |  | $curtime,
|  |  | $ttl
| ) |  |

Calculates if the local file is expired or not.

Parameters

  int | $expiry | Time when file is to be expired, a value of -1 will disable this check.
  int | $curtime | The current time to check against.
  int | $ttl | Number of seconds the data can live, set to null to disable TTL.

Returns
  bool

Implements eZClusterFileHandlerInterface.

Definition at line 761 of file ezdfsfilehandler.php.

References isFileExpired().

Referenced by processCache().

## ◆ loadMetaData()

eZDFSFileHandler::loadMetaData | ( |  | $force = `false` | ) |

Loads file meta information.

Parameters

  bool | $force | File stats will be refreshed if true

Returns
  void

Implements eZClusterFileHandlerInterface.

Definition at line 128 of file ezdfsfilehandler.php.

References $filePath.

Referenced by __get(), and processCache().

## ◆ move()

eZDFSFileHandler::move | ( |  | $dstPath | ) |

Move/rename file to $dstPath

Parameters

  string | $dstPath | Destination path

Implements eZClusterFileHandlerInterface.

Definition at line 1228 of file ezdfsfilehandler.php.

References $filePath, cleanPath(), and eZDebugSetting\writeDebug().

## ◆ mtime()

eZDFSFileHandler::mtime | ( |  | ) |

Returns file modification time.

Returns
  int|null

Implements eZClusterFileHandlerInterface.

Definition at line 948 of file ezdfsfilehandler.php.

References eZDebugSetting\writeDebug().

## ◆ name()

eZDFSFileHandler::name | ( |  | ) |

Returns file name.

Returns
  string|null

Implements eZClusterFileHandlerInterface.

Definition at line 958 of file ezdfsfilehandler.php.

References $filePath, and eZDebugSetting\writeDebug().

## ◆ passthrough()

eZDFSFileHandler::passthrough | ( |  | $startOffset = `0`,
|  |  | $length = `false`
| ) |  |

Outputs file contents directly

Parameters

  int | $startOffset | Byte offset to start transfer from
  int | $length | Byte length to transfer. NOT end offset, end offset = $startOffset + $length

Returns
  void

Definition at line 1178 of file ezdfsfilehandler.php.

References eZDebugSetting\writeDebug().

## ◆ processCache()

eZDFSFileHandler::processCache | ( |  | $retrieveCallback,
|  |  | $generateCallback = `null`,
|  |  | $ttl = `null`,
|  |  | $expiry = `null`,
|  |  | $extraData = `null`
| ) |  |

Handles cache requests / write operations

Creates a single transaction out of the typical file operations for accessing caches. Caches are normally ready from the database or local file, if the entry does not exist or is expired then it generates the new cache data and stores it. This method takes care of these operations and handles the custom code by performing callbacks when needed.

The $retrieveCallback is used when the file contents can be used (ie. not re-generation) and is called when the file is ready locally. The function will be called with the file path as the first parameter, the mtime as the second and optionally $extraData as the third. The function must return the file contents or an instance of eZClusterFileFailure which can be used to tell the system that the retrieve data cannot be used after all.

$retrieveCallback can be set to null which makes the system go directly to the generation.

The $generateCallback is used when the file content is expired or does not exist, in this case the content must be re-generated and stored. The function will be called with the file path as the first parameter and optionally $extraData as the second. The function must return an array with information on the contents, the array consists of:

- scope - The current scope of the file, is optional.
- datatype - The current datatype of the file, is optional.
- content - The file content, this can be any type except null.
- binarydata - The binary data which is written to the file.
- store - Whether content or binarydata should be stored to the file, if false it will simply return the data. Optional, by default it is true. Note: Set $generateCallback to false to disable generation callback. Note: Set $generateCallback to null to tell the function to perform a write lock but not do any generation, the generation must done be done by the caller by calling
  See also
    storeCache().
  Either content or binarydata must be supplied, if not an error is issued and it returns null.

If content is set it will be used as the return value of this function, if not it will return the binary data. If binarydata is set it will be used as the binary data for the file, if not it will perform a var_export on content and use that as the binary data.

For convenience the $generateCallback function can return a string which will be considered as the binary data for the file and returned as the content.

For controlling how long a cache entry can be used the parameters

See also
  $expiry and
  $ttl is used.
  $expiry can be set to a timestamp which controls the absolute max time for the cache, after this time/date the cache will never be used. If the value is set to a negative value or null there the expiration check is disabled.

$ttl (time to live) tells how many seconds the cache can live from the time it was stored. If the value is set to negative or null there is no limit for the lifetime of the cache. A value of 0 means that the cache will always expire and practically disables caching. For the cache to be used both the $expiry and $ttl check must hold.

Todo:
  Reformat the doc so that it's readable

Implements eZClusterFileHandlerInterface.

Definition at line 413 of file ezdfsfilehandler.php.

References $args, $message, $res, fetch(), fetchUnique(), file_exists(), eZClusterFileFailure\FILE_RETRIEVAL_FAILED, fileDeleteLocal(), isDBFileExpired(), isLocalFileExpired(), loadMetaData(), startCacheGeneration(), storeCache(), eZDebugSetting\writeDebug(), and eZDebug\writeError().

Referenced by processFile().

## ◆ processFile()

eZDFSFileHandler::processFile | ( |  | $callback,
|  |  | $expiry = `false`,
|  |  | $extraData = `null`
| ) |  |

Provides access to the file contents by downloading the file locally and calling $callback with the local filename. The callback can then process the contents and return the data in the same way as in processCache().

Downloading is only done once so the local copy is kept, while updates to the remote DB entry is synced with the local one.

The parameters $expiry and $extraData is the same as for processCache().

See also
  self::processCache()

Note
  Unlike processCache() this returns null if the file cannot be accessed.

Implements eZClusterFileHandlerInterface.

Definition at line 905 of file ezdfsfilehandler.php.

References $result, and processCache().

## ◆ purge()

eZDFSFileHandler::purge | ( |  | $printCallback = `false`,
|  |  | $microsleep = `false`,
|  |  | $max = `false`,
|  |  | $expiry = `false`
| ) |  |

Purges local and remote file data for current file path.

Can be given a file or a folder. In order to clear a folder, do NOT add a trailing / at the end of the file's path: path/to/file instead of path/to/file/.

By default, only expired files will be removed (ezdfsfile.expired = 1). If you specify an $expiry time, it will replace the expired test and only purge files older than the given expiry timestamp.

Parameters

  callback | $printCallback | Callback called after each delete iteration (

See also
  $max) to print out a report of the deleted files. This callback expects two parameters, $file (delete pattern used to perform deletion) and $count (number of deleted items)

Parameters

  int | $microsleep | Wait interval before each purge batch of $max items
  int | $max | Maximum number of items to delete in one batch (default: 100)
  int | $expiry | If specificed, only files older than this date will be purged

Returns
  void

The loop starts without knowing how many files are to be deleted. When _purgeByLike is called, it returns the number of affected rows. If rows were affected, _purgeByLike will be called again

Implements eZClusterFileHandlerInterface.

Definition at line 1097 of file ezdfsfilehandler.php.

References $count, $file, $filePath, eZClusterFileHandler\cleanupEmptyDirectories(), eZDir\recursiveDelete(), and eZDebugSetting\writeDebug().

## ◆ requiresClusterizing()

eZDFSFileHandler::requiresClusterizing | ( |  | ) |

Since eZDFS uses the database, running clusterize.php is required

Returns
  bool

Implements eZClusterFileHandlerInterface.

Definition at line 1426 of file ezdfsfilehandler.php.

## ◆ requiresPurge()

eZDFSFileHandler::requiresPurge | ( |  | ) |

eZDFS does require binary purge. It does store files in DB + on NFS, and therefore doesn't remove files in real time

Since
  4.5.0

Returns
  bool

Implements eZClusterFileHandlerInterface.

Definition at line 1439 of file ezdfsfilehandler.php.

## ◆ size()

eZDFSFileHandler::size | ( |  | ) |

Returns file size.

Returns
  int|null

Implements eZClusterFileHandlerInterface.

Definition at line 928 of file ezdfsfilehandler.php.

References eZDebugSetting\writeDebug().

## ◆ startCacheGeneration()

eZDFSFileHandler::startCacheGeneration | ( |  | ) |

Starts cache generation for the current file.

This is done by creating a file named by the original file name, prefixed with '.generating'.

Returns
  bool false if the file is being generated, true if it is not

Implements eZClusterFileHandlerInterface.

Definition at line 1290 of file ezdfsfilehandler.php.

References $filePath, $ret, eZClusterFileHandler\addGeneratingFile(), eZLog\write(), eZDebugSetting\writeDebug(), and eZDebug\writeError().

Referenced by processCache().

## ◆ stat()

eZDFSFileHandler::stat | ( |  | ) |

Returns file metadata.

Implements eZClusterFileHandlerInterface.

Definition at line 918 of file ezdfsfilehandler.php.

References eZDebugSetting\writeDebug().

## ◆ storeCache()

eZDFSFileHandler::storeCache | ( |  | $fileData | ) |

Stores the data in $fileData to the remote and local file and commits the transaction.

The parameter $fileData must contain the same as information as the $generateCallback returns as explained in processCache().

Note
  This method is just a continuation of the code in processCache() and is not meant to be called alone since it relies on specific state in the database.

Implements eZClusterFileHandlerInterface.

Definition at line 789 of file ezdfsfilehandler.php.

References $result, abortCacheGeneration(), checkCacheGenerationTimeout(), eZFile\create(), endCacheGeneration(), file_exists(), storeContents(), eZDebugSetting\writeDebug(), and eZDebug\writeError().

Referenced by processCache().

## ◆ storeContents()

eZDFSFileHandler::storeContents | ( |  | $contents,
|  |  | $scope = `false`,
|  |  | $datatype = `false`,
|  |  | $storeLocally = `false`
| ) |  |

Store file contents using binary data

Parameters

  string | $contents | Binary file content
  string | $scope | "file category". May be used by cache management
  string | $datatype | Datatype for the file. Also used to clean cache up
  bool | $storeLocally | If true the file will also be stored on the local file system.

Implements eZClusterFileHandlerInterface.

Definition at line 237 of file ezdfsfilehandler.php.

References $contents, $filePath, $result, eZFile\create(), and eZDebugSetting\writeDebug().

Referenced by storeCache().

## Member Data Documentation

## ◆ $_cacheType

eZDFSFileHandler::$_cacheType = null
| protected

Definition at line 1534 of file ezdfsfilehandler.php.

Referenced by __get().

## ◆ $_metaData

eZDFSFileHandler::$_metaData = null
| protected

Definition at line 1520 of file ezdfsfilehandler.php.

Referenced by __get().

## ◆ $dbbackend

eZDFSFileHandler::$dbbackend = null
| static protected

Definition at line 1474 of file ezdfsfilehandler.php.

## ◆ $filePath

eZDFSFileHandler::$filePath = null

Definition at line 1480 of file ezdfsfilehandler.php.

Referenced by __construct(), applyServerUri(), delete(), deleteLocal(), fetchContents(), fetchUnique(), fileFetch(), fileFetchContents(), fileStore(), fileStoreContents(), loadMetaData(), move(), name(), purge(), startCacheGeneration(), and storeContents().

## ◆ $generationStartTimestamp

eZDFSFileHandler::$generationStartTimestamp = false
| protected

Definition at line 1510 of file ezdfsfilehandler.php.

## ◆ $nonExistantStaleCacheHandling

eZDFSFileHandler::$nonExistantStaleCacheHandling = null
| static protected

Definition at line 1528 of file ezdfsfilehandler.php.

## ◆ $realFilePath

eZDFSFileHandler::$realFilePath = null
| protected

holds the real file path. This is only used when we are generating a cache file, in which case $filePath holds the generating cache file name, and $realFilePath holds the real name

Definition at line 1487 of file ezdfsfilehandler.php.

Referenced by abortCacheGeneration(), and endCacheGeneration().

## ◆ $remainingCacheGenerationTime

eZDFSFileHandler::$remainingCacheGenerationTime = false
| protected

Definition at line 1500 of file ezdfsfilehandler.php.

## ◆ $useStaleCache

eZDFSFileHandler::$useStaleCache = false
| protected

Definition at line 1494 of file ezdfsfilehandler.php.

## ◆ INFOCACHE_MAX

const eZDFSFileHandler::INFOCACHE_MAX = 200

Definition at line 41 of file ezdfsfilehandler.php.

## ◆ LOCAL_CACHE

const eZDFSFileHandler::LOCAL_CACHE = 1

Definition at line 34 of file ezdfsfilehandler.php.

The documentation for this class was generated from the following file:

- ezdfsfilehandler.php

Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.