jenkins-bot has submitted this change and it was merged.
Change subject: Made global page data constants into CargoPageData fields
......................................................................
Made global page data constants into CargoPageData fields
Change-Id: Ibb2e9a2f6fdfa7682c224c31b9debd39fe0274f2
---
M Cargo.hooks.php
M Cargo.php
M CargoPageData.php
3 files changed, 20 insertions(+), 26 deletions(-)
Approvals:
Yaron Koren: Looks good to me, approved
jenkins-bot: Verified
diff --git a/Cargo.hooks.php b/Cargo.hooks.php
index e6fc7a3..58f7253 100755
--- a/Cargo.hooks.php
+++ b/Cargo.hooks.php
@@ -24,13 +24,6 @@
$wgGroupPermissions['sysop']['recreatecargodata'] = true;
$wgGroupPermissions['sysop']['deletecargodata'] = true;
-
- define( 'CARGO_STORE_CREATION_DATE', 1 );
- define( 'CARGO_STORE_MODIFICATION_DATE', 2 );
- define( 'CARGO_STORE_CREATOR', 3 );
- define( 'CARGO_STORE_FULL_TEXT', 4 );
- define( 'CARGO_STORE_CATEGORIES', 5 );
- define( 'CARGO_STORE_NUM_REVISIONS', 6 );
}
public static function registerParserFunctions( &$parser ) {
diff --git a/Cargo.php b/Cargo.php
index bcdfbbe..aff2c61 100644
--- a/Cargo.php
+++ b/Cargo.php
@@ -27,13 +27,6 @@
define( 'CARGO_VERSION', '1.0.1' );
-define( 'CARGO_STORE_CREATION_DATE', 1 );
-define( 'CARGO_STORE_MODIFICATION_DATE', 2 );
-define( 'CARGO_STORE_CREATOR', 3 );
-define( 'CARGO_STORE_FULL_TEXT', 4 );
-define( 'CARGO_STORE_CATEGORIES', 5 );
-define( 'CARGO_STORE_NUM_REVISIONS', 6 );
-
$wgExtensionCredits['parserhook'][] = array(
'path' => __FILE__,
'name' => 'Cargo',
diff --git a/CargoPageData.php b/CargoPageData.php
index c95ded3..865dae9 100644
--- a/CargoPageData.php
+++ b/CargoPageData.php
@@ -7,27 +7,35 @@
*/
class CargoPageData {
+ // Constants for possible table fields/columns
+ const CREATION_DATE = 1;
+ const MODIFICATION_DATE = 2;
+ const CREATOR = 3;
+ const FULL_TEXT = 4;
+ const CATEGORIES = 5;
+ const NUM_REVISIONS = 6;
+
static function getTableSchema() {
global $wgCargoPageDataColumns;
$fieldTypes = array();
- if ( in_array( CARGO_STORE_CREATION_DATE,
$wgCargoPageDataColumns ) ) {
+ if ( in_array( self::CREATION_DATE, $wgCargoPageDataColumns ) )
{
$fieldTypes['_creationDate'] = array( 'Date', false );
}
- if ( in_array( CARGO_STORE_MODIFICATION_DATE,
$wgCargoPageDataColumns ) ) {
+ if ( in_array( self::MODIFICATION_DATE, $wgCargoPageDataColumns
) ) {
$fieldTypes['_modificationDate'] = array( 'Date', false
);
}
- if ( in_array( CARGO_STORE_CREATOR, $wgCargoPageDataColumns ) )
{
+ if ( in_array( self::CREATOR, $wgCargoPageDataColumns ) ) {
$fieldTypes['_creator'] = array( 'String', false );
}
- if ( in_array( CARGO_STORE_FULL_TEXT, $wgCargoPageDataColumns )
) {
+ if ( in_array( self::FULL_TEXT, $wgCargoPageDataColumns ) ) {
$fieldTypes['_fullText'] = array( 'Searchtext', false );
}
- if ( in_array( CARGO_STORE_CATEGORIES, $wgCargoPageDataColumns
) ) {
+ if ( in_array( self::CATEGORIES, $wgCargoPageDataColumns ) ) {
$fieldTypes['_categories'] = array( 'String', true );
}
- if ( in_array( CARGO_STORE_NUM_REVISIONS,
$wgCargoPageDataColumns ) ) {
+ if ( in_array( self::NUM_REVISIONS, $wgCargoPageDataColumns ) )
{
$fieldTypes['_numRevisions'] = array( 'Integer', false
);
}
@@ -70,7 +78,7 @@
$wikiPage = WikiPage::factory( $title );
$pageDataValues = array();
- if ( in_array( CARGO_STORE_CREATION_DATE,
$wgCargoPageDataColumns ) ) {
+ if ( in_array( self::CREATION_DATE, $wgCargoPageDataColumns ) )
{
$firstRevision = $title->getFirstRevision();
if ( $firstRevision == null ) {
// This can sometimes happen.
@@ -79,13 +87,13 @@
$pageDataValues['_creationDate'] =
$firstRevision->getTimestamp();
}
}
- if ( in_array( CARGO_STORE_MODIFICATION_DATE,
$wgCargoPageDataColumns ) ) {
+ if ( in_array( self::MODIFICATION_DATE, $wgCargoPageDataColumns
) ) {
$pageDataValues['_modificationDate'] =
$wikiPage->getTimestamp();
}
- if ( in_array( CARGO_STORE_CREATOR, $wgCargoPageDataColumns ) )
{
+ if ( in_array( self::CREATOR, $wgCargoPageDataColumns ) ) {
$pageDataValues['_creator'] = $wikiPage->getCreator();
}
- if ( in_array( CARGO_STORE_FULL_TEXT, $wgCargoPageDataColumns )
) {
+ if ( in_array( self::FULL_TEXT, $wgCargoPageDataColumns ) ) {
if ( $setToBlank ) {
$pageDataValues['_fullText'] = '';
} else {
@@ -93,7 +101,7 @@
$pageDataValues['_fullText'] =
$article->getContent();
}
}
- if ( in_array( CARGO_STORE_CATEGORIES, $wgCargoPageDataColumns
) ) {
+ if ( in_array( self::CATEGORIES, $wgCargoPageDataColumns ) ) {
$pageCategories = array();
if ( !$setToBlank ) {
$dbr = wfGetDB( DB_SLAVE );
@@ -111,7 +119,7 @@
$pageCategoriesString = implode( '|', $pageCategories );
$pageDataValues['_categories'] = $pageCategoriesString;
}
- if ( in_array( CARGO_STORE_NUM_REVISIONS,
$wgCargoPageDataColumns ) ) {
+ if ( in_array( self::NUM_REVISIONS, $wgCargoPageDataColumns ) )
{
$dbr = wfGetDB( DB_SLAVE );
$res = $dbr->select(
'revision',
--
To view, visit https://gerrit.wikimedia.org/r/304024
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ibb2e9a2f6fdfa7682c224c31b9debd39fe0274f2
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Cargo
Gerrit-Branch: master
Gerrit-Owner: Yaron Koren <[email protected]>
Gerrit-Reviewer: Yaron Koren <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits