r40626 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r40625‎ | r40626 | r40627 >
Date:22:53, 8 September 2008
Author:simetrical
Status:old
Tags:
Comment:
(bug 15528) Don't fail fatally on invalid titles

This is a corollary to r40496, which didn't restore the behavior of make*LinkObj() on being passed a non-Title, only link().
Modified paths:
  • /trunk/phase3/includes/Linker.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Linker.php
@@ -305,6 +305,11 @@
306306 }
307307
308308 private function linkText( $target ) {
 309+ # We might be passed a non-Title by make*LinkObj(). Fail gracefully.
 310+ if( !$target instanceof Title ) {
 311+ return '';
 312+ }
 313+
309314 # If the target is just a fragment, with no title, we return the frag-
310315 # ment text. Otherwise, we return the title text itself.
311316 if( $target->getPrefixedText() === '' and $target->getFragment() !== '' ) {
@@ -426,7 +431,7 @@
427432 * the end of the link.
428433 * @param $prefix String: optional prefix. As trail, only before instead of after.
429434 */
430 - function makeLinkObj( Title $nt, $text= '', $query = '', $trail = '', $prefix = '' ) {
 435+ function makeLinkObj( $nt, $text= '', $query = '', $trail = '', $prefix = '' ) {
431436 global $wgUser;
432437 wfProfileIn( __METHOD__ );
433438
@@ -458,7 +463,7 @@
459464 * @param $style String: style to apply - if empty, use getInternalLinkAttributesObj instead
460465 * @return the a-element
461466 */
462 - function makeKnownLinkObj( Title $title, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '', $style = '' ) {
 467+ function makeKnownLinkObj( $title, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '', $style = '' ) {
463468 wfProfileIn( __METHOD__ );
464469
465470 if ( $text == '' ) {
@@ -490,7 +495,7 @@
491496 * be included in the link text. Other characters will be appended after
492497 * the end of the link.
493498 */
494 - function makeBrokenLinkObj( Title $title, $text = '', $query = '', $trail = '', $prefix = '' ) {
 499+ function makeBrokenLinkObj( $title, $text = '', $query = '', $trail = '', $prefix = '' ) {
495500 wfProfileIn( __METHOD__ );
496501
497502 list( $inside, $trail ) = Linker::splitTrail( $trail );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r40496Don't fail fatally when Linker::link() is passed a non-object...simetrical15:35, 5 September 2008