* @param $text String Text with possible redirect
* @return Array of Titles, with the destination last
* @deprecated since 1.WD, use Content::getRedirectChain instead.
- * @todo: migrate this logic into WikitextContent!
*/
public static function newFromRedirectArray( $text ) {
$content = ContentHandler::makeContent( $text, null, CONTENT_MODEL_WIKITEXT );
$linkCache = LinkCache::singleton();
$cached = $linkCache->getGoodLinkFieldObj( $this, 'redirect' );
- assert( $cached !== null ); # assert the assumption that the cache actually knows about this title #XXX breaks stuff #TODO: use exception
+ if ( $cached === null ) { # check the assumption that the cache actually knows about this title
+ # XXX: this does apparently happen, see https://bugzilla.wikimedia.org/show_bug.cgi?id=37209
+ # as a stop gap, perhaps log this, but don't throw an exception?
+ throw new MWException( "LinkCache doesn't currently know about this title: " . $this->getPrefixedDBkey() );
+ }
$this->mRedirect = (bool)$cached;
}
$linkCache = LinkCache::singleton();
$cached = $linkCache->getGoodLinkFieldObj( $this, 'length' );
- assert( $cached !== null ); # assert the assumption that the cache actually knows about this title #TODO: use exception
+ if ( $cached === null ) { # check the assumption that the cache actually knows about this title
+ # XXX: this does apparently happen, see https://bugzilla.wikimedia.org/show_bug.cgi?id=37209
+ # as a stop gap, perhaps log this, but don't throw an exception?
+ throw new MWException( "LinkCache doesn't currently know about this title: " . $this->getPrefixedDBkey() );
+ }
$this->mLength = intval( $cached );
}
$linkCache = LinkCache::singleton();
$cached = $linkCache->getGoodLinkFieldObj( $this, 'revision' );
- assert( $cached !== null ); # assert the assumption that the cache actually knows about this title #TODO: use exception
+ if ( $cached === null ) { # check the assumption that the cache actually knows about this title
+ # XXX: this does apparently happen, see https://bugzilla.wikimedia.org/show_bug.cgi?id=37209
+ # as a stop gap, perhaps log this, but don't throw an exception?
+ throw new MWException( "LinkCache doesn't currently know about this title: " . $this->getPrefixedDBkey() );
+ }
$this->mLatestID = intval( $cached );
$hook_ok = wfRunHooks( 'ArticleContentSave', array( &$this, &$user, &$content, &$summary,
$flags & EDIT_MINOR, null, null, &$flags, &$status ) );
- if ( $hook_ok && !empty( $wgHooks['ArticleSave'] ) ) { #FIXME: use wfHasHook or whatever. # avoid serialization overhead if the hook isn't present
+ if ( $hook_ok && Hooks::isRegistered( 'ArticleSave' ) ) { # avoid serialization overhead if the hook isn't present
$content_text = $content->serialize();
$txt = $content_text; # clone
$changed = !$content->equals( $old_content );
if ( $changed ) {
- // TODO: validate!
- if ( $content->isValid() ) {
- #XXX: do it! throw exception??
+ if ( !$content->isValid() ) {
+ throw new MWException( "New content failed validity check!" );
}
$dbw->begin( __METHOD__ );
$edit->newContent = $content;
$edit->oldContent = $this->getContent( Revision::RAW );
- $edit->newText = ContentHandler::getContentText( $edit->newContent ); #FIXME: B/C only! don't use this field!
- $edit->oldText = $edit->oldContent ? ContentHandler::getContentText( $edit->oldContent ) : ''; #FIXME: B/C only! don't use this field!
+ #NOTE: B/C for hooks! don't use these fields!
+ $edit->newText = ContentHandler::getContentText( $edit->newContent );
+ $edit->oldText = $edit->oldContent ? ContentHandler::getContentText( $edit->oldContent ) : '';
$this->mPreparedEdit = $edit;
}
if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
- $msgtext = ContentHandler::getContentText( $content ); #XXX: could skip pseudo-messages like js/css here, based on content model.
+ $msgtext = $content->getWikitextForTransclusion(); #XXX: could skip pseudo-messages like js/css here, based on content model.
if ( $msgtext === false || $msgtext === null ) $msgtext = '';
MessageCache::singleton()->replace( $shortTitle, $msgtext );
'length' => $content->getSize(),
'comment' => $comment,
'minor_edit' => $minor ? 1 : 0,
- ) ); #XXX: set the content object
+ ) ); #XXX: set the content object?
$revision->insertOn( $dbw );
$this->updateRevisionOn( $dbw, $revision );