The PHPCompatibility sniffer for PHPCS flags several issues related to "Function set_magic_quotes_runtime()"

$ phpcs --standard=PHPCompatibility --runtime-set testVersion 7.1 contrib/smtp

FILE: .../docroot/modules/contrib/smtp/src/PHPMailer/PHPMailer.php
----------------------------------------------------------------------
FOUND 4 ERRORS AFFECTING 4 LINES
----------------------------------------------------------------------
1474 | ERROR | Function set_magic_quotes_runtime() is deprecated
| | since PHP 5.3 and removed since PHP 7.0
1477 | ERROR | INI directive 'magic_quotes_runtime' is deprecated
| | since PHP 5.3 and removed since PHP 5.4
1484 | ERROR | Function set_magic_quotes_runtime() is deprecated
| | since PHP 5.3 and removed since PHP 7.0
1487 | ERROR | INI directive 'magic_quotes_runtime' is deprecated
| | since PHP 5.3 and removed since PHP 5.4
----------------------------------------------------------------------

CommentFileSizeAuthor
#15 smtp-7.x-1.7-php72.patch1.22 KBsam.spinoy@gmail.com
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

click2tman created an issue. See original summary.

click2tman’s picture

Issue summary: View changes
webservant316’s picture

This is also an issue for smtp 7.x. Do we need a separate issue for that?

Also is this issue breaking? phpsnif reports an error and not a warning. Can we move to PHP71 and ignore this error?

estoyausente’s picture

I'm not sure that it would be a real problem because the code check if the PHP version is less than 5.3 before use the magic quotes:

$magic_quotes = get_magic_quotes_runtime();
      if ($magic_quotes) {
        if (version_compare(PHP_VERSION, '5.3.0', '<')) {
          set_magic_quotes_runtime(0);
        }
        else {
          ini_set('magic_quotes_runtime', 0);
        }
      }
      $file_buffer  = file_get_contents($path);
      $file_buffer  = $this->EncodeString($file_buffer, $encoding);
      if ($magic_quotes) {
        if (version_compare(PHP_VERSION, '5.3.0', '<')) {
          set_magic_quotes_runtime($magic_quotes);
        }
        else {
          ini_set('magic_quotes_runtime', $magic_quotes);
        }
      }

Furthermore, PhpMailer is an external library and I'm not sure if we have to modify...

webservant316’s picture

yes, sorry for not looking more closely. agreed this is not a problem.

estoyausente’s picture

Status: Active » Closed (won't fix)
gbisht’s picture

Status: Closed (won't fix) » Needs work

Above solution is good to removed the following error

ERROR | Function set_magic_quotes_runtime() is deprecated
| | since PHP 5.3 and removed since PHP 7.0

But in the else condition it uses ini_set('magic_quotes_runtime', 0); which is also throws error

ERROR | INI directive 'magic_quotes_runtime' is deprecated
| | since PHP 5.3 and removed since PHP 5.4

So do we have any solution for this.

u_tiwari’s picture

So i noticed this issue still exists and these errors get logged . Is it established that these errors don't have any impact on functionality of the module, if yes then can the part of the code be removed which causes these errors. Or is there any patch for this ?

Chris Matthews’s picture

Version: 8.x-1.0-beta1 » 8.x-1.x-dev
wundo’s picture

Assigned: Unassigned » wundo
Issue tags: -

  • wundo committed 5c159c5 on 8.x-1.x
    Issue #2890426 by wundo: Order the use clauses
    
  • wundo committed 820f1aa on 8.x-1.x
    Issue #2890426 by wundo: Remove mentions to magic_quotes_runtime
    
  • wundo committed 9e4b409 on 8.x-1.x
    Issue #2890426 by estoyausente, wundo, Chris Matthews: Function...
wundo’s picture

Status: Needs work » Fixed
wundo’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

sam.spinoy@gmail.com’s picture

FileSize
1.22 KB

Here's a patch for D7 that removes the offending code