#328 Deprecated: Function set_magic_quotes_runtime()

5.0
closed
nobody
None
5
2013-03-20
2009-10-18
Anonymous
No

Deprecated: Function set_magic_quotes_runtime() is deprecated in class.phpmailer.php on line 1244

I am on PHP5.3 Windows XP

Discussion


  • Anonymous
    2009-10-23

    I spent quite some time on this one. I'm using a custom error function and running on E_STRICT. I had to debug almost line by line to find the culprit.

    I just commented out the offending lines. Attaching patch #2884418

    Best,
    Rubén

     
  • Patrickz
    Patrickz
    2009-12-01

    get_magic_quotes_runtime(): "This function has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 6.0.0. Relying on this feature is highly discouraged."

    Change if (PHP_VERSION < 6) to if (PHP_VERSION < 5.3)

    So. Function EncodeFile() cloud change to

    private function EncodeFile($path, $encoding = 'base64') {
    try {
    if (!is_readable($path)) {
    throw new phpmailerException($this->Lang('file_open') . $path, self::STOP_CONTINUE);
    }
    if (function_exists('get_magic_quotes')) {
    function get_magic_quotes() {
    return false;
    }
    }
    if (PHP_VERSION < 5.3) {
    $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 < 5.3) { set_magic_quotes_runtime($magic_quotes); }
    return $file_buffer;
    } catch (Exception $e) {
    $this->SetError($e->getMessage());
    return '';
    }

     

  • Anonymous
    2010-09-29

    Another solution is this:

    if (PHP_VERSION < 6) {
    $magic_quotes = get_magic_quotes_runtime();
    ini_set("magic_quotes_runtime", 0);
    }
    $file_buffer = file_get_contents($path);
    $file_buffer = $this->EncodeString($file_buffer, $encoding);
    fclose($fd);
    if (PHP_VERSION < 6) { ini_set("magic_quotes_runtime", $magic_quotes); }
    return $file_buffer;
    }

     
  • Checking PHP_VERSION does not prevent "deprecated" warnings and stops me from using this excellent class when I should return JSON to client.

    I suggest to add @ in front of deprecated calls to skip warnings.

     
  • ini_set() is definitely good as well )

     
  • Marcus Bointon
    Marcus Bointon
    2013-03-20

    Fixed in later versions

     
  • Marcus Bointon
    Marcus Bointon
    2013-03-20

    • status: open --> closed
    • milestone: --> 5.0