60 return is_file( $this->path );
69 return filesize( $this->path );
78 MediaWiki\suppressWarnings();
80 MediaWiki\restoreWarnings();
106 $info = self::placeholderProps();
107 $info[
'fileExists'] = $this->
exists();
109 if ( $info[
'fileExists'] ) {
110 $info[
'size'] = $this->
getSize();
113 $mime = mime_content_type( $this->path );
114 # MIME type according to file contents
117 $info[
'mime'] =
$mime;
120 list( $info[
'major_mime'], $info[
'minor_mime'] ) = explode(
'/',
$mime, 2 );
122 list( $info[
'major_mime'], $info[
'minor_mime'] ) = [
$mime,
'unknown' ];
145 $info[
'fileExists'] =
false;
147 $info[
'file-mime'] = null;
148 $info[
'major_mime'] = null;
149 $info[
'minor_mime'] = null;
150 $info[
'mime'] = null;
167 if ( $this->sha1Base36 !== null && !$recache ) {
171 MediaWiki\suppressWarnings();
172 $this->sha1Base36 = sha1_file( $this->path );
173 MediaWiki\restoreWarnings();
175 if ( $this->sha1Base36 !==
false ) {
176 $this->sha1Base36 = Wikimedia\base_convert( $this->sha1Base36, 16, 36, 31 );
189 $i = strrpos(
$path,
'.' );
191 return strtolower( $i ? substr(
$path, $i + 1 ) :
'' );
203 $fsFile =
new self(
$path );
205 return $fsFile->getProps(
$ext );
219 $fsFile =
new self(
$path );
221 return $fsFile->getSha1Base36();
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
__construct($path)
Sets up the file object.
getPath()
Returns the file system path.
processing should stop and the error should be shown to the user * false
string $sha1Base36
File SHA-1 in base 36.
string $path
Path to file.
if($ext== 'php'||$ext== 'php5') $mime
wfTimestamp($outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
static extensionFromPath($path)
Get the final file extension from a file system path.
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
getProps($ext=true)
Get an associative array containing information about a file with the given storage path...
static placeholderProps()
Placeholder file properties to use for files that don't exist.
static getSha1Base36FromPath($path)
Get a SHA-1 hash of a file in the local filesystem, in base-36 lower case encoding, zero padded to 31 digits.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
exists()
Checks if the file exists.
Class representing a non-directory file on the file system.
getSize()
Get the file size in bytes.
getSha1Base36($recache=false)
Get a SHA-1 hash of a file in the local filesystem, in base-36 lower case encoding, zero padded to 31 digits.
getTimestamp()
Get the file's last-modified timestamp.
static getPropsFromPath($path, $ext=true)
Get an associative array containing information about a file in the local filesystem.