Make WordPress Core

Opened 14 years ago

Closed 14 years ago

#17880 closed defect (bug) (fixed)

PHP4 + WordPress 3.2 = fatal error

Reported by: dd32's profile dd32 Owned by:
Milestone: 3.2 Priority: normal
Severity: normal Version: 3.2
Component: General Keywords: has-patch
Focuses: Cc:

Description

example:

Parse error: syntax error, unexpected T_VARIABLE in C:\www\wordpress-commit\wp-includes\load.php on line 564

This is caused by using PHP5 language before the php version checks have been done.

Specifically:

function wp_clone( $object ) {
	return clone $object ;
}

Changing it to:

function wp_clone( $object ) {
	return clone( $object );
}

allows PHP4 to parse the file (as it see's a function call, to a not-yet-existant function) not a unknown language construct.

This happens as load.php is included before the version checks are run. An alternate method would be to move the version checks into wp-settings.php again.

I'm not sure if/how that affects the usage of the function, but it's how it was done in WordPress 3.1

As seen on the support forums: http://wordpress.org/support/topic/error-message-mysql

Attachments (2)

17880.diff (298 bytes) - added by ryan 14 years ago.
17880.2.diff (358 bytes) - added by ryan 14 years ago.
With comment

Download all attachments as: .zip

Change History (12)

#1 @nacin
14 years ago

Let's do clone( $object ) and include a comment there.

That said, we'll need to make sure that load.php always parses for PHP4 in the future. Might be safer to move the version checks back into wp-settings.php.

#2 @szadok
14 years ago

+1 for checking php version on wp-settings.php
A solution for time being can be something like:

function wp_clone($object) {

return version_compare(phpversion(), '5.0') < 0 ? $object : clone($object);

}

#3 follow-up: @dd32
14 years ago

A solution for time being can be something like:

no version checks need to be done, as WordPress 3.2 requires PHP 5.2.4.

The point of this is that we need files loaded before the version check to conform to the PHP4 Language constructs (and clone $x is a PHP5 syntax, whereas, clone( $x ) is a PHP4 syntax)

Last edited 14 years ago by dd32 (previous) (diff)

#4 @nacin
14 years ago

We could also move the PHP check to before wp-settings. I'm thinking wp-load, even. Needs to be run anyway, why not as early as possible?

#5 in reply to: ↑ 3 @szadok
14 years ago

So the function above is the solution, I think
Replying to dd32:

A solution for time being can be something like:

no version checks need to be done, as WordPress 3.2 requires PHP 5.2.4.

The point of this is that we need files loaded before the version check to conform to the PHP4 Language constructs (and clone $x is a PHP5 syntax, whereas, clone( $x ) is a PHP4 syntax)

#6 @dd32
14 years ago

We could also move the PHP check to before wp-settings. I'm thinking wp-load, even. Needs to be run anyway, why not as early as possible?

That's a long term solution. There's no real need to have the check done after more files load. It'll require juggling of version.php include as well (since that's got the version no's).

Personally I'd just say throw the parenthesis in for 3.2, and take a look at the loading order for 3.3.

#7 @nacin
14 years ago

szadok: Well, no. We're not supporting PHP4 anymore. So the issue has nothing to do with when that function runs (the script will die out in wp_check_php_mysql_versions(), but rather when the function is parsed. clone $object won't parse in PHP4.

dd32: That's perfectly fine.

@ryan
14 years ago

#8 @ryan
14 years ago

  • Keywords has-patch added

@ryan
14 years ago

With comment

#9 @ryan
14 years ago

In [18339]:

Avoid PHP 4 parse error prior to version checks. Props dd32. see #17880

#10 @ryan
14 years ago

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.