Closed (fixed)
Project:
Piwik PRO
Version:
1.4.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
22 Oct 2024 at 04:54 UTC
Updated:
23 Feb 2026 at 08:24 UTC
Jump to comment: Most recent
Comments
Comment #2
heikkiy commentedComment #3
heikkiy commentedComment #7
jorgik commentedComment #8
hartsak commentedThanks a lot for your work with this issue @jorgik!
Could you please try to change your indenting so it would follow Drupal coding standards https://www.drupal.org/docs/develop/standards/php/php-coding-standards#i... ?
It seems there's now a lot of 4 space indenting instead of 2 spaces which makes looking at the changes a little difficult.
There's also a couple of occasions with issues like "Access to constant POLICY_ALTER on an unknown class Drupal\csp\CspEvents."
Comment #10
lakdev commentedBased on the great work by @jorgik, I updated the code to the latest version and fixed all remaining code quality issues. I also made a few small refactors to leverage existing services from the CSP module and added some tests.
Hope this helps! Looking forward to a review!
Comment #11
hartsak commentedHello @lakdev and thanks a lot for your efforts with these features!
I tested your code and as far as I could find out the nonce seems to work. I also liked a lot of that implementation where enabling the CSP mode requires a separate install of the CSP module instead of adding that module anyway. So it leaves it up to the admins to make the choice if they want to have the module or not. That's a good idea!
However, I picked up 5 deprecation warnings with phpunit testing. At least some of these seem quite simple to fix, but can you still give a look at these yourself too?
The first one could be fixed by just changing this:
public static function getSubscribedEvents() {to this
public static function getSubscribedEvents(): array {in piwik_pro/src/EventSubscriber/PiwikProCspAlterSubscriber.php
Comment #12
lakdev commentedHi @hartsak,
Thanks for testing and your feedback! I fixed the first issue though I'm not sure whether the other ones are related to any of my code since I'm not really using those classes.
I'm running PHPUnit via DDEV Contrib - Can you maybe also explain how to see those deprecations since I'm not getting them by default?
Comment #13
hartsak commentedHello again @lakdev!
Thank you for fixing those warnings. I think we can ignore those other ones I mentioned about if you didn't see them in your own local.
I'll mark this as RTBC and let's get this merged soonish!
Comment #28
hartsak commentedThis is now merged and added as a new release 1.4.3
Thanks a lot for all contributors especially @jorgik and @lakdev!
Comment #30
joshahubbers commentedI enabled this setting on a site, and got a 500 error when viewing the site in anonymous mode. As logged in user it is working fijn. No error shows up in the drupal logs, but in the apache logs I see " Premature end of script headers: index.php". So I think something is not working correctly. I'll look into it if I can find the cause of the error.
Comment #31
joshahubbers commentedComment #32
joshahubbers commentedHm, might be problem that the csp-headers make the header too big.
Comment #33
joshahubbers commentedConfirmed that our header got too big, so I put this ticket back to fixed.
Comment #34
joshahubbers commented