Le 24/10/13 11:40, Max Semenik a écrit :
> Now:
>
> $title = Title::newFromText( $text );
> if ( $title ) {
> return $title->getLocalUrl( 'foo=bar' );
> }
> return null;
>
> Proposed:
>
> $tp = new TextTitleParser();
> try {
> $title = $tp->parse( $text );
> $tf = new UrlTitleFormatter( $title, 'foo=bar );
> return $tf->format();
> } catch( MWException ) {
> return null;
> }
Since I am lazy, I would want:
return Title::newFromText( $text )
->getLocalUrl( 'foo=bar ');
Aka make Title::newFromText() to always return an object having the
methods neededs, albeit when the $text does not form a title, it would
yield a NullTitle objet that has calls returning nothing (or other
NullTitle object).
Less fatal errors.
--
Antoine "hashar" Musso
_______________________________________________
Wikitech-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l