Tpt has uploaded a new change for review. https://gerrit.wikimedia.org/r/91619
Change subject: Add a maintenance script in order to replace hardcoded content model for Page: page in the page DB table ...................................................................... Add a maintenance script in order to replace hardcoded content model for Page: page in the page DB table Change-Id: I6ef14006b900a6d83bcbd349614eab972b6cf71a --- M ProofreadPage.body.php M ProofreadPage.php M includes/index/ProofreadIndexDbConnector.php A maintenance/fixProofreadPagePagesContentModel.php R sql/ProofreadIndex.sql 5 files changed, 93 insertions(+), 16 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ProofreadPage refs/changes/19/91619/1 diff --git a/ProofreadPage.body.php b/ProofreadPage.body.php index 242037b..218dd17 100644 --- a/ProofreadPage.body.php +++ b/ProofreadPage.body.php @@ -719,6 +719,20 @@ return true; } + + /** + * @param $updater DatabaseUpdater + * @return bool + */ + public static function onLoadExtensionSchemaUpdates( DatabaseUpdater $updater ) { + $dir = __DIR__ . '/sql/'; + + $updater->addExtensionTable( 'pr_index', $dir . 'ProofreadIndex.sql', true ); + $updater->addPostDatabaseUpdateMaintenance( 'FixProofreadPagePagesContentModel' ); + + return true; + } + /** * Add the links to previous, next, index page and scan image to Page: pages. * @param $skin SkinTemplate object diff --git a/ProofreadPage.php b/ProofreadPage.php index aedc2bc..fa88643 100644 --- a/ProofreadPage.php +++ b/ProofreadPage.php @@ -95,6 +95,9 @@ $wgAutoloadClasses['ApiQueryProofreadInfo'] = $dir . 'ApiQueryProofreadInfo.php'; $wgAPIMetaModules['proofreadinfo'] = 'ApiQueryProofreadInfo'; +//maintenance scripts +$wgAutoloadClasses['FixProofreadPagePagesContentModel'] = $dir . 'maintenance/FixProofreadPagePagesContentModel.php'; + # Group allowed to modify pagequality $wgGroupPermissions['user']['pagequality'] = true; @@ -159,7 +162,7 @@ $wgHooks['ArticleUndelete'][] = 'ProofreadPage::onArticleUndelete'; $wgHooks['ArticlePurge'][] = 'ProofreadPage::onArticlePurge'; $wgHooks['SpecialMovepageAfterMove'][] = 'ProofreadPage::onSpecialMovepageAfterMove'; -$wgHooks['LoadExtensionSchemaUpdates'][] = 'ProofreadIndexDbConnector::onLoadExtensionSchemaUpdates'; +$wgHooks['LoadExtensionSchemaUpdates'][] = 'ProofreadPage::onLoadExtensionSchemaUpdates'; $wgHooks['OutputPageParserOutput'][] = 'ProofreadPage::onOutputPageParserOutput'; $wgHooks['wgQueryPages'][] = 'ProofreadPage::onwgQueryPages'; $wgHooks['GetPreferences'][] = 'ProofreadPage::onGetPreferences'; diff --git a/includes/index/ProofreadIndexDbConnector.php b/includes/index/ProofreadIndexDbConnector.php index 019114a..a5afa0e 100644 --- a/includes/index/ProofreadIndexDbConnector.php +++ b/includes/index/ProofreadIndexDbConnector.php @@ -19,21 +19,7 @@ * @ingroup ProofreadPage */ -class ProofreadIndexDbConnector{ - - /** - * @param $updater DatabaseUpdater - * @return bool - */ - public static function onLoadExtensionSchemaUpdates( DatabaseUpdater $updater ) { - $updater->addExtensionUpdate( array( - 'addTable', - 'pr_index', - __DIR__ . '/ProofreadIndex.sql', - true - ) ); - return true; - } +class ProofreadIndexDbConnector { /** * Query the database to find if the current page is referred in an Index page. diff --git a/maintenance/fixProofreadPagePagesContentModel.php b/maintenance/fixProofreadPagePagesContentModel.php new file mode 100644 index 0000000..72eacaa --- /dev/null +++ b/maintenance/fixProofreadPagePagesContentModel.php @@ -0,0 +1,74 @@ +<?php +/** + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @file + * @ingroup ProofreadPage + */ + +$basePath = getenv( 'MW_INSTALL_PATH' ) !== false ? getenv( 'MW_INSTALL_PATH' ) : __DIR__ . '/../../..'; + +require_once $basePath . '/maintenance/Maintenance.php'; + + /** + * Set the content model type for Page: pages + */ +class FixProofreadPagePagesContentModel extends LoggedUpdateMaintenance { + + public function __construct() { + parent::__construct(); + + $this->mDescription = 'Set the content model type for Page: pages'; + } + + /** + * @see LoggedUpdateMaintenance::doDBUpdates + */ + public function doDBUpdates() { + $db = wfGetDB( DB_MASTER ); + if ( !$db->fieldExists( 'page', 'page_content_model', __METHOD__ ) ) { + $this->error( 'page_content_model field of page table does not exists.' ); + return false; + } + + $db->update( + 'page', + array( + 'page_content_model' => CONTENT_MODEL_PROOFREAD_PAGE + ), + array( + 'page_namespace' => ProofreadPage::getPageNamespaceId(), + 'page_content_model' => CONTENT_MODEL_WIKITEXT + ), + __METHOD__ + ); + + $this->output( "Update of the content model for Page: pages is done.\n" ); + + return true; + } + + /** + * @see LoggedUpdateMaintenance::getUpdateKey + */ + public function getUpdateKey() { + return 'FixPagePagesContentModel'; + } + +} + +$maintClass = 'FixProofreadPagePagesContentModel'; +require_once( RUN_MAINTENANCE_IF_MAIN ); \ No newline at end of file diff --git a/includes/index/ProofreadIndex.sql b/sql/ProofreadIndex.sql similarity index 100% rename from includes/index/ProofreadIndex.sql rename to sql/ProofreadIndex.sql -- To view, visit https://gerrit.wikimedia.org/r/91619 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6ef14006b900a6d83bcbd349614eab972b6cf71a Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/ProofreadPage Gerrit-Branch: pagePagesRefactoring Gerrit-Owner: Tpt <thoma...@hotmail.fr> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits