Tpt has submitted this change and it was merged.
Change subject: Separated data fetching from presentation in function
load_index in ProofreadPage.body.php
......................................................................
Separated data fetching from presentation in function load_index in
ProofreadPage.body.php
Will do the same for other functions also.
Change-Id: I9e067185529af2d259cfbeb84c3c3db66d2ddd95
---
M .gitignore
M ProofreadPage.body.php
M ProofreadPage.php
A includes/index/ProofreadIndexDbConnector.php
4 files changed, 45 insertions(+), 28 deletions(-)
Approvals:
Tpt: Verified; Looks good to me, approved
jenkins-bot: Checked
diff --git a/.gitignore b/.gitignore
index 98b092a..f610f91 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,5 @@
*~
*.kate-swp
.*.swp
+.htaccess
+
diff --git a/ProofreadPage.body.php b/ProofreadPage.body.php
index 4d37b7f..7e763b2 100644
--- a/ProofreadPage.body.php
+++ b/ProofreadPage.body.php
@@ -136,22 +136,6 @@
}
/**
- * @param $updater DatabaseUpdater
- * @return bool
- */
- public static function onLoadExtensionSchemaUpdates( $updater = null ) {
- $base = dirname( __FILE__ );
- if ( $updater === null ) {
- global $wgExtNewTables;
- $wgExtNewTables[] = array( 'pr_index',
"$base/ProofreadPage.sql" );
- } else {
- $updater->addExtensionUpdate( array( 'addTable',
'pr_index',
- "$base/ProofreadPage.sql", true ) );
- }
- return true;
- }
-
- /**
* Query the database to find if the current page is referred in an
Index page.
* @param $title Title
*/
@@ -159,17 +143,7 @@
list( $page_namespace, $index_namespace ) =
self::getPageAndIndexNamespace();
$title->pr_index_title = null;
- $dbr = wfGetDB( DB_SLAVE );
- $result = $dbr->select(
- array( 'page', 'pagelinks' ),
- array( 'page_namespace', 'page_title' ),
- array(
- 'pl_namespace' => $title->getNamespace(),
- 'pl_title' => $title->getDBkey(),
- 'pl_from=page_id'
- ),
- __METHOD__
- );
+ $result = ProofreadIndexDbConnector::getRowsFromTitle( $title );
foreach ( $result as $x ) {
$ref_title = Title::makeTitle( $x->page_namespace,
$x->page_title );
diff --git a/ProofreadPage.php b/ProofreadPage.php
index e066366..359f986 100644
--- a/ProofreadPage.php
+++ b/ProofreadPage.php
@@ -40,6 +40,7 @@
$wgExtensionMessagesFiles['ProofreadPageAlias'] = $dir .
'ProofreadPage.alias.php';
$wgAutoloadClasses['ProofreadPage'] = $dir . 'ProofreadPage.body.php';
+$wgAutoloadClasses['ProofreadIndexDbConnector'] = $dir .
'includes/index/ProofreadIndexDbConnector.php';
$wgAutoloadClasses['ProofreadPageInit'] = $dir .
'includes/ProofreadPageInit.php';
@@ -143,7 +144,7 @@
$wgHooks['EditFormPreloadText'][] = 'ProofreadPage::onEditFormPreloadText';
$wgHooks['ArticlePurge'][] = 'ProofreadPage::onArticlePurge';
$wgHooks['SpecialMovepageAfterMove'][] =
'ProofreadPage::onSpecialMovepageAfterMove';
-$wgHooks['LoadExtensionSchemaUpdates'][] =
'ProofreadPage::onLoadExtensionSchemaUpdates';
+$wgHooks['LoadExtensionSchemaUpdates'][] =
'ProofreadIndexDbConnector::onLoadExtensionSchemaUpdates';
$wgHooks['EditPage::importFormData'][] =
'ProofreadPage::onEditPageImportFormData';
$wgHooks['OutputPageParserOutput'][] =
'ProofreadPage::onOutputPageParserOutput';
$wgHooks['wgQueryPages'][] = 'ProofreadPage::onwgQueryPages';
diff --git a/includes/index/ProofreadIndexDbConnector.php
b/includes/index/ProofreadIndexDbConnector.php
new file mode 100644
index 0000000..7453102
--- /dev/null
+++ b/includes/index/ProofreadIndexDbConnector.php
@@ -0,0 +1,40 @@
+<?php
+
+class ProofreadIndexDbConnector{
+
+/**
+ * @param $updater DatabaseUpdater
+ * @return bool
+ */
+ public static function onLoadExtensionSchemaUpdates( $updater = null ) {
+ $base = dirname( __FILE__ );
+ if ( $updater === null ) {
+ global $wgExtNewTables;
+ $wgExtNewTables[] = array( 'pr_index',
"$base/ProofreadPage.sql" );
+ } else {
+ $updater->addExtensionUpdate( array( 'addTable',
'pr_index',
+ "$base/ProofreadPage.sql", true ) );
+ }
+ return true;
+ }
+
+ /**
+ * Query the database to find if the current page is referred in an
Index page.
+ * @param $title Title
+ * @return ResultWrapper
+ */
+ public static function getRowsFromTitle( $title ) {
+ $dbr = wfGetDB( DB_SLAVE );
+ $result = $dbr->select(
+ array( 'page', 'pagelinks' ),
+ array( 'page_namespace', 'page_title' ),
+ array(
+ 'pl_namespace' => $title->getNamespace(),
+ 'pl_title' => $title->getDBkey(),
+ 'pl_from=page_id'
+ ),
+ __METHOD__
+ );
+ return $result;
+ }
+}
\ No newline at end of file
--
To view, visit https://gerrit.wikimedia.org/r/67632
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I9e067185529af2d259cfbeb84c3c3db66d2ddd95
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/extensions/ProofreadPage
Gerrit-Branch: master
Gerrit-Owner: Rtdwivedi <[email protected]>
Gerrit-Reviewer: Reedy <[email protected]>
Gerrit-Reviewer: Rtdwivedi <[email protected]>
Gerrit-Reviewer: Tpt <[email protected]>
Gerrit-Reviewer: Zaran <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits