line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CMS::Drupal::Admin::MaintenanceMode; |
2
|
|
|
|
|
|
|
$CMS::Drupal::Admin::MaintenanceMode::VERSION = '0.94'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Put your Drupal site into Maintenance Mode, or take it out |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
786
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
6
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
31
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
4
|
use base "Exporter::Tiny"; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
340
|
|
9
|
|
|
|
|
|
|
our @EXPORT = qw/ maintenance_mode_check |
10
|
|
|
|
|
|
|
maintenance_mode_on |
11
|
|
|
|
|
|
|
maintenance_mode_off /; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub maintenance_mode_check { |
14
|
0
|
|
|
0
|
1
|
|
my $dbh = shift; |
15
|
|
|
|
|
|
|
|
16
|
0
|
|
|
|
|
|
my $sql = qq| |
17
|
|
|
|
|
|
|
SELECT value |
18
|
|
|
|
|
|
|
FROM variable |
19
|
|
|
|
|
|
|
WHERE name = 'maintenance_mode' |
20
|
|
|
|
|
|
|
|; |
21
|
|
|
|
|
|
|
|
22
|
0
|
0
|
|
|
|
|
return ( $dbh->selectrow_array( $sql ) eq 'i:1;' ) ? 1 : 0; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub maintenance_mode_on { |
26
|
0
|
|
|
0
|
1
|
|
my $dbh = shift; |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
my $sql1 = qq| |
29
|
|
|
|
|
|
|
UPDATE variable |
30
|
|
|
|
|
|
|
SET value = 'i:1;' |
31
|
|
|
|
|
|
|
WHERE name = 'maintenance_mode' |
32
|
|
|
|
|
|
|
|; |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
my $rv1 = $dbh->do( $sql1 ); |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
my $sql2 = qq| |
37
|
|
|
|
|
|
|
DELETE FROM cache_bootstrap |
38
|
|
|
|
|
|
|
WHERE cid = 'variables' |
39
|
|
|
|
|
|
|
|; |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
my $rv2 = $dbh->do( $sql2 ); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# cache_bootstrap may not have an entry |
44
|
|
|
|
|
|
|
# for 'variables' so we allow 0E0 |
45
|
0
|
0
|
0
|
|
|
|
return ( $rv1 > 0 and $rv2 >= 0 ) ? 1 : 0; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub maintenance_mode_off { |
49
|
0
|
|
|
0
|
1
|
|
my $dbh = shift; |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
my $sql1 = qq| |
52
|
|
|
|
|
|
|
UPDATE variable |
53
|
|
|
|
|
|
|
SET value = 'i:0;' |
54
|
|
|
|
|
|
|
WHERE name = 'maintenance_mode' |
55
|
|
|
|
|
|
|
|; |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
my $rv1 = $dbh->do( $sql1 ); |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
my $sql2 = qq| |
60
|
|
|
|
|
|
|
DELETE FROM cache_bootstrap |
61
|
|
|
|
|
|
|
WHERE cid = 'variables' |
62
|
|
|
|
|
|
|
|; |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
my $rv2 = $dbh->do( $sql2 ); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# cache_bootstrap may not have an entry |
67
|
|
|
|
|
|
|
# for 'variables' so we allow 0E0 |
68
|
0
|
0
|
0
|
|
|
|
return ( $rv1 > 0 and $rv2 >= 0 ) ? 1 : 0; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; # return true |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
__END__ |