blob: 91745db88d322023fac110ddd0323cf1818b860f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
<?php
namespace Piwik\Plugins\Diagnostics\Diagnostic;
use Piwik\Db;
use Piwik\MetricsFormatter;
use Piwik\Piwik;
use Piwik\SettingsPiwik;
use Piwik\Translation\Translator;
/**
* Check if Piwik is connected with database through ssl.
*/
class DbMaxPacket implements Diagnostic
{
/**
* @var Translator
*/
private $translator;
const MIN_VALUE_MAX_PACKET_MB = 64;
public function __construct(Translator $translator)
{
$this->translator = $translator;
}
public function execute()
{
if (!SettingsPiwik::isPiwikInstalled()) {
return array(); // only possible to perform check once we have DB connection
}
$maxPacketBytes = Db::fetchRow("SHOW VARIABLES LIKE 'max_allowed_packet'");
$status = DiagnosticResult::STATUS_OK;
$label = $this->translator->translate('Diagnostics_MysqlMaxPacketSize');
$comment = '';
$minSize = self::MIN_VALUE_MAX_PACKET_MB * 1000 * 1000; // not using 1024 just in case... this amount be good enough
if (!empty($maxPacketBytes['Value']) && $maxPacketBytes['Value'] < $minSize) {
$status = DiagnosticResult::STATUS_WARNING;
$pretty = MetricsFormatter::getPrettySizeFromBytes($maxPacketBytes['Value'], 'M');
$configured = str_replace(array(' M', ' M'), 'MB', $pretty);
$comment = Piwik::translate('Diagnostics_MysqlMaxPacketSizeWarning', array('64MB', $configured));
}
return array(DiagnosticResult::singleResult($label, $status, $comment));
}
}
|