Join 34,000+ subscribers and receive articles from our
blog about software quality, testing, QA and security.

From site settings as admin user email notification fails


#1

sending a test email notification from ‘site setting’ menu : observed error in log - see below

[root@lmhi-ddnmttr01b logs]# [Fri Jan 26 15:36:35 2018] [error] [client 10.9.213.74] PHP Fatal error: Using $this when not in object context in /var/www/html/testrail/vendors/swift/Swift/Message/Headers.php on line 442, referer: https://lmhi-ddnmttr01b.elektron.int.thomsonreuters.com/testrail/index.php?/admin/site_settings

line 442 is :
$ret = str_replace("’ . $this->LE . '", “”, “<$cb[1]>”);

using php 5.3.3 on redhat 6.9


#2

I would suggest contacting Gurock support via email - probably get a faster response.


#3

issue fixed by removing new code lines for php 7:

php 7 update hashed out and revert to older version as we are on php 5.3.3

   if (false !== $p = strpos($encoded_value[$key], $this->LE))
  {
    // MR - replace preg_replace.../e with preg_replace_callback to work with php7
    $cb = 'str_replace("' . $this->LE . '", "", "<$1>");';
    $encoded_value[$key] = preg_replace("/<([^>]+)>/e", $cb, $encoded_value[$key]);

// $encoded_value[$key] = preg_replace_callback("/<([^>]+)>/",
// function($cb) {
// $ret = str_replace("’ . $this->LE . '", “”, “<$cb[1]>”);
// return $ret;
// },
// $encoded_value[$key]);
}

email test notify now works !


#4

Wouldn’t it be better to us the client for non-PHP 7? :slight_smile: Not trying to be smart but it seems the easiest path rather than using the PHP7 client when your company uses PHP 5.3.3. They have installation packages got PHP 5.2, 5.3 and later, and PHP 7.