eZ Publish Community Project (Legacy Stack) 2013.4
Class

eZDFSFileHandlerMySQLiBackend

class eZDFSFileHandlerMySQLiBackend implements eZClusterEventNotifier

Constants

TIME_UNTIL_RETRY

Wait for n microseconds until retry if copy fails, to avoid DFS overload.

TABLE_METADATA

DB file table name

Properties

handle $db DB connexion handle

Methods

__construct()

void _connect()

Connects to the database.

_disconnect()

Disconnects the handler from the database

bool _copy(string $srcFilePath, string $dstFilePath, string $fname = false)

Creates a copy of a file in DB+DFS

_purge(string $filePath, bool $onlyExpired = false, bool|int $expiry = false, bool $fname = false)

Purges meta-data and file-data for a file entry

bool|int _purgeByLike(string $like, bool $onlyExpired = false, integer $limit = 50, integer $expiry = false, mixed $fname = false)

Purges meta-data and file-data for files matching a pattern using a SQL LIKE syntax.

bool _delete(string $filePath, bool $insideOfTransaction = false, bool|string $fname = false)

Deletes a file from DB

bool _deleteByLike(string $like, string $fname = false)

Deletes multiple files using a SQL LIKE statement

bool _deleteByWildcard(string $wildcard, mixed $fname = false)

Deletes multiple DB files by wildcard

_deleteByDirList($dirList, $commonPath, $commonSuffix, $fname = false)

_exists($filePath, $fname = false, $ignoreExpiredFiles = true, $checkOnDFS = false)

string|bool _fetch(string $filePath, bool|string $uniqueName = false)

Fetches the file $filePath from the database to its own name

_fetchContents($filePath, $fname = false)

array|false _fetchMetadata($filePath, $fname = false)

Fetches and returns metadata for $filePath

_linkCopy($srcPath, $dstPath, $fname = false)

bool _passThrough($filePath, $startOffset, $length = false, $fname = false)

Passes $filePath content through

bool _rename(string $srcFilePath, string $dstFilePath)

Renames $srcFilePath to $dstFilePath

void _store(string $filePath, string $datatype, string $scope, string $fname = false)

Stores $filePath to cluster

bool _storeInner(string $filePath, string $datatype, string $scope, string $fname)

Callback function used to perform the actual file store operation

void _storeContents(string $filePath, string $contents, string $scope, string $datatype, int $mtime = false, string $fname = false)

Stores $contents as the contents of $filePath to the cluster

_storeContentsInner($filePath, $contents, $scope, $datatype, $curTime, $fname)

array|false _getFileList($scopes = false, $excludeScopes = false, $limit = false, $path = false)

gets the list of cluster files, filtered by the optional params

_insert(string $table, array $array, string $fname)

Performs an insert of the given items in $array.

_report($query, $fname, $timeTaken, $numRows = false)

Report SQL $query to debug system.

array _startCacheGeneration($filePath, $generatingFilePath)

Attempts to begin cache generation by creating a new file named as the given filepath, suffixed with .generating.

bool _endCacheGeneration($filePath, $generatingFilePath, $rename)

Ends the cache generation for the current file: moves the (meta)data for the .generating file to the actual file, and removed the .generating

bool _checkCacheGenerationTimeout(string $generatingFilePath, int $generatingFileMtime)

Checks if generation has timed out by looking for the .generating file and comparing its timestamp to the one assigned when the file was created

void _abortCacheGeneration($generatingFilePath)

Aborts the cache generation process by removing the .generating file

array(filepath) expiredFilesList(array $scopes, int $limit = array(0, 100), int $expiry = false)

Returns the list of expired files

void registerListener(eZClusterEventListener $listener)

Registers $listener as the cluster event listener.

Details

at line 47
public __construct()

at line 60
public void _connect()

Connects to the database.

Return Value

void

at line 134
public _disconnect()

Disconnects the handler from the database

at line 152
public bool _copy(string $srcFilePath, string $dstFilePath, string $fname = false)

Creates a copy of a file in DB+DFS

Parameters

string $srcFilePath Source file
string $dstFilePath Destination file
string $fname

Return Value

bool

See also

_copyInner

at line 234
public _purge(string $filePath, bool $onlyExpired = false, bool|int $expiry = false, bool $fname = false)

Purges meta-data and file-data for a file entry

Will only expire a single file. Use _purgeByLike to purge multiple files

Parameters

string $filePath Path of the file to purge
bool $onlyExpired Only purges expired files
bool|int $expiry
bool $fname

See also

_purgeByLike

at line 281
public bool|int _purgeByLike(string $like, bool $onlyExpired = false, integer $limit = 50, integer $expiry = false, mixed $fname = false)

Purges meta-data and file-data for files matching a pattern using a SQL LIKE syntax.

Parameters

string $like SQL LIKE string applied to ezdfsfile.name to look for files to purge
bool $onlyExpired Only purge expired files (ezdfsfile.expired = 1)
integer $limit Maximum number of items to purge in one call
integer $expiry Timestamp used to limit deleted files: only files older than this date will be deleted
mixed $fname Optional caller name for debugging

Return Value

bool|int false if it fails, number of affected rows otherwise

See also

_purge

at line 359
public bool _delete(string $filePath, bool $insideOfTransaction = false, bool|string $fname = false)

Deletes a file from DB

The file won't be removed from disk, _purge has to be used for this. Only single files will be deleted, to delete multiple files, _deleteByLike has to be used.

Parameters

string $filePath Path of the file to delete
bool $insideOfTransaction Wether or not a transaction is already started
bool|string $fname Optional caller name for debugging

Return Value

bool

See also

_deleteInner
_deleteByLike

at line 415
public bool _deleteByLike(string $like, string $fname = false)

Deletes multiple files using a SQL LIKE statement

Use _delete if you need to delete single files

Parameters

string $like SQL LIKE condition applied to ezdfsfile.name to look for files to delete. Will use nametrunk if the LIKE string matches a filetype that supports nametrunk.
string $fname Optional caller name for debugging

Return Value

bool

See also

_deleteByLikeInner
_delete

at line 455
public bool _deleteByWildcard(string $wildcard, mixed $fname = false)

Deletes multiple DB files by wildcard

Parameters

string $wildcard
mixed $fname

Return Value

bool

at line 494
public _deleteByDirList($dirList, $commonPath, $commonSuffix, $fname = false)

Parameters

$dirList
$commonPath
$commonSuffix
$fname

at line 538
public _exists($filePath, $fname = false, $ignoreExpiredFiles = true, $checkOnDFS = false)

Parameters

$filePath
$fname
$ignoreExpiredFiles
$checkOnDFS

at line 606
public string|bool _fetch(string $filePath, bool|string $uniqueName = false)

Fetches the file $filePath from the database to its own name

Saving $filePath locally with its original name, or $uniqueName if given

Parameters

string $filePath
bool|string $uniqueName Alternative name to save the file to

Return Value

string|bool the file physical path, or false if fetch failed

at line 667
public _fetchContents($filePath, $fname = false)

Parameters

$filePath
$fname

at line 695
public array|false _fetchMetadata($filePath, $fname = false)

Fetches and returns metadata for $filePath

Parameters

$filePath
$fname

Return Value

array|false file metadata, or false if the file does not exist in database.

at line 715
public _linkCopy($srcPath, $dstPath, $fname = false)

Parameters

$srcPath
$dstPath
$fname

at line 733
public bool _passThrough($filePath, $startOffset, $length = false, $fname = false)

Passes $filePath content through

Parameters

$filePath
$startOffset
$length
$fname

Return Value

bool

at line 758
public bool _rename(string $srcFilePath, string $dstFilePath)

Renames $srcFilePath to $dstFilePath

Parameters

string $srcFilePath
string $dstFilePath

Return Value

bool

at line 834
public void _store(string $filePath, string $datatype, string $scope, string $fname = false)

Stores $filePath to cluster

Parameters

string $filePath
string $datatype
string $scope
string $fname

Return Value

void

at line 861
public bool _storeInner(string $filePath, string $datatype, string $scope, string $fname)

Callback function used to perform the actual file store operation

Parameters

string $filePath
string $datatype
string $scope
string $fname

Return Value

bool

See also

eZDFSFileHandlerMySQLiBackend::_store()

at line 908
public void _storeContents(string $filePath, string $contents, string $scope, string $datatype, int $mtime = false, string $fname = false)

Stores $contents as the contents of $filePath to the cluster

Parameters

string $filePath
string $contents
string $scope
string $datatype
int $mtime
string $fname

Return Value

void

at line 919
public _storeContentsInner($filePath, $contents, $scope, $datatype, $curTime, $fname)

Parameters

$filePath
$contents
$scope
$datatype
$curTime
$fname

at line 962
public array|false _getFileList($scopes = false, $excludeScopes = false, $limit = false, $path = false)

gets the list of cluster files, filtered by the optional params

Parameters

$scopes
$excludeScopes
$limit
$path

Return Value

array|false the db list of entries of false if none found

at line 1031
public _insert(string $table, array $array, string $fname)

Performs an insert of the given items in $array.

Parameters

string $table Name of table to execute insert on.
array $array Associative array with data to insert, the keys are the field names and the values will be quoted according to type.
string $fname Name of caller function (for logging purpuse)

at line 1425
public _report($query, $fname, $timeTaken, $numRows = false)

Report SQL $query to debug system.

Parameters

$query
$fname
$timeTaken
$numRows

at line 1453
public array _startCacheGeneration($filePath, $generatingFilePath)

Attempts to begin cache generation by creating a new file named as the given filepath, suffixed with .generating.

If the file already exists, insertion is not performed and false is returned (means that the file is already being generated)

Parameters

$filePath
$generatingFilePath

Return Value

array array with 2 indexes: 'result', containing either ok or ko, and another index that depends on the result: - if result == 'ok', the 'mtime' index contains the generating file's mtime - if result == 'ko', the 'remaining' index contains the remaining generation time (time until timeout) in seconds

at line 1529
public bool _endCacheGeneration($filePath, $generatingFilePath, $rename)

Ends the cache generation for the current file: moves the (meta)data for the .generating file to the actual file, and removed the .generating

Parameters

$filePath
$generatingFilePath
$rename

Return Value

bool

at line 1621
public bool _checkCacheGenerationTimeout(string $generatingFilePath, int $generatingFileMtime)

Checks if generation has timed out by looking for the .generating file and comparing its timestamp to the one assigned when the file was created

Parameters

string $generatingFilePath
int $generatingFileMtime

Return Value

bool true if the file didn't timeout, false otherwise

at line 1684
public void _abortCacheGeneration($generatingFilePath)

Aborts the cache generation process by removing the .generating file

Parameters

$generatingFilePath

Return Value

void

at line 1764
public array(filepath) expiredFilesList(array $scopes, int $limit = array(0, 100), int $expiry = false)

Returns the list of expired files

Parameters

array $scopes Array of scopes to consider. At least one.
int $limit Max number of items. Set to false for unlimited.
int $expiry Number of seconds, only items older than this will be returned.

Return Value

array(filepath)

at line 1794
public void registerListener(eZClusterEventListener $listener)

Registers $listener as the cluster event listener.

Parameters

eZClusterEventListener $listener

Return Value

void