http://www.mediawiki.org/wiki/Special:Code/MediaWiki/68860
Revision: 68860 Author: yaron Date: 2010-07-01 23:53:42 +0000 (Thu, 01 Jul 2010) Log Message: ----------- Fixed path, changed class name, script only affects pages with no approved revision, script ignores pages in unhandled namespaces, changed output Modified Paths: -------------- trunk/extensions/ApprovedRevs/maintenance/approveAllPages.php Modified: trunk/extensions/ApprovedRevs/maintenance/approveAllPages.php =================================================================== --- trunk/extensions/ApprovedRevs/maintenance/approveAllPages.php 2010-07-01 23:51:38 UTC (rev 68859) +++ trunk/extensions/ApprovedRevs/maintenance/approveAllPages.php 2010-07-01 23:53:42 UTC (rev 68860) @@ -1,7 +1,8 @@ <?php /** - * This script approves all current revisions. + * This script approves the current revision of all pages that are in an + * approvable namespace, and do not already have an approved revision. * * Usage: * no parameters @@ -25,17 +26,18 @@ * @ingroup Maintenance */ -require_once( dirname( __FILE__ ) . '/../../maintenance/Maintenance.php' ); +require_once( dirname( __FILE__ ) . '/../../../maintenance/Maintenance.php' ); -class ApproveRevisions extends Maintenance { +class ApproveAllPages extends Maintenance { public function __construct() { parent::__construct(); - $this->mDescription = "Approve all current revisions"; + $this->mDescription = "Approve the current revision of all pages that do not yet have an approved revision."; } public function execute() { + global $wgTitle; $dbr = wfGetDB( DB_SLAVE ); @@ -49,8 +51,14 @@ while ( $page = $pages->fetchObject() ) { $title = Title::newFromID( $page->page_id ); - ApprovedRevs::setApprovedRevID( $title, $page->page_latest ); - $this->output( "\n" . wfTimestamp( TS_DB ) . ' Page ' . $title->getFullText() . ' now has ' . $page->page_latest . ' as approved revision.' ); + // some extensions, like Semantic Forms, need $wgTitle + // set as well + $wgTitle = $title; + if ( ! ApprovedRevs::hasUnsupportedNamespace( $title ) && + ! ApprovedRevs::hasApprovedRevision( $title ) ) { + ApprovedRevs::setApprovedRevID( $title, $page->page_latest ); + $this->output( wfTimestamp( TS_DB ) . ' Approved the last revision of page "' . $title->getFullText() . '".' ); + } } @@ -59,5 +67,5 @@ } -$maintClass = "ApproveRevisions"; -require_once( DO_MAINTENANCE ); \ No newline at end of file +$maintClass = "ApproveAllPages"; +require_once( DO_MAINTENANCE ); _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs