Ecodev / newsletter

TYPO3 extension to send newsletter
https://extensions.typo3.org/extension/newsletter/
25 stars 26 forks source link

[BUG] newsletter_view_url missing Language Parameter #162

Closed siwa-pparzer closed 5 years ago

siwa-pparzer commented 6 years ago

TYPO3 8.7.18 Newsletter 3.3.1 The ###newsletter_view_url### is missing the Language Parameter L in the EMail. The E-Mail Preview (via BE) works but after sending, the L Parameter gets lost.

Preview Link: https://www.example.com/index.php?id=852&type=1342671779&L=1&tx_newsletter_p%5Baction%5D=show&tx_newsletter_p%5Bcontroller%5D=Email&tx_newsletter_p%5Bc%5D=

EMail Link: https://www.example.com/index.php?id=852&type=1342671779&tx_newsletter_p%5Baction%5D=show&tx_newsletter_p%5Bcontroller%5D=Email&tx_newsletter_p%5Bc%5D=cde70009b8665062adc67d8035eb08a3

PowerKiKi commented 6 years ago

Would you try to submit a PR to fix this and cover it with unit/functional tests ?

siwa-pparzer commented 6 years ago

I tried to find a solution for this bug last week, but unfortunately I wasn't able to detect the problem. I couldn't find out why the preview works, but the sending won't. So I hoped for your help.

PowerKiKi commented 6 years ago

Could you please test the following diff and report if everything is working for you ?

diff --git Classes/Domain/Model/Email.php Classes/Domain/Model/Email.php
index 02b1f34..876b21e 100644
--- Classes/Domain/Model/Email.php
+++ Classes/Domain/Model/Email.php
@@ -292,7 +292,7 @@ class Email extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity implements Em
      */
     public function getViewUrl()
     {
-        return UriBuilder::buildFrontendUri($this->getPid(), 'Email', 'show', ['c' => $this->getAuthCode()]);
+        return UriBuilder::buildFrontendUri($this->getPid(), 'Email', 'show', ['c' => $this->getAuthCode(), 'L' => $this->getRecipientData()['L']]);
     }

     /**
@@ -302,7 +302,7 @@ class Email extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity implements Em
      */
     public function getUnsubscribeUrl()
     {
-        return UriBuilder::buildFrontendUri($this->getPid(), 'Email', 'unsubscribe', ['c' => $this->getAuthCode()]);
+        return UriBuilder::buildFrontendUri($this->getPid(), 'Email', 'unsubscribe', ['c' => $this->getAuthCode(), 'L' => $this->getRecipientData()['L']]);
     }

     /**
siwa-pparzer commented 6 years ago

This diff itself couldn't be patched (implements Em ?) - but i created a patch myself with the additional parameter. This works, as long as i turn realurl off - because: The preview uses the L Parameter, that doesn't get encoded - works not. The email uses the tx_newsletter_p[L] Parameter - works because it uses the default language of the page. But maybe thats an error in my realurl conf.

Conclusion: Bug of the missing Language Parameter is fixed by this edit. If I can confirm the bug with realurl I'll open a new ticket. Thanks