r68081 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68080‎ | r68081 | r68082 >
Date:15:49, 15 June 2010
Author:nikerabbit
Status:ok
Tags:
Comment:
Prevent delete action also, and refine conditions for old/new/stuck pages
Modified paths:
  • /trunk/extensions/Translate/tag/PageTranslationHooks.php (modified) (history)
  • /trunk/extensions/Translate/tag/SpecialPageTranslation.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/tag/SpecialPageTranslation.php
@@ -59,6 +59,7 @@
6060 if ( $revision === -1 ) {
6161 $page = TranslatablePage::newFromTitle( $title );
6262 $page->removeTags();
 63+ $page->getTitle()-invalidateCache();
6364 global $wgUser;
6465 $logger = new LogPage( 'pagetranslation' );
6566 $params = array( 'user' => $wgUser->getName() );
@@ -166,18 +167,14 @@
167168 // Pages where mark <= tag
168169 $items = array();
169170 foreach ( $pages as $index => $page ) {
170 - if ( !isset( $page['tp:mark'] ) ) {
 171+ if ( !isset( $page['tp:mark'] ) || !isset( $page['tp:tag'] ) ) {
171172 continue;
172173 }
173174
174 - if ( !isset( $page['tp:tag'] ) ) {
 175+ if ( $page['tp:tag'] !== $page['title']->getLatestRevID() ) {
175176 continue;
176177 }
177178
178 - if ( $page['tp:mark'] > $page['tp:tag'] ) {
179 - continue;
180 - }
181 -
182179 $link = $this->user->getSkin()->link( $page['title'] );
183180 $acts = $this->actionLinks( $page['title'], $page['tp:mark'], 'old' );
184181 $items[] = "<li>$link ($acts) </li>";
@@ -193,16 +190,19 @@
194191 // Pages which are never marked
195192 $items = array();
196193 foreach ( $pages as $index => $page ) {
197 - if ( isset( $page['tp:mark'] ) ) {
 194+ if ( isset( $page['tp:mark'] ) || !isset( $page['tp:tag'] ) ) {
198195 continue;
199196 }
200197
201 - if ( !isset( $page['tp:tag'] ) ) {
 198+ /* Ignore pages which have had <translate> at some point, but which
 199+ * have never been marked. */
 200+ if ( $page['title']->getLatestRevID() !== $page['tp:tag'] ) {
 201+ unset( $pages[$index] );
202202 continue;
203203 }
204204
205205 $link = $this->user->getSkin()->link( $page['title'] );
206 - $acts = $this->actionLinks( $page['title'], $page['tp:tag'], 'old' );
 206+ $acts = $this->actionLinks( $page['title'], $page['tp:tag'], 'new' );
207207 $items[] = "<li>$link ($acts) </li>";
208208
209209 unset( $pages[$index] );
@@ -497,6 +497,7 @@
498498 );
499499 $logger->addEntry( 'mark', $page->getTitle(), null, array( serialize( $params ) ) );
500500
 501+ $page->getTitle()-invalidateCache();
501502 $this->setupRenderJobs( $page );
502503
503504 // Re-generate caches
Index: trunk/extensions/Translate/tag/PageTranslationHooks.php
@@ -343,7 +343,7 @@
344344
345345 return false;
346346 }
347 - } elseif ( $action === 'move' ) {
 347+ } elseif ( $action === 'move' || $action === 'delete' ) {
348348 $page = TranslatablePage::newFromTitle( $title );
349349 if ( $page->getMarkedTag() ) {
350350 $result = array( 'tpt-move-impossible' );

Status & tagging log