MediaWiki
REL1_35
FileDependency.php
Go to the documentation of this file.
1
<?php
28
class
FileDependency
extends
CacheDependency
{
29
private
$filename
;
30
private
$timestamp
;
31
46
public
function
__construct
(
$filename
,
$timestamp
=
null
) {
47
$this->filename =
$filename
;
48
$this->timestamp =
$timestamp
;
49
}
50
54
public
function
__sleep
() {
55
$this->
loadDependencyValues
();
56
57
return
[
'filename'
,
'timestamp'
];
58
}
59
60
public
function
loadDependencyValues
() {
61
if
( $this->timestamp ===
null
) {
62
Wikimedia\suppressWarnings();
63
# Dependency on a non-existent file stores "false"
64
# This is a valid concept!
65
$this->timestamp = filemtime( $this->filename );
66
Wikimedia\restoreWarnings();
67
}
68
}
69
73
public
function
isExpired
() {
74
Wikimedia\suppressWarnings();
75
$lastmod = filemtime( $this->filename );
76
Wikimedia\restoreWarnings();
77
if
( $lastmod ===
false
) {
78
if
( $this->timestamp ===
false
) {
79
# Still nonexistent
80
return
false
;
81
}
82
83
# Deleted
84
wfDebug
(
"Dependency triggered: {$this->filename} deleted."
);
85
86
return
true
;
87
}
88
89
if
( $lastmod > $this->timestamp ) {
90
# Modified or created
91
wfDebug
(
"Dependency triggered: {$this->filename} changed."
);
92
93
return
true
;
94
}
95
96
# Not modified
97
return
false
;
98
}
99
}
wfDebug
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Definition
GlobalFunctions.php:910
CacheDependency
Stable to extend.
Definition
CacheDependency.php:28
FileDependency
@newable
Definition
FileDependency.php:28
FileDependency\$filename
$filename
Definition
FileDependency.php:29
FileDependency\__construct
__construct( $filename, $timestamp=null)
Create a file dependency.
Definition
FileDependency.php:46
FileDependency\__sleep
__sleep()
Definition
FileDependency.php:54
FileDependency\$timestamp
$timestamp
Definition
FileDependency.php:30
FileDependency\isExpired
isExpired()
Definition
FileDependency.php:73
FileDependency\loadDependencyValues
loadDependencyValues()
Hook to perform any expensive pre-serialize loading of dependency values.
Definition
FileDependency.php:60
includes
cache
dependency
FileDependency.php
Generated on Sat Apr 6 2024 00:06:58 for MediaWiki by
1.9.8