Handle null data return in HTMLForm
[lhc/web/wiklou.git] / includes / Title.php
index a6163f0..3fd4631 100644 (file)
@@ -248,6 +248,10 @@ class Title implements LinkTarget {
         * @return Title
         */
        public static function newFromLinkTarget( LinkTarget $linkTarget ) {
+               if ( $linkTarget instanceof Title ) {
+                       // Special case if it's already a Title object
+                       return $linkTarget;
+               }
                return self::makeTitle(
                        $linkTarget->getNamespace(),
                        $linkTarget->getText(),
@@ -268,13 +272,9 @@ class Title implements LinkTarget {
         * @return Title|null Title or null on an error.
         */
        public static function newFromText( $text, $defaultNamespace = NS_MAIN ) {
-               if ( is_object( $text ) ) {
-                       throw new InvalidArgumentException( '$text must be a string.' );
-               }
                // DWIM: Integers can be passed in here when page titles are used as array keys.
                if ( $text !== null && !is_string( $text ) && !is_int( $text ) ) {
-                       wfDebugLog( 'T76305', wfGetAllCallers( 5 ) );
-                       return null;
+                       throw new InvalidArgumentException( '$text must be a string.' );
                }
                if ( $text === null ) {
                        return null;
@@ -572,23 +572,6 @@ class Title implements LinkTarget {
                return $title;
        }
 
-       /**
-        * Extract a redirect destination from a string and return the
-        * Title, or null if the text doesn't contain a valid redirect
-        * This will recurse down $wgMaxRedirects times or until a non-redirect target is hit
-        * in order to provide (hopefully) the Title of the final destination instead of another redirect
-        *
-        * @param string $text Text with possible redirect
-        * @return Title
-        * @deprecated since 1.21, use Content::getUltimateRedirectTarget instead.
-        */
-       public static function newFromRedirectRecurse( $text ) {
-               ContentHandler::deprecated( __METHOD__, '1.21' );
-
-               $content = ContentHandler::makeContent( $text, null, CONTENT_MODEL_WIKITEXT );
-               return $content->getUltimateRedirectTarget();
-       }
-
        /**
         * Get the prefixed DB key associated with an ID
         *