Feedback error?

Got the following error today, was not showing prior to todays login:

WARNING: /home/thehostingguy/analytics.thehostingguy.com/plugins/Feedback/Feedback.php(117): Warning - Use of undefined constant PIWIK_TEST_MODE - assumed ‘PIWIK_TEST_MODE’ (this will throw an Error in a future version of PHP) - Matomo 3.12.0-b1 - Please report this message in the Matomo forums: https://forum.matomo.org (please do a search first as it might have been reported already)

Hi,

This is really weird.

Can you check if the line 117 in your plugins/Feedback/Feedback.php looks like this?

Because if so, this error could never happen as it first checks if PIWIK_TEST_MODE is defined before accessing it.

This is poor programming practice.
You should precede the return statement with an IF like so:

if (!defined(‘PIWIK_TEST_MODE’)) return false;

and then remove the test for PIWIK_TEST_MODE being defined from the return statement. That way, you’re not dependent on the execution of the implied IF statement being always left-to-right.

Hi,

I was just told that this has been fixed a few days ago:

The fix is just adding defined test.

diff --git a/plugins/Feedback/Feedback.php b/plugins/Feedback/Feedback.php
index fd796ab5df..f7cace66e6 100644
--- a/plugins/Feedback/Feedback.php
+++ b/plugins/Feedback/Feedback.php
@@ -114,7 +114,7 @@ public function getShouldPromptForFeedback()
     // needs to be protected not private for testing purpose
     protected function isDisabledInTestMode()
     {
-        return PIWIK_TEST_MODE && !Common::getRequestVar('forceFeedbackTest', false);
+        return defined('PIWIK_TEST_MODE') && PIWIK_TEST_MODE && !Common::getRequestVar('forceFeedbackTest', false);
     }
 
 }