r46051 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46050‎ | r46051 | r46052 >
Date:00:49, 23 January 2009
Author:tparscal
Status:ok
Tags:
Comment:
Added command-line interface for initialization of database. Added meta information in change logs.
Modified paths:
  • /trunk/extensions/DataCenter/CLI (added) (history)
  • /trunk/extensions/DataCenter/CLI/Initialize.php (added) (history)
  • /trunk/extensions/DataCenter/DataCenter.db.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DataCenter/DataCenter.db.php
@@ -1715,6 +1715,21 @@
17161716 )
17171717 );
17181718 }
 1719+
 1720+ public function serialize() {
 1721+ $metaFieldValues = $this->getMetaValues();
 1722+ $meta = array();
 1723+ foreach ( $metaFieldValues as $metaFieldValue ) {
 1724+ $meta[$metaFieldValue->get( 'field' )] =
 1725+ $metaFieldValue->get( 'value' );
 1726+ }
 1727+ return serialize(
 1728+ array(
 1729+ 'row' => $this->get(),
 1730+ 'meta' => $meta
 1731+ )
 1732+ );
 1733+ }
17191734 }
17201735
17211736 /* Asset Rows */
@@ -2227,7 +2242,7 @@
22282243 'component_category' => $component->getCategory(),
22292244 'component_type' => $component->getType(),
22302245 'component_id' => $component->getId(),
2231 - 'state' => serialize( $component->get() ),
 2246+ 'state' => $component->serialize(),
22322247 )
22332248 )
22342249 );
Index: trunk/extensions/DataCenter/CLI/Initialize.php
@@ -0,0 +1,20 @@
 2+<?php
 3+
 4+require_once dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) .
 5+ "/maintenance/commandLine.inc";
 6+
 7+if ( isset( $options['help'] ) ) {
 8+ echo "Rebuilds database structure for DataCenter.\n";
 9+ echo "Usage:\n";
 10+ echo "\tphp extensions/DataCenter/CLI/Initialize.php --confirm=yes \n";
 11+} else {
 12+ if ( isset( $options['confirm'] ) && $options['confirm'] == 'yes' ) {
 13+ echo "Rebuilding database structure for DataCenter...\n";
 14+ // Get a connection
 15+ $dbw = wfGetDB( DB_MASTER );
 16+ // Runs initialization
 17+ $dbw->sourceFile( dirname( dirname( __FILE__ ) ) . '/DataCenter.sql' );
 18+ } else {
 19+ echo "Nothing was changed. The --confirm=yes parameter is required.\n";
 20+ }
 21+}

Status & tagging log