r25957 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25956‎ | r25957 | r25958 >
Date:11:23, 20 September 2007
Author:kim
Status:old
Tags:
Comment:
Copy.php
* Correct user assignment. Some minor issues remain (cross off this item from requirements to check)
! PENULTIMATE REVISION of copy.php in this form (pending possible last debugging)
> Now reimplementing as library+special page.
Modified paths:
  • /trunk/extensions/Wikidata/util/copy.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/util/copy.php
@@ -26,7 +26,13 @@
2727 # * CopyTools::getRow(...); # comment
2828 # Wrappers around PHP functions or extensions to PHP function set: Same style as the wrapped function
2929 # * mysql_insert_assoc(...); # comment
 30+#
 31+# TODO:
 32+# * Change to library
 33+# some read/write/dup functions are still main namespace, should get their own
 34+# classes
3035
 36+
3137 header("Content-type: text/html; charset=UTF-8");
3238
3339 define('MEDIAWIKI', true );
@@ -559,6 +565,9 @@
560566 }
561567 }
562568
 569+/** provide a namespace for copying tools (so we don't clutter up the main namespace with
 570+ * all our utility and tool functions) All functions here are public+static.
 571+ */
563572 class CopyTools {
564573 /** create a relevant entry in the `page` table. */
565574 public static function createPage($title) {
@@ -579,9 +588,31 @@
580589 }
581590
582591 /** start a new copy transaction
 592+ * Gets a virtual user id from the wikidata_sets table, if available
 593+ * (else uses user 0)
 594+ * There's still some issues with transactions especially wrt with user assignment
 595+ * where we intersect with the (old) "WikiDataAPI".
583596 */
584597 public static function newCopyTransaction($dc1, $dc2) {
585 - startNewTransaction(0, "127.0.0.1", "copying from $dc1 to $dc2", $dc2);
 598+
 599+ $datasets=CopyTools::getRow_noDC("wikidata_sets", "WHERE set_prefix=\"$dc2\"");
 600+ if ( $datasets == false ) {
 601+ throw new Exception("Dataset info for $dc2 not found.");
 602+ }
 603+
 604+ if ( array_key_exists("virtual_user_id", $datasets) ) {
 605+ $virtual_user_id=$datasets["virtual_user_id"];
 606+ } else {
 607+ $virtual_user_id=0;
 608+ }
 609+
 610+ print " VUID: $virtual_user_id";
 611+ startNewTransaction(
 612+ $virtual_user_id,
 613+ "0.0.0.0",
 614+ "copying from $dc1 to $dc2",
 615+ $dc2 );
 616+ print " UTID: ".getUpdateTransactionId();
586617 }
587618
588619 /** retrieve a single row from the database as an associative array
@@ -594,10 +625,14 @@
595626 public static function getRow($dc, $table, $where) {
596627 $target_table=mysql_real_escape_string("${dc}_${table}");
597628 $query="SELECT * FROM $target_table ".$where;
598 - print $query."<br>\n";
599629 return CopyTools::doQuery($query);
600630 }
601631
 632+ public static function getRow_noDC($table, $where) {
 633+ $target_table=mysql_real_escape_string("${table}");
 634+ $query="SELECT * FROM $target_table ".$where;
 635+ return CopyTools::doQuery($query);
 636+ }
602637
603638 /** retrieve multiple rows from the database, as an array of associative arrays.
604639 * @param $dc the dataset prefix we need

Status & tagging log