* Add wfClone() wrapper since we're still using PHP 4 on some servers.
authorBrion Vibber <brion@users.mediawiki.org>
Fri, 13 Jan 2006 20:13:58 +0000 (20:13 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Fri, 13 Jan 2006 20:13:58 +0000 (20:13 +0000)
RELEASE-NOTES
includes/GlobalFunctions.php
includes/Linker.php

index 54891e6..306f09c 100644 (file)
@@ -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 ===
index 9349499..1e850e7 100644 (file)
@@ -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
index ffe062e..9ac52a2 100644 (file)
@@ -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' ) );
                        }