r87955 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r87954‎ | r87955 | r87956 >
Date:09:28, 13 May 2011
Author:ialex
Status:ok
Tags:
Comment:
Use Article::doEdit(), much, much easier
Modified paths:
  • /trunk/phase3/tests/phpunit/includes/search/SearchEngineTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/search/SearchEngineTest.php
@@ -84,8 +84,7 @@
8585 $dbw = $this->db;
8686 $title = Title::newFromText( $pageName );
8787
88 - $userId = 0;
89 - $userText = 'WikiSysop';
 88+ $user = User::newFromName( 'WikiSysop' );
9089 $comment = 'Search Test';
9190
9291 // avoid memory leak...?
@@ -93,41 +92,8 @@
9493 $linkCache->clear();
9594
9695 $article = new Article( $title );
97 - $pageId = $article->getId();
98 - $created = false;
99 - if ( $pageId == 0 ) {
100 - # must create the page...
101 - $pageId = $article->insertOn( $dbw );
102 - $created = true;
103 - }
 96+ $article->doEdit( $text, $comment, 0, false, $user );
10497
105 - # FIXME: Use original rev_id optionally (better for backups)
106 - # Insert the row
107 - $revision = new Revision( array(
108 - 'page' => $pageId,
109 - 'text' => $text,
110 - 'comment' => $comment,
111 - 'user' => $userId,
112 - 'user_text' => $userText,
113 - 'timestamp' => 0,
114 - 'minor_edit' => false,
115 - ) );
116 - $revId = $revision->insertOn( $dbw );
117 - $changed = $article->updateIfNewerOn( $dbw, $revision );
118 -
119 - $GLOBALS['wgTitle'] = $title;
120 - if ( $created ) {
121 - Article::onArticleCreate( $title );
122 - $article->createUpdates( $revision );
123 - } elseif ( $changed ) {
124 - Article::onArticleEdit( $title );
125 - $article->editUpdates(
126 - $text, $comment, false, 0, $revId );
127 - }
128 -
129 - $su = new SearchUpdate( $article->getId(), $pageName, $text );
130 - $su->doUpdate();
131 -
13298 $this->pageList[] = array( $title, $article->getId() );
13399
134100 return true;

Follow-up revisions

RevisionCommit summaryAuthorDate
r87956Follow-up r87955: fix commentialex09:30, 13 May 2011

Status & tagging log