Follow-up fixes for PR https://github.com/matomo-org/matomo/pull/18868
@peterhashair it would have been enough to change the base in the other PR instead of creating a new one.
Nevertheless your branch still contains the changes from 4.x-dev that shouldn't be included here. You may need to do a rebase and remove all the commits that don't belong to this PR.