← Back to team overview

phpdevshell team mailing list archive

[Bug 856746] Re: PHP_VERSION check bug in class.phpmailer.php

 

** Changed in: phpdevshell
       Status: Confirmed => Fix Committed

-- 
You received this bug notification because you are a member of
PHPDevShell, which is subscribed to PHPDevShell.
https://bugs.launchpad.net/bugs/856746

Title:
  PHP_VERSION check bug in class.phpmailer.php

Status in Open Source PHP RAD Framework with UI.:
  Fix Committed

Bug description:
  Both the legacy mailer and new plugin mailer has a PHP version check
  bug. This is not a PHPDevShell specific bug but rather a bug with the
  PHPMailer class used by PHPDevShell (class.phpmailer.php).

  The issue start on line 1348:

        if (PHP_VERSION < 6) {

          $magic_quotes = get_magic_quotes_runtime();

          set_magic_quotes_runtime(0);

        }

        $file_buffer  = file_get_contents($path);

        $file_buffer  = $this->EncodeString($file_buffer, $encoding);

        if (PHP_VERSION < 6) { set_magic_quotes_runtime($magic_quotes);
  }

  
  Doing a version check using the method above doesn't always work since the PHP_VERSION constant is not always a valid number. When using Ubuntu for example the PHP_VERSION constant will return a string that looks something like this: 5.3.2-1ubuntu4.7

  As with the rest of PHPDevShell's code the PHP version_compare()
  function should be used instead. In the case above the version check
  is done because the set_magic_quotes_runtime() function has been
  deprecated. However, the function has already been deprecated from
  version 5.3.0 meaning that the comparison should be done against PHP
  v5.3.0 instead of version 6.

  I recommend that the code above should be changed to:
        if (version_compare(PHP_VERSION, '5.3.0', '<')) {
          $magic_quotes = get_magic_quotes_runtime();
          set_magic_quotes_runtime(0);
        }
        $file_buffer  = file_get_contents($path);
        $file_buffer  = $this->EncodeString($file_buffer, $encoding);
        if (version_compare(PHP_VERSION, '5.3.0', '<')) { set_magic_quotes_runtime($magic_quotes); }

  I also recommend that the author of the PHPMailer class should be
  notified of this problem or it should at least be checked if there
  isn't a later version of the PHPMailer class.

  The bug needs to be fixed in both the following files:
  includes/legacy/phpmailer/class.phpmailer.php
  plugins/PHPMailer/resources/class.phpmailer.php

  
  PHPDevShell version: V 3.0.4-Stable
  Browser: Firefox v 4.0.1
  OS: Ubuntu 10.04 LTS
  Kernel: Linux 2.6.32-28
  PHP Version: 5.3.2
  MySQL Version: 5.1.41
  Apache: 2.2.14

To manage notifications about this bug go to:
https://bugs.launchpad.net/phpdevshell/+bug/856746/+subscriptions


References