Skip to content

Commit dc1996c

Browse files
Set config key disable_cookies default to true [BC break] (#31)
* Set config key disable_cookies default to true [BC break] * Created new test for testing enabling cookies
1 parent e3e639d commit dc1996c

File tree

5 files changed

+10
-15
lines changed

5 files changed

+10
-15
lines changed

DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function getConfigTreeBuilder()
2323
->scalarNode('piwik_host')->isRequired()->end()
2424
->scalarNode('tracker_path')->defaultValue('/js/')->end()
2525
->scalarNode('site_id')->isRequired()->end()
26-
->scalarNode('disable_cookies')->defaultValue(null)->end()
26+
->scalarNode('disable_cookies')->defaultValue(true)->end()
2727
->end();
2828

2929
return $treeBuilder;

DependencyInjection/WebfactoryPiwikExtension.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,6 @@ public function load(array $configs, ContainerBuilder $container)
1818
$configuration = new Configuration();
1919
$config = $this->processConfiguration($configuration, $configs);
2020

21-
if (null === $config['disable_cookies']) {
22-
$config['disable_cookies'] = false;
23-
@trigger_error(
24-
'The "disableCookies" configuration key is missing. In the next major version, it will default to "true".
25-
Please configure the "disableCookies" key explicitly if this is not what you want.',
26-
E_USER_DEPRECATED
27-
);
28-
}
29-
3021
foreach (['disabled', 'piwik_host', 'tracker_path', 'site_id', 'disable_cookies'] as $configParameterKey) {
3122
$container->setParameter("webfactory_piwik.$configParameterKey", $config[$configParameterKey]);
3223
}

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ webfactory_piwik:
5454
tracker_path: "/js/"
5555
# Optional, has default. Disable cookies in favor of GDPR
5656
# https://matomo.org/faq/new-to-piwik/how-do-i-use-matomo-analytics-without-consent-or-cookie-banner/ & https://matomo.org/faq/general/faq_157/
57-
#
58-
# In the next major release the default will be true!
59-
disable_cookies: false
57+
disable_cookies: true
6058
```
6159
6260
Add calls to the JavaScript tracker API

Tests/Twig/ExtensionTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,16 @@ public function testTrackPageViewEnabledByDefault()
6363

6464
public function testCookiesCanBeDisabled()
6565
{
66-
$extension = new Extension(false, 1, 'my.host', false, true);
66+
$extension = new Extension(false, 1, 'my.host', false);
6767
$this->assertContains('"disableCookies"', $extension->piwikCode());
6868
}
6969

70+
public function testCookiesCanBeEnabled()
71+
{
72+
$extension = new Extension(false, 1, 'my.host', false, false);
73+
$this->assertNotContains('"disableCookies"', $extension->piwikCode());
74+
}
75+
7076
public function testTrackSiteSearchDisablesPageTracking()
7177
{
7278
$extension = new Extension(false, 1, 'my.host', false);

Twig/Extension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Extension extends AbstractExtension
3737
*/
3838
private $paqs = [];
3939

40-
public function __construct(bool $disabled, string $siteId, string $piwikHost, string $trackerPath, bool $disableCookies = false)
40+
public function __construct(bool $disabled, string $siteId, string $piwikHost, string $trackerPath, bool $disableCookies = true)
4141
{
4242
$this->disabled = $disabled;
4343
$this->siteId = $siteId;

0 commit comments

Comments
 (0)