From 33fb226abf8f10ee4d75ac1af7a7cb684b318efb Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 13 Jan 2006 20:13:58 +0000 Subject: [PATCH] * Add wfClone() wrapper since we're still using PHP 4 on some servers. --- RELEASE-NOTES | 1 + includes/GlobalFunctions.php | 13 +++++++++++++ includes/Linker.php | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 54891e6c9d..306f09cb32 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -481,6 +481,7 @@ fully support the editing toolbar, but was found to be too confusing. page view (comes after parser cache, if used). Patch by ThomasV. * Linker::formatComment corrupted the passed title object on PHP 5 if the comment included a section link. Use clone() to make a safe copy. +* Add wfClone() wrapper since we're still using PHP 4 on some servers. === Caveats === diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 9349499a02..1e850e777f 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -111,6 +111,19 @@ if ( !function_exists( 'array_diff_key' ) ) { if ( ! function_exists( 'ctype_alnum' ) ) require_once 'compatability/ctype.php'; +/** + * Wrapper for clone() for PHP 4, for the moment. + * PHP 5 won't let you declare a 'clone' function, even conditionally, + * so it has to be a wrapper with a different name. + */ +function wfClone( $object ) { + // WARNING: clone() is not a function in PHP 5, so function_exists fails. + if( version_compare( PHP_VERSION, '5.0' ) < 0 ) { + return $object; + } else { + return clone( $object ); + } +} /** * Where as we got a random seed diff --git a/includes/Linker.php b/includes/Linker.php index ffe062e354..9ac52a2ab6 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -694,7 +694,7 @@ class Linker { # This is hackish but should work in most cases. $section = str_replace( '[[', '', $section ); $section = str_replace( ']]', '', $section ); - $sectionTitle = clone( $title ); + $sectionTitle = wfClone( $title ); $sectionTitle->mFragment = $section; $link = $this->makeKnownLinkObj( $sectionTitle, wfMsg( 'sectionlink' ) ); } -- 2.20.1