[wp-trac] Re: [WordPress Trac] #8701: WordPress throws E_DEPRECATED
notices all over the place with newer PHP 5 installs
WordPress Trac
wp-trac at lists.automattic.com
Thu Mar 26 20:25:03 GMT 2009
#8701: WordPress throws E_DEPRECATED notices all over the place with newer PHP 5
installs
-------------------------------------+--------------------------------------
Reporter: Otto42 | Owner: anonymous
Type: defect (bug) | Status: reopened
Priority: high | Milestone: 2.7.2
Component: General | Version: 2.7
Severity: blocker | Resolution:
Keywords: has-patch tested commit |
-------------------------------------+--------------------------------------
Comment(by sojweb):
I think I have a solution that will solve this problem, as well as #9394,
#3293, #3292, #667, and allow for further backwards compatibility as PHP
evolves. I've written some conditional code into wp-settings.php, wp-
db.php, and install.php, and added two files, wp-adjust.php and wp-adjust-
functions.php to the wp-admin directory that will read wp-settings.php and
wp-db.php during install and rewrite them to fix the deprecated errors, as
well as check for mysqli functionality.
It works a bit like the IE conditional code we all use for CSS. For
example, to deal with the problem in #9394, this code is in the wp-
settings.php file:
{{{
if ( function_exists('memory_get_usage') && ( (int)
@ini_get('memory_limit') < abs(intval(WP_MEMORY_LIMIT)) ) )
@ini_set('memory_limit', WP_MEMORY_LIMIT);
/** PHP **/
/** >4.4.9
**/
/** <=5.2.9
set_magic_quotes_runtime(0);
**/
set_magic_quotes_runtime(0);
/** /PHP **/
@ini_set('magic_quotes_sybase', 0);
}}}
During install, this tells wordpress to rewrite that block as a blank line
for PHP versions higher than 4.4.9, to use set_magic_quotes_runtime(0) for
versions less than 5.3. After install, the section (for me) looks like
this:
{{{
if ( function_exists('memory_get_usage') && ( (int)
@ini_get('memory_limit') < abs(intval(WP_MEMORY_LIMIT)) ) )
@ini_set('memory_limit', WP_MEMORY_LIMIT);
@ini_set('magic_quotes_sybase', 0);
}}}
All this conditional stuff is in comments, so if WordPress doesn't have
write privileges, the patch doesn't bother trying to rewrite the files,
and they behave as usual.
The only catch is that, to install, you have to visit /wp-
admin/install.php directly. You can't count on redirects to take you
there. On my test server I have PHP 5.3RC1 with strict error reporting on,
and only mysqli installed, and WordPress fails before it gets to redirect.
If I visit install.php directly, however, it works fine. Of course, there
are a million different ways around that problem, but I thought I put this
up for discussion first. Patch file attached as conditional_code.diff,
additional files uploaded in conditional_code.zip.
I haven't done extensive tests on this, so any feedback is welcome.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/8701#comment:50>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list