Skip to content

Commit dc7e1a2

Browse files
authored
Merge pull request #28 from DevDavido/development
Bump to v1.1.3
2 parents fa02858 + 890c9da commit dc7e1a2

15 files changed

+92
-41
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
- Added: Support for Matomo 4 🎉
44
- Updated: Bumped the minimum PHP version to 7.2.5 for this new major plugin version, just as Matomo 4 itself
55

6+
## 1.1.3
7+
- Added: Possibility to set extended audit timeout for each site
8+
- Improved: Minor internal refactoring for site settings
9+
- Updated: Bumped `symfony/process` dependency version
10+
611
## 1.1.2
712
- Added: Possibility to enable or disable audit for each site
813
- Improved: Set timeout for installation process to 5 minutes

MeasurableSettings.php

+41-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ class MeasurableSettings extends BaseMeasurableSettings
2323
/** @var Setting */
2424
public $isEnabled;
2525

26+
/** @var Setting */
27+
public $hasExtendedTimeout;
28+
2629
/** @var Setting */
2730
public $runCount;
2831

@@ -52,6 +55,7 @@ protected function init()
5255
Piwik::checkUserHasSomeViewAccess();
5356

5457
$this->isEnabled = $this->makeIsEnabledSetting();
58+
$this->hasExtendedTimeout = $this->makeHasExtendedTimeoutSetting();
5559
$this->runCount = $this->makeRunCountSetting();
5660
$this->emulatedDevice = $this->makeEmulatedDeviceSetting();
5761
$this->hasGroupedUrls = $this->makeHasGroupedUrlsSetting();
@@ -75,6 +79,21 @@ private function makeIsEnabledSetting()
7579
});
7680
}
7781

82+
/**
83+
* Create has extended timeout setting.
84+
*
85+
* @return MeasurableSetting
86+
* @throws ValidatorException|Exception
87+
*/
88+
private function makeHasExtendedTimeoutSetting()
89+
{
90+
return $this->makeSetting('has_extended_timeout', false, FieldConfig::TYPE_BOOL, function (FieldConfig $field) {
91+
$field->title = Piwik::translate('PerformanceAudit_Settings_HasExtendedTimeout_Title');
92+
$field->inlineHelp = Piwik::translate('PerformanceAudit_Settings_HasExtendedTimeout_Help');
93+
$field->uiControl = FieldConfig::UI_CONTROL_CHECKBOX;
94+
});
95+
}
96+
7897
/**
7998
* Create run count setting.
8099
*
@@ -180,7 +199,7 @@ private function makeExtraHttpHeaderKeySetting()
180199
'Cookie' => Piwik::translate('PerformanceAudit_Settings_ExtraHttpHeaderKey_Cookie'),
181200
];
182201
$field->validate = function ($value) use ($self, $field) {
183-
if ($self->getSetting('has_extra_http_header')->getValue()) {
202+
if ($self->hasExtraHttpHeader()) {
184203
if (empty($value)) {
185204
throw new ValidatorException(Piwik::translate('General_ValidatorErrorEmptyValue'));
186205
}
@@ -208,7 +227,7 @@ private function makeExtraHttpHeaderValueSetting()
208227
$field->condition = 'is_enabled && has_extra_http_header';
209228
$field->uiControl = FieldConfig::UI_CONTROL_TEXT;
210229
$field->validate = function ($value) use ($self, $field) {
211-
if ($self->getSetting('has_extra_http_header')->getValue()) {
230+
if ($self->hasExtraHttpHeader()) {
212231
if (empty($value)) {
213232
throw new ValidatorException(Piwik::translate('General_ValidatorErrorEmptyValue'));
214233
}
@@ -250,6 +269,16 @@ public function isAuditEnabled()
250269
return $this->getSetting('is_enabled')->getValue();
251270
}
252271

272+
/**
273+
* Returns if site has extended timeout for site audit.
274+
*
275+
* @return bool
276+
*/
277+
public function hasExtendedTimeout()
278+
{
279+
return $this->getSetting('has_extended_timeout')->getValue();
280+
}
281+
253282
/**
254283
* Returns if site has grouped URLs for site.
255284
*
@@ -259,4 +288,14 @@ public function hasGroupedUrls()
259288
{
260289
return $this->getSetting('has_grouped_urls')->getValue();
261290
}
291+
292+
/**
293+
* Returns if site has extra HTTP header for site.
294+
*
295+
* @return bool
296+
*/
297+
public function hasExtraHttpHeader()
298+
{
299+
return $this->getSetting('has_extra_http_header')->getValue();
300+
}
262301
}

Tasks.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,10 @@ private static function getLighthouse(int $idSite)
276276
Audit::enableEachLighthouseAudit(self::$lighthouse[$idSite]);
277277

278278
$siteSettings = new MeasurableSettings($idSite);
279-
if ($siteSettings->getSetting('has_extra_http_header')->getValue()) {
279+
if ($siteSettings->hasExtendedTimeout()) {
280+
self::$lighthouse[$idSite]->setTimeout(300);
281+
}
282+
if ($siteSettings->hasExtraHttpHeader()) {
280283
self::$lighthouse[$idSite]->setHeaders([
281284
$siteSettings->getSetting('extra_http_header_key')->getValue() => $siteSettings->getSetting('extra_http_header_value')->getValue()
282285
]);

lang/en.json

+2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@
6565
"Metrics_Tooltip_OutOfRange": "%s%s is out of range of all classification groups.",
6666
"Settings_IsEnabled_Title": "Perform performance audit for this site",
6767
"Settings_IsEnabled_Help": "You can decide on a per-website basis if website performance audits are performed after all.",
68+
"Settings_HasExtendedTimeout_Title": "Increase timeout for performance audits",
69+
"Settings_HasExtendedTimeout_Help": "You can decide on a per-website basis if website performance audit timeouts should be extended to 5 minutes instead of the default 1 minute. Extending the timeout is only recommended if you encounter regular timeouts, e.g. if your server is not fast enough to perform the audits within 1 minute.",
6870
"Settings_RunCount_Title": "Number of performance audit iterations",
6971
"Settings_RunCount_Help": "Set how many times the audit should be performed on each page for stable results. Any number between 1 and 5 is possible. 5 iterations are twice as stable, but prolongs the processing time the most. Just use such high values like 5 iterations only if enough server resources are generally available. 3 iterations are usually the best balance between reproducibility and resource consumption.",
7072
"Settings_EmulatedDevice_Title": "Performance simulation environment",

plugin.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "PerformanceAudit",
33
"description": "Daily performance audits of all your sites in Matomo.",
4-
"version": "1.1.2",
4+
"version": "1.1.3",
55
"theme": false,
66
"require": {
77
"php": ">=7.1.3",

vendor/composer/InstalledVersions.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class InstalledVersions
1919
'aliases' =>
2020
array (
2121
),
22-
'reference' => '674a5e8d09a059e62bda1ab8ad1cdadb3b2603a0',
22+
'reference' => 'fa02858d47f977e486689baf845e3df5367ed647',
2323
'name' => 'devdavido/performance-audit-plugin',
2424
),
2525
'versions' =>
@@ -31,7 +31,7 @@ class InstalledVersions
3131
'aliases' =>
3232
array (
3333
),
34-
'reference' => '674a5e8d09a059e62bda1ab8ad1cdadb3b2603a0',
34+
'reference' => 'fa02858d47f977e486689baf845e3df5367ed647',
3535
),
3636
'ducks-project/spl-types' =>
3737
array (
@@ -62,12 +62,12 @@ class InstalledVersions
6262
),
6363
'symfony/process' =>
6464
array (
65-
'pretty_version' => 'v4.4.13',
66-
'version' => '4.4.13.0',
65+
'pretty_version' => 'v4.4.15',
66+
'version' => '4.4.15.0',
6767
'aliases' =>
6868
array (
6969
),
70-
'reference' => '65e70bab62f3da7089a8d4591fb23fbacacb3479',
70+
'reference' => '9b887acc522935f77555ae8813495958c7771ba7',
7171
),
7272
),
7373
);

vendor/composer/autoload_classmap.php

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
'Piwik\\Plugins\\PerformanceAudit\\Columns\\Metrics\\MinPercent' => $baseDir . '/Columns/Metrics/MinPercent.php',
3636
'Piwik\\Plugins\\PerformanceAudit\\Columns\\Metrics\\MinSeconds' => $baseDir . '/Columns/Metrics/MinSeconds.php',
3737
'Piwik\\Plugins\\PerformanceAudit\\Columns\\PageUrl' => $baseDir . '/Columns/PageUrl.php',
38+
'Piwik\\Plugins\\PerformanceAudit\\Commands\\ClearTaskRunningFlag' => $baseDir . '/Commands/ClearTaskRunningFlag.php',
3839
'Piwik\\Plugins\\PerformanceAudit\\Controller' => $baseDir . '/Controller.php',
3940
'Piwik\\Plugins\\PerformanceAudit\\EmulatedDevice' => $baseDir . '/EmulatedDevice.php',
4041
'Piwik\\Plugins\\PerformanceAudit\\Exceptions\\AuditFailedAuthoriseRefusedException' => $baseDir . '/Exceptions/AuditFailedAuthoriseRefusedException.php',

vendor/composer/autoload_static.php

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class ComposerStaticInit98dde460e8a16c8877d8f8d8a8e6921c
7373
'Piwik\\Plugins\\PerformanceAudit\\Columns\\Metrics\\MinPercent' => __DIR__ . '/../..' . '/Columns/Metrics/MinPercent.php',
7474
'Piwik\\Plugins\\PerformanceAudit\\Columns\\Metrics\\MinSeconds' => __DIR__ . '/../..' . '/Columns/Metrics/MinSeconds.php',
7575
'Piwik\\Plugins\\PerformanceAudit\\Columns\\PageUrl' => __DIR__ . '/../..' . '/Columns/PageUrl.php',
76+
'Piwik\\Plugins\\PerformanceAudit\\Commands\\ClearTaskRunningFlag' => __DIR__ . '/../..' . '/Commands/ClearTaskRunningFlag.php',
7677
'Piwik\\Plugins\\PerformanceAudit\\Controller' => __DIR__ . '/../..' . '/Controller.php',
7778
'Piwik\\Plugins\\PerformanceAudit\\EmulatedDevice' => __DIR__ . '/../..' . '/EmulatedDevice.php',
7879
'Piwik\\Plugins\\PerformanceAudit\\Exceptions\\AuditFailedAuthoriseRefusedException' => __DIR__ . '/../..' . '/Exceptions/AuditFailedAuthoriseRefusedException.php',

vendor/composer/installed.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -195,23 +195,23 @@
195195
},
196196
{
197197
"name": "symfony/process",
198-
"version": "v4.4.13",
199-
"version_normalized": "4.4.13.0",
198+
"version": "v4.4.15",
199+
"version_normalized": "4.4.15.0",
200200
"source": {
201201
"type": "git",
202202
"url": "https://github.com/symfony/process.git",
203-
"reference": "65e70bab62f3da7089a8d4591fb23fbacacb3479"
203+
"reference": "9b887acc522935f77555ae8813495958c7771ba7"
204204
},
205205
"dist": {
206206
"type": "zip",
207-
"url": "https://api.github.com/repos/symfony/process/zipball/65e70bab62f3da7089a8d4591fb23fbacacb3479",
208-
"reference": "65e70bab62f3da7089a8d4591fb23fbacacb3479",
207+
"url": "https://api.github.com/repos/symfony/process/zipball/9b887acc522935f77555ae8813495958c7771ba7",
208+
"reference": "9b887acc522935f77555ae8813495958c7771ba7",
209209
"shasum": ""
210210
},
211211
"require": {
212212
"php": ">=7.1.3"
213213
},
214-
"time": "2020-07-23T08:31:43+00:00",
214+
"time": "2020-09-02T16:08:58+00:00",
215215
"type": "library",
216216
"extra": {
217217
"branch-alias": {
@@ -244,7 +244,7 @@
244244
"description": "Symfony Process Component",
245245
"homepage": "https://symfony.com",
246246
"support": {
247-
"source": "https://github.com/symfony/process/tree/v4.4.12"
247+
"source": "https://github.com/symfony/process/tree/4.4"
248248
},
249249
"funding": [
250250
{

vendor/composer/installed.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
'aliases' =>
77
array (
88
),
9-
'reference' => '674a5e8d09a059e62bda1ab8ad1cdadb3b2603a0',
9+
'reference' => 'fa02858d47f977e486689baf845e3df5367ed647',
1010
'name' => 'devdavido/performance-audit-plugin',
1111
),
1212
'versions' =>
@@ -18,7 +18,7 @@
1818
'aliases' =>
1919
array (
2020
),
21-
'reference' => '674a5e8d09a059e62bda1ab8ad1cdadb3b2603a0',
21+
'reference' => 'fa02858d47f977e486689baf845e3df5367ed647',
2222
),
2323
'ducks-project/spl-types' =>
2424
array (
@@ -49,12 +49,12 @@
4949
),
5050
'symfony/process' =>
5151
array (
52-
'pretty_version' => 'v4.4.13',
53-
'version' => '4.4.13.0',
52+
'pretty_version' => 'v4.4.15',
53+
'version' => '4.4.15.0',
5454
'aliases' =>
5555
array (
5656
),
57-
'reference' => '65e70bab62f3da7089a8d4591fb23fbacacb3479',
57+
'reference' => '9b887acc522935f77555ae8813495958c7771ba7',
5858
),
5959
),
6060
);

vendor/symfony/process/ExecutableFinder.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function addSuffix($suffix)
5151
public function find($name, $default = null, array $extraDirs = [])
5252
{
5353
if (ini_get('open_basedir')) {
54-
$searchPath = array_merge(explode(PATH_SEPARATOR, ini_get('open_basedir')), $extraDirs);
54+
$searchPath = array_merge(explode(\PATH_SEPARATOR, ini_get('open_basedir')), $extraDirs);
5555
$dirs = [];
5656
foreach ($searchPath as $path) {
5757
// Silencing against https://bugs.php.net/69240
@@ -65,15 +65,15 @@ public function find($name, $default = null, array $extraDirs = [])
6565
}
6666
} else {
6767
$dirs = array_merge(
68-
explode(PATH_SEPARATOR, getenv('PATH') ?: getenv('Path')),
68+
explode(\PATH_SEPARATOR, getenv('PATH') ?: getenv('Path')),
6969
$extraDirs
7070
);
7171
}
7272

7373
$suffixes = [''];
7474
if ('\\' === \DIRECTORY_SEPARATOR) {
7575
$pathExt = getenv('PATHEXT');
76-
$suffixes = array_merge($pathExt ? explode(PATH_SEPARATOR, $pathExt) : $this->suffixes, $suffixes);
76+
$suffixes = array_merge($pathExt ? explode(\PATH_SEPARATOR, $pathExt) : $this->suffixes, $suffixes);
7777
}
7878
foreach ($suffixes as $suffix) {
7979
foreach ($dirs as $dir) {

vendor/symfony/process/PhpExecutableFinder.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function find($includeArgs = true)
3838
if ($php = getenv('PHP_BINARY')) {
3939
if (!is_executable($php)) {
4040
$command = '\\' === \DIRECTORY_SEPARATOR ? 'where' : 'command -v';
41-
if ($php = strtok(exec($command.' '.escapeshellarg($php)), PHP_EOL)) {
41+
if ($php = strtok(exec($command.' '.escapeshellarg($php)), \PHP_EOL)) {
4242
if (!is_executable($php)) {
4343
return false;
4444
}
@@ -54,8 +54,8 @@ public function find($includeArgs = true)
5454
$args = $includeArgs && $args ? ' '.implode(' ', $args) : '';
5555

5656
// PHP_BINARY return the current sapi executable
57-
if (PHP_BINARY && \in_array(\PHP_SAPI, ['cgi-fcgi', 'cli', 'cli-server', 'phpdbg'], true)) {
58-
return PHP_BINARY.$args;
57+
if (\PHP_BINARY && \in_array(\PHP_SAPI, ['cgi-fcgi', 'cli', 'cli-server', 'phpdbg'], true)) {
58+
return \PHP_BINARY.$args;
5959
}
6060

6161
if ($php = getenv('PHP_PATH')) {
@@ -72,11 +72,11 @@ public function find($includeArgs = true)
7272
}
7373
}
7474

75-
if (@is_executable($php = PHP_BINDIR.('\\' === \DIRECTORY_SEPARATOR ? '\\php.exe' : '/php'))) {
75+
if (@is_executable($php = \PHP_BINDIR.('\\' === \DIRECTORY_SEPARATOR ? '\\php.exe' : '/php'))) {
7676
return $php;
7777
}
7878

79-
$dirs = [PHP_BINDIR];
79+
$dirs = [\PHP_BINDIR];
8080
if ('\\' === \DIRECTORY_SEPARATOR) {
8181
$dirs[] = 'C:\xampp\php\\';
8282
}

vendor/symfony/process/PhpProcess.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public static function fromShellCommandline(string $command, string $cwd = null,
6565
*/
6666
public function setPhpBinary($php)
6767
{
68-
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the $php argument of the constructor instead.', __METHOD__), E_USER_DEPRECATED);
68+
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the $php argument of the constructor instead.', __METHOD__), \E_USER_DEPRECATED);
6969

7070
$this->setCommandLine($php);
7171
}

vendor/symfony/process/Pipes/WindowsPipes.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,17 @@ public function __construct($input, bool $haveReadSupport)
6262
restore_error_handler();
6363
throw new RuntimeException('A temporary file could not be opened to write the process output: '.$lastError);
6464
}
65-
if (!flock($h, LOCK_EX | LOCK_NB)) {
65+
if (!flock($h, \LOCK_EX | \LOCK_NB)) {
6666
continue 2;
6767
}
6868
if (isset($this->lockHandles[$pipe])) {
69-
flock($this->lockHandles[$pipe], LOCK_UN);
69+
flock($this->lockHandles[$pipe], \LOCK_UN);
7070
fclose($this->lockHandles[$pipe]);
7171
}
7272
$this->lockHandles[$pipe] = $h;
7373

7474
if (!fclose(fopen($file, 'w')) || !$h = fopen($file, 'r')) {
75-
flock($this->lockHandles[$pipe], LOCK_UN);
75+
flock($this->lockHandles[$pipe], \LOCK_UN);
7676
fclose($this->lockHandles[$pipe]);
7777
unset($this->lockHandles[$pipe]);
7878
continue 2;
@@ -152,7 +152,7 @@ public function readAndWrite(bool $blocking, bool $close = false): array
152152
if ($close) {
153153
ftruncate($fileHandle, 0);
154154
fclose($fileHandle);
155-
flock($this->lockHandles[$type], LOCK_UN);
155+
flock($this->lockHandles[$type], \LOCK_UN);
156156
fclose($this->lockHandles[$type]);
157157
unset($this->fileHandles[$type], $this->lockHandles[$type]);
158158
}
@@ -186,7 +186,7 @@ public function close()
186186
foreach ($this->fileHandles as $type => $handle) {
187187
ftruncate($handle, 0);
188188
fclose($handle);
189-
flock($this->lockHandles[$type], LOCK_UN);
189+
flock($this->lockHandles[$type], \LOCK_UN);
190190
fclose($this->lockHandles[$type]);
191191
}
192192
$this->fileHandles = $this->lockHandles = [];

0 commit comments

Comments
 (0)