Index: trunk/phase3/includes/Title.php |
— | — | @@ -3093,7 +3093,12 @@ |
3094 | 3094 | } |
3095 | 3095 | |
3096 | 3096 | /** |
3097 | | - * Check if page exists |
| 3097 | + * Check if page exists. For historical reasons, this function simply |
| 3098 | + * checks for the existence of the title in the page table, and will |
| 3099 | + * thus return false for interwiki links, special pages and the like. |
| 3100 | + * If you want to know if a title can be meaningfully viewed, you should |
| 3101 | + * probably call the isKnown() method instead. |
| 3102 | + * |
3098 | 3103 | * @return \type{\bool} TRUE or FALSE |
3099 | 3104 | */ |
3100 | 3105 | public function exists() { |
— | — | @@ -3101,24 +3106,54 @@ |
3102 | 3107 | } |
3103 | 3108 | |
3104 | 3109 | /** |
3105 | | - * Do we know that this title definitely exists, or should we otherwise |
3106 | | - * consider that it exists? |
| 3110 | + * Should links to this title be shown as potentially viewable (i.e. as |
| 3111 | + * "bluelinks"), even if there's no record by this title in the page |
| 3112 | + * table? |
3107 | 3113 | * |
| 3114 | + * This function is semi-deprecated for public use, as well as somewhat |
| 3115 | + * misleadingly named. You probably just want to call isKnown(), which |
| 3116 | + * calls this function internally. |
| 3117 | + * |
3108 | 3118 | * @return \type{\bool} TRUE or FALSE |
3109 | 3119 | */ |
3110 | 3120 | public function isAlwaysKnown() { |
3111 | | - // If the page is form Mediawiki:message/lang, calling wfMsgWeirdKey causes |
3112 | | - // the full l10n of that language to be loaded. That takes much memory and |
3113 | | - // isn't needed. So we strip the language part away. |
3114 | | - // Also, extension messages which are not loaded, are shown as red, because |
3115 | | - // we don't call MessageCache::loadAllMessages. |
3116 | | - list( $basename, /* rest */ ) = explode( '/', $this->mDbkeyform, 2 ); |
3117 | | - return $this->isExternal() |
3118 | | - || ( $this->mNamespace == NS_MAIN && $this->mDbkeyform == '' ) |
3119 | | - || ( $this->mNamespace == NS_MEDIAWIKI && wfMsgWeirdKey( $basename ) ); |
| 3121 | + if( $this->mInterwiki != '' ) { |
| 3122 | + return true; // any interwiki link might be viewable, for all we know |
| 3123 | + } |
| 3124 | + switch( $this->mNamespace ) { |
| 3125 | + case NS_MEDIA: |
| 3126 | + case NS_FILE: |
| 3127 | + return wfFindFile( $this ); // file exists, possibly in a foreign repo |
| 3128 | + case NS_SPECIAL: |
| 3129 | + return SpecialPage::exists( $this->getDBKey() ); // valid special page |
| 3130 | + case NS_MAIN: |
| 3131 | + return $this->mDbkeyform == ''; // selflink, possibly with fragment |
| 3132 | + case NS_MEDIAWIKI: |
| 3133 | + // If the page is form Mediawiki:message/lang, calling wfMsgWeirdKey causes |
| 3134 | + // the full l10n of that language to be loaded. That takes much memory and |
| 3135 | + // isn't needed. So we strip the language part away. |
| 3136 | + // Also, extension messages which are not loaded, are shown as red, because |
| 3137 | + // we don't call MessageCache::loadAllMessages. |
| 3138 | + list( $basename, /* rest */ ) = explode( '/', $this->mDbkeyform, 2 ); |
| 3139 | + return wfMsgWeirdKey( $basename ); // known system message |
| 3140 | + default: |
| 3141 | + return false; |
| 3142 | + } |
3120 | 3143 | } |
3121 | 3144 | |
3122 | 3145 | /** |
| 3146 | + * Does this title refer to a page that can (or might) be meaningfully |
| 3147 | + * viewed? In particular, this function may be used to determine if |
| 3148 | + * links to the title should be rendered as "bluelinks" (as opposed to |
| 3149 | + * "redlinks" to non-existent pages). |
| 3150 | + * |
| 3151 | + * @return \type{\bool} TRUE or FALSE |
| 3152 | + */ |
| 3153 | + public function isKnown() { |
| 3154 | + return $this->exists() || $this->isAlwaysKnown(); |
| 3155 | + } |
| 3156 | + |
| 3157 | + /** |
3123 | 3158 | * Update page_touched timestamps and send squid purge messages for |
3124 | 3159 | * pages linking to this title. May be sent to the job queue depending |
3125 | 3160 | * on the number of links. Typically called on create and delete. |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -399,6 +399,8 @@ |
400 | 400 | new pages in the recent changes IRC feed |
401 | 401 | * Ugly tooltips in Special:Statistics were phased out in favor of more direct |
402 | 402 | information. Went ahead and rewrote SpecialStatistics to subclass SpecialPage |
| 403 | +* (bug 5506) Links to files on foreign repositories are now shown consistently |
| 404 | + as bluelinks e.g. in logs and edit summaries |
403 | 405 | |
404 | 406 | === API changes in 1.14 === |
405 | 407 | |