r10322 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r10321‎ | r10322 | r10323 >
Date:23:21, 30 July 2005
Author:salvatoreingala
Status:old
Tags:
Comment:
added logging and renamed database field
Modified paths:
  • /branches/SHOW_VERIFIED/phase3/includes/Article.php (modified) (history)
  • /branches/SHOW_VERIFIED/phase3/includes/LogPage.php (modified) (history)
  • /branches/SHOW_VERIFIED/phase3/includes/PageHistory.php (modified) (history)
  • /branches/SHOW_VERIFIED/phase3/includes/SkinTemplate.php (modified) (history)
  • /branches/SHOW_VERIFIED/phase3/includes/Title.php (modified) (history)
  • /branches/SHOW_VERIFIED/phase3/languages/Language.php (modified) (history)
  • /branches/SHOW_VERIFIED/phase3/maintenance/archives/patch-page_verified_rev.sql (added) (history)
  • /branches/SHOW_VERIFIED/phase3/maintenance/tables.sql (modified) (history)
  • /branches/SHOW_VERIFIED/phase3/maintenance/updaters.inc (modified) (history)

Diff [purge]

Index: branches/SHOW_VERIFIED/phase3/maintenance/archives/patch-page_verified_rev.sql
@@ -0,0 +1,6 @@
 2+-- rev_id of the verified revision. This is needed
 3+-- for the 'verify' feature.
 4+-- Added 2005-07-23
 5+
 6+ALTER TABLE /*$wgDBprefix*/page
 7+ ADD page_verified_rev int(8) unsigned NOT NULL
Property changes on: branches/SHOW_VERIFIED/phase3/maintenance/archives/patch-page_verified_rev.sql
___________________________________________________________________
Added: svn:eol-style
18 + native
Added: svn:keywords
29 + Author Date Id Revision
Index: branches/SHOW_VERIFIED/phase3/maintenance/updaters.inc
@@ -30,27 +30,27 @@
3131
3232 $wgNewFields = array(
3333 # table field patch file (in maintenance/archives)
34 - array( 'ipblocks', 'ipb_id', 'patch-ipblocks.sql' ),
35 - array( 'ipblocks', 'ipb_expiry', 'patch-ipb_expiry.sql' ),
36 - array( 'recentchanges', 'rc_type', 'patch-rc_type.sql' ),
37 - array( 'recentchanges', 'rc_ip', 'patch-rc_ip.sql' ),
38 - array( 'recentchanges', 'rc_id', 'patch-rc_id.sql' ),
39 - array( 'recentchanges', 'rc_patrolled', 'patch-rc-patrol.sql' ),
40 - array( 'user', 'user_real_name', 'patch-user-realname.sql' ),
41 - array( 'user', 'user_token', 'patch-user_token.sql' ),
42 - array( 'user', 'user_email_token', 'patch-user_email_token.sql' ),
43 - array( 'logging', 'log_params', 'patch-log_params.sql' ),
44 - array( 'archive', 'ar_rev_id', 'patch-archive-rev_id.sql' ),
45 - array( 'archive', 'ar_text_id', 'patch-archive-text_id.sql' ),
46 - array( 'page', 'page_len', 'patch-page_len.sql' ),
47 - array( 'page', 'page_idverified', 'patch-page_idverified.sql' ),
48 - array( 'revision', 'rev_deleted', 'patch-rev_deleted.sql' ),
49 - array( 'image', 'img_width', 'patch-img_width.sql' ),
50 - array( 'image', 'img_metadata', 'patch-img_metadata.sql' ),
51 - array( 'image', 'img_media_type', 'patch-img_media_type.sql' ),
52 - array( 'validate', 'val_ip', 'patch-val_ip.sql' ),
53 - array( 'site_stats', 'ss_total_pages', 'patch-ss_total_articles.sql' ),
54 - array( 'interwiki', 'iw_trans', 'patch-interwiki-trans.sql' ),
 34+ array( 'ipblocks', 'ipb_id', 'patch-ipblocks.sql' ),
 35+ array( 'ipblocks', 'ipb_expiry', 'patch-ipb_expiry.sql' ),
 36+ array( 'recentchanges', 'rc_type', 'patch-rc_type.sql' ),
 37+ array( 'recentchanges', 'rc_ip', 'patch-rc_ip.sql' ),
 38+ array( 'recentchanges', 'rc_id', 'patch-rc_id.sql' ),
 39+ array( 'recentchanges', 'rc_patrolled', 'patch-rc-patrol.sql' ),
 40+ array( 'user', 'user_real_name', 'patch-user-realname.sql' ),
 41+ array( 'user', 'user_token', 'patch-user_token.sql' ),
 42+ array( 'user', 'user_email_token', 'patch-user_email_token.sql' ),
 43+ array( 'logging', 'log_params', 'patch-log_params.sql' ),
 44+ array( 'archive', 'ar_rev_id', 'patch-archive-rev_id.sql' ),
 45+ array( 'archive', 'ar_text_id', 'patch-archive-text_id.sql' ),
 46+ array( 'page', 'page_len', 'patch-page_len.sql' ),
 47+ array( 'page', 'page_verified_rev', 'patch-page_verified_rev.sql' ),
 48+ array( 'revision', 'rev_deleted', 'patch-rev_deleted.sql' ),
 49+ array( 'image', 'img_width', 'patch-img_width.sql' ),
 50+ array( 'image', 'img_metadata', 'patch-img_metadata.sql' ),
 51+ array( 'image', 'img_media_type', 'patch-img_media_type.sql' ),
 52+ array( 'validate', 'val_ip', 'patch-val_ip.sql' ),
 53+ array( 'site_stats', 'ss_total_pages', 'patch-ss_total_articles.sql' ),
 54+ array( 'interwiki', 'iw_trans', 'patch-interwiki-trans.sql' ),
5555 );
5656
5757 function rename_table( $from, $to, $patch ) {
Index: branches/SHOW_VERIFIED/phase3/maintenance/tables.sql
@@ -194,7 +194,7 @@
195195
196196 -- Key to revision.rev_id of the revision marked as "verified"
197197 -- This is 0 if verify protection is not enabled
198 - page_idverified int(8) unsigned NOT NULL,
 198+ page_verifed_rev int(8) unsigned NOT NULL,
199199
200200 -- Uncompressed length in bytes of the page's current source text.
201201 page_len int(8) unsigned NOT NULL,
Index: branches/SHOW_VERIFIED/phase3/includes/Article.php
@@ -36,7 +36,7 @@
3737 var $mOldId;
3838 var $mRevIdFetched;
3939 var $mRevision;
40 - var $mIdVerified;
 40+ var $mVerifiedRev;
4141 /**#@-*/
4242
4343 /**
@@ -79,9 +79,10 @@
8080 * not told otherwise, and so may cause a change to mTitle.
8181 *
8282 * @param $noredir
 83+ * @param $use_verified_rev
8384 * @return Return the text of this revision
8485 */
85 - function getContent( $noredir, $use_idverified = false ) {
 86+ function getContent( $noredir, $use_verified_rev = false ) {
8687 global $wgRequest, $wgUser, $wgOut;
8788
8889 # Get variables from query string :P
@@ -108,7 +109,7 @@
109110 $wgOut->setRobotpolicy( 'noindex,nofollow' );
110111 return wfMsg( 'noarticletext' );
111112 } else {
112 - $this->loadContent( $noredir, $use_idverified );
 113+ $this->loadContent( $noredir, $use_verified_rev );
113114 # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page
114115 if ( $this->mTitle->getNamespace() == NS_USER_TALK &&
115116 $wgUser->isIP($this->mTitle->getText()) &&
@@ -151,6 +152,7 @@
152153 if($rev) {
153154 return $rev->getText();
154155 }
 156+
155157 }
156158 }
157159 return '';
@@ -275,7 +277,7 @@
276278 /**
277279 * Load the revision (including cur_text) into this object
278280 */
279 - function loadContent( $noredir = false, $use_idverified = false ) {
 281+ function loadContent( $noredir = false, $use_verified_rev = false ) {
280282 global $wgOut, $wgRequest;
281283
282284 if ( $this->mContentLoaded ) return;
@@ -294,7 +296,7 @@
295297 $noredir = $noredir || ($wgRequest->getVal( 'redirect' ) == 'no')
296298 || $wgRequest->getCheck( 'rdfrom' );
297299 $this->mOldId = $oldid;
298 - $this->fetchContent( $oldid, $noredir, true, $use_idverified );
 300+ $this->fetchContent( $oldid, $noredir, true, $use_verified_rev );
299301
300302 }
301303
@@ -318,7 +320,7 @@
319321 'page_random',
320322 'page_touched',
321323 'page_latest',
322 - 'page_idverified',
 324+ 'page_verified_rev',
323325 'page_len' ),
324326 $conditions,
325327 'Article::pageData' );
@@ -346,13 +348,13 @@
347349 $this->mTitle->loadRestrictions( $data->page_restrictions );
348350 $this->mTitle->mRestrictionsLoaded = true;
349351
350 - $this->mCounter = $data->page_counter;
351 - $this->mTouched = wfTimestamp( TS_MW, $data->page_touched );
352 - $this->mIsRedirect = $data->page_is_redirect;
353 - $this->mLatest = $data->page_latest;
354 - $this->mIdVerified = $data->page_idverified;
 352+ $this->mCounter = $data->page_counter;
 353+ $this->mTouched = wfTimestamp( TS_MW, $data->page_touched );
 354+ $this->mIsRedirect = $data->page_is_redirect;
 355+ $this->mLatest = $data->page_latest;
 356+ $this->mVerifiedRev = $data->page_verified_rev;
355357
356 - $this->mDataLoaded = true;
 358+ $this->mDataLoaded = true;
357359 }
358360
359361 /**
@@ -362,7 +364,7 @@
363365 * @param bool $globalTitle Set to true to change the global $wgTitle object when following redirects or other unexpected title changes
364366 * @return string
365367 */
366 - function fetchContent( $oldid = 0, $noredir = true, $globalTitle = false, $use_idverified = false ) {
 368+ function fetchContent( $oldid = 0, $noredir = true, $globalTitle = false, $use_verified_rev = false ) {
367369 if ( $this->mContentLoaded ) {
368370 return $this->mContent;
369371 }
@@ -403,7 +405,7 @@
404406 }
405407 $this->loadPageData( $data );
406408 }
407 - $revision = Revision::newFromId( ( $use_idverified && ($this->mIdVerified != 0 ) ) ? $this->mIdVerified : $this->mLatest );
 409+ $revision = Revision::newFromId( ( $use_verified_rev && ($this->mVerifiedRev != 0 ) ) ? $this->mVerifiedRev : $this->mLatest );
408410 if( is_null( $revision ) ) {
409411 wfDebug( "$fname failed to retrieve current page, rev_id $data->page_latest\n" );
410412 return false;
@@ -434,7 +436,7 @@
435437 }
436438 $redirData = $this->pageDataFromTitle( $dbr, $rt );
437439 if( $redirData ) {
438 - $redirRev = Revision::newFromId( ( $use_idverified && ($redirData->page_idverified != 0) ) ? $redirData->page_idverified : $redirData->page_latest );
 440+ $redirRev = Revision::newFromId( ( $use_verified_rev && ($redirData->page_verified_rev != 0) ) ? $redirData->page_verified_rev : $redirData->page_latest );
439441 if( !is_null( $redirRev ) ) {
440442 $this->mRedirectedFrom = $this->mTitle->getPrefixedText();
441443 $this->mTitle = $rt;
@@ -756,9 +758,9 @@
757759 }
758760 if ( !$outputDone ) {
759761 # Check if we must use verify protection
760 - $use_idverified = $wgEnableVerify;
 762+ $use_verified_rev = $wgEnableVerify;
761763
762 - $text = $this->getContent( false, $use_idverified ); # May change mTitle by following a redirect
 764+ $text = $this->getContent( false, $use_verified_rev ); # May change mTitle by following a redirect
763765
764766 # Another whitelist check in case oldid or redirects are altering the title
765767 if ( !$this->mTitle->userCanRead() ) {
@@ -776,7 +778,7 @@
777779
778780 # We are looking at the latest verified revision but there have been some other edits
779781 $s = '';
780 - if ( $wgEnableVerify && empty( $oldid ) && !empty( $this->mIdVerified ) && ($this->mLatest != $this->mIdVerified) ) {
 782+ if ( $wgEnableVerify && empty( $oldid ) && !empty( $this->mVerifiedRev ) && ($this->mLatest != $this->mVerifiedRev) ) {
781783 $sk = $wgUser->getSkin();
782784 $current = $sk->makeKnownLink( $this->mTitle->GetPartialURL(), '',
783785 "oldid={$this->mLatest}" );
@@ -969,7 +971,7 @@
970972 'page_random' => wfRandom(),
971973 'page_touched' => $dbw->timestamp(),
972974 'page_latest' => 0, # Fill this in shortly...
973 - 'page_idverified' => 0
 975+ 'page_verified_rev' => 0
974976 ), $fname );
975977 $newid = $dbw->insertId();
976978
@@ -1698,25 +1700,27 @@
16991701
17001702 $lastRevision = $dbw->selectField(
17011703 'page', 'page_latest', array( 'page_id' => $id ) );
1702 - $page_idverified = $dbw->selectField(
1703 - 'page', 'page_idverified', array( 'page_id' => $id ) );
 1704+ $page_verified_rev = $dbw->selectField(
 1705+ 'page', 'page_verified_rev', array( 'page_id' => $id ) );
17041706
1705 - if ( !isset($oldid) && !$page_idverified ){
 1707+ if ( !isset($oldid) && !$page_verified_rev ){
17061708 # Set verify protection
1707 - $new_idverified = $lastRevision;
1708 - } else if ( !isset($oldid) && $page_idverified ) {
 1709+ $new_verified_rev = $lastRevision;
 1710+ } else if ( !isset($oldid) && $page_verified_rev ) {
17091711 # Don't do nothing
17101712 $wgOut->redirect( $this->mTitle->getFullURL() );
17111713 return;
17121714 } else /* if isset($oldid) */ {
1713 - # Update page_idverified to the wanted revision
1714 - $new_idverified = $oldid;
 1715+ # Update page_verified_rev to the wanted revision
 1716+ $new_verified_rev = $oldid;
17151717 }
17161718
 1719+ $addEntryToLog = ( $page_verified_rev == 0 );
 1720+
17171721 $dbw->update( 'page',
17181722 array( /* SET */
17191723 'page_touched' => $dbw->timestamp(),
1720 - 'page_idverified' => $new_idverified
 1724+ 'page_verified_rev' => $new_verified_rev
17211725 ), array( /* WHERE */
17221726 'page_id' => $id
17231727 ), 'Article::verify'
@@ -1735,7 +1739,11 @@
17361740 array_push( $wgPostCommitUpdateList, $u );
17371741 }
17381742
1739 - # TODO: Add an entry to some log page
 1743+ if ( $addEntryToLog ) {
 1744+ # Add an entry to the log if the article was not verified yet
 1745+ $log = new LogPage( 'protect' );
 1746+ $log->addEntry( 'verify', $this->mTitle, "" );
 1747+ }
17401748
17411749 $wgOut->redirect( $this->mTitle->getFullURL() );
17421750
@@ -1766,7 +1774,7 @@
17671775 $dbw->update( 'page',
17681776 array( /* SET */
17691777 'page_touched' => $dbw->timestamp(),
1770 - 'page_idverified' => 0
 1778+ 'page_verified_rev' => 0
17711779 ), array( /* WHERE */
17721780 'page_id' => $id
17731781 ), 'Article::unverify'
@@ -1783,7 +1791,9 @@
17841792 array_push( $wgPostCommitUpdateList, $u );
17851793 }
17861794
1787 - # TODO: Add an entry to some log page
 1795+ # Add an entry to the log
 1796+ $log = new LogPage( 'protect' );
 1797+ $log->addEntry( 'unverify', $this->mTitle, "" );
17881798
17891799 $wgOut->redirect( $this->mTitle->getFullURL() );
17901800
Index: branches/SHOW_VERIFIED/phase3/includes/Title.php
@@ -45,7 +45,7 @@
4646 var $mLatestID; # ID of most recent revision
4747 var $mRestrictions; # Array of groups allowed to edit this article
4848 # Only null or "sysop" are supported
49 - var $mIdVerified; # page_idverified
 49+ var $mVerifiedRev; # page_verified_rev
5050 var $mRestrictionsLoaded; # Boolean for initialisation on demand
5151 var $mPrefixedText; # Text form including namespace/interwiki, initialised on demand
5252 var $mDefaultNamespace; # Namespace index when there is no namespace
@@ -865,18 +865,18 @@
866866 }
867867
868868 /**
869 - * Gets page_idverified
 869+ * Gets page_verified_rev
870870 * @return int
871871 * @access public
872872 */
873 - function getIdVerified() {
 873+ function getVerifiedRev() {
874874 $id = $this->getArticleID();
875875 if ($id == 0) return 0;
876 - if ( empty( $this->mIdVerified ) ) {
 876+ if ( empty( $this->mVerifiedRev ) ) {
877877 $dbr =& wfGetDB( DB_SLAVE );
878 - $this->mIdVerified = $dbr->selectField( 'page', 'page_idverified', array( 'page_id' => $id ) );
 878+ $this->mVerifiedRev = $dbr->selectField( 'page', 'page_verified_rev', array( 'page_id' => $id ) );
879879 }
880 - return $this->mIdVerified;
 880+ return $this->mVerifiedRev;
881881 }
882882
883883 /**
@@ -885,7 +885,7 @@
886886 * @access public
887887 */
888888 function isVerified() {
889 - return ($this->getIdVerified() != 0);
 889+ return ($this->getVerifiedRev() != 0);
890890 }
891891
892892 /**
Index: branches/SHOW_VERIFIED/phase3/includes/SkinTemplate.php
@@ -612,7 +612,7 @@
613613 }
614614
615615 if($wgEnableVerify && $wgUser->isAllowed('verify')) {
616 - if(!$this->mTitle->isVerified() || (isset($oldid) && ($oldid != $this->mTitle->getIdVerified()))) {
 616+ if(!$this->mTitle->isVerified() || (isset($oldid) && ($oldid != $this->mTitle->getVerifiedRev()))) {
617617 $oid = !isset( $oldid ) ? "" : '&oldid='.$oldid;
618618 $content_actions['verify'] = array(
619619 'class' => ($action == 'verify') ? 'selected' : false,
Index: branches/SHOW_VERIFIED/phase3/includes/PageHistory.php
@@ -251,7 +251,7 @@
252252 $s = '<li>';
253253
254254 # Print the row bold if it's the verified revision
255 - if ($wgEnableVerify && $this->mArticle->mIdVerified == $row->rev_id) $s .= '<b>';
 255+ if ($wgEnableVerify && $this->mArticle->mVerifiedRev == $row->rev_id) $s .= '<b>';
256256
257257
258258 if( $row->rev_deleted ) {
@@ -275,7 +275,7 @@
276276 }
277277 $s .= '</li>';
278278
279 - if ($wgEnableVerify && $this->mArticle->mIdVerified == $row->rev_id) $s .= '</b>';
 279+ if ($wgEnableVerify && $this->mArticle->mVerifiedRev == $row->rev_id) $s .= '</b>';
280280
281281 return $s;
282282 }
Index: branches/SHOW_VERIFIED/phase3/includes/LogPage.php
@@ -161,6 +161,8 @@
162162 'block/unblock' => 'unblocklogentry',
163163 'protect/protect' => 'protectedarticle',
164164 'protect/unprotect' => 'unprotectedarticle',
 165+ 'protect/verify' => 'verifiedarticle',
 166+ 'protect/unverify' => 'unverifiedarticle',
165167 'rights/rights' => 'bureaucratlogentry',
166168 'rights/addgroup' => 'addgrouplogentry',
167169 'rights/rngroup' => 'renamegrouplogentry',
Index: branches/SHOW_VERIFIED/phase3/languages/Language.php
@@ -1346,6 +1346,11 @@
13471347 'unprotectcomment' => 'Reason for unprotecting',
13481348 'protectreason' => '(give a reason)',
13491349
 1350+# Verify
 1351+'verifiedarticle' => 'set "[[$1]]" as verified',
 1352+'unverifiedarticle' => 'set "[[$1]]" as not verified',
 1353+
 1354+
13501355 # Undelete
13511356 'undelete' => 'Restore deleted page',
13521357 'undeletepage' => 'View and restore deleted pages',

Status & tagging log