Make WordPress Core

Opened 15 years ago

Closed 13 years ago

Last modified 7 years ago

#9394 closed defect (bug) (fixed)

set_magic_quotes_runtime deprecated in PHP 5.3

Reported by: sojweb's profile sojweb Owned by: sojweb's profile sojweb
Milestone: 3.3 Priority: low
Severity: minor Version: 2.8.1
Component: Warnings/Notices Keywords:
Focuses: Cc:


In PHP 5.3, the set_magic_quotes_runtime() function in wp-settings.php has been deprecated and gives an error. I propose two ways of addressing this, one to simply suppress the error, another to do a version test. The version test method would be better should the function ever be removed from PHP.

Attachments (2)

version-test.patch (496 bytes) - added by sojweb 15 years ago.
suppress.patch (446 bytes) - added by sojweb 15 years ago.

Download all attachments as: .zip

Change History (22)

15 years ago

#1 in reply to: ↑ description @sojweb
15 years ago

Meant to add this in the original description: Magic quotes are disabled by default in 5.3, and removed in PHP 6

#2 @sojweb
15 years ago

  • Owner changed from anonymous to sojweb

#3 @sojweb
15 years ago

This is definitely related to #8701. But given that support will be completely removed for this at some point, playing around with error reporting levels is, at best, a temporary fix. Probably the only way to handle it properly is to break backward compatibility, do version testing, or create the wp-settings.php file at install time with the appropriate code.

#4 follow-up: @azaozz
15 years ago

How about testing for "features"? Easy enough to do here:

if ( function_exists('set_magic_quotes_runtime')

#5 in reply to: ↑ 4 @jacobsantos
15 years ago

Replying to azaozz:

How about testing for "features"? Easy enough to do here:

if ( function_exists('set_magic_quotes_runtime')

This does not cover deprecated. PHP6 isn't going to be released in a while, so covering support for it now, doesn't seem like a good idea.

#6 @sojweb
15 years ago

I think I have a better solution; I will post it later today.

#7 @sojweb
15 years ago

Perhaps a more comprehensive solution here: #8701

#8 @Denis-de-Bernardy
15 years ago

  • Milestone changed from Unassigned to 2.8
  • Severity changed from normal to major

hasn't this been fixed in trunk via #8701?

#9 @Denis-de-Bernardy
15 years ago

  • Resolution set to duplicate
  • Status changed from new to closed

closing as dup of #8701

#10 @lloydbudd
15 years ago

  • Component changed from General to Warnings/Notices
  • Milestone changed from 2.8 to Future Release
  • Priority changed from normal to low
  • Resolution duplicate deleted
  • Severity changed from major to minor
  • Status changed from closed to reopened
  • Version changed from 2.7.1 to 2.8.1

#8701 would seem to just hide the issue of using the deprecated function, not fix the issue. Reopening.

$ ack set_magic_quotes_runtime -l

#11 @Denis-de-Bernardy
14 years ago

  • Keywords php 5.3 set_magic_quotes_runtime has-patch tested removed

in this case it should version compare < 5.3

#12 @mark-k
14 years ago

  • Cc mark-k added

Just encountered this issue. caused the firestats plugin not to work because the deprecation notice was output into the JS file it generates on the fly. I would suggest to bump up the priority/severity of this bug.

#13 @nacin
14 years ago

Why is it outputting JS on the fly? admin-ajax? wp_localize_script?

E_DEPRECATED is silenced by WP. I consider this ticket wontfix.

#14 @Ipstenu
13 years ago

Looks like it blows up in PHP6 (per hearsay reports - the evidence is circumstantial.)

#15 @nacin
13 years ago

PHP6 development was moved to a branch some time ago because Unicode support was too difficult to implement. We won't be needing to make a decision on this for a few years.

#16 @azizur
13 years ago

  • Cc azizur added

I am on PHP Version 5.3.5 and it just showed up. Would be nice to have this resolved.

Last edited 13 years ago by azizur (previous) (diff)

#17 @wonderboymusic
13 years ago

it would be nice to not have this in the logs on every single request ( when error_reporting(-1) is set )

I don’t understand the hesitance to just switch to ini_set? The next line does it properly:

Disable magic quotes at runtime. Magic quotes are added using wpdb later in wp-settings.php.
set_magic_quotes_runtime( 0 );
@ini_set( 'magic_quotes_sybase', 0 );

Version 0, edited 13 years ago by wonderboymusic (next)

#18 @Viper007Bond
13 years ago

  • Milestone changed from Future Release to 3.3
  • Resolution set to fixed
  • Status changed from reopened to closed

Fixed in [18549].

#19 @hakre
13 years ago

Thanks for fixing. Just ran over it, changed a 3.2.1 install, fixed my warning issue.

#20 @natalisilverio
7 years ago

Hello guys

I was performing a compatibility test with PHP Code Sniffer using PHPCompatibility / PHPCompatibility for migrating to PHP 7 and I've got the errors bellow. Once this error was fixed in [18549] I believe it is something that I do not need to be concerned about. Anyway I wanted to check if anyone had any issue with class-pclzip.php running on a PHP 7.

Thank you

[1mFILE: ...rowdyhouse/crowdyhouse-github/wp-admin/includes/class-pclzip.php[0m
 5345 | [31mERROR[0m | [1mFunction set_magic_quotes_runtime() is deprecated since
      |       | PHP 5.3 and removed since PHP 7.0[0m
      |       | (PHPCompatibility.PHP.DeprecatedFunctions.set_magic_quotes_runtimeDeprecatedRemoved)
 5376 | [31mERROR[0m | [1mFunction set_magic_quotes_runtime() is deprecated since
      |       | PHP 5.3 and removed since PHP 7.0[0m
      |       | (PHPCompatibility.PHP.DeprecatedFunctions.set_magic_quotes_runtimeDeprecatedRemoved)
Note: See TracTickets for help on using tickets.