Index: trunk/phase3/includes/WikiPage.php |
— | — | @@ -54,9 +54,15 @@ |
55 | 55 | * @return WikiPage object of the appropriate type |
56 | 56 | */ |
57 | 57 | public static function factory( Title $title ) { |
58 | | - switch( $title->getNamespace() ) { |
59 | | - case NS_MEDIA: |
60 | | - throw new MWException( "NS_MEDIA is a virtual namespace" ); |
| 58 | + $ns = $title->getNamespace(); |
| 59 | + |
| 60 | + if ( $ns == NS_MEDIA ) { |
| 61 | + throw new MWException( "NS_MEDIA is a virtual namespace; use NS_FILE." ); |
| 62 | + } elseif ( $ns < 0 ) { |
| 63 | + throw new MWException( "Invalid or virtual namespace $ns given." ); |
| 64 | + } |
| 65 | + |
| 66 | + switch ( $ns ) { |
61 | 67 | case NS_FILE: |
62 | 68 | $page = new WikiFilePage( $title ); |
63 | 69 | break; |