r24077 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24076‎ | r24077 | r24078 >
Date:09:17, 14 July 2007
Author:vrandezo
Status:old
Tags:
Comment:
Refreshdata has options now to constrain to certain namespaces
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/maintenance/SMW_refreshData.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/maintenance/SMW_refreshData.php
@@ -11,6 +11,9 @@
1212 *
1313 * -d <delay> Wait for this many milliseconds after processing an article, useful for limiting server load.
1414 * -v Be verbose about the progress.
 15+ * -c Will refresh only category pages (and other explicitly named namespaces)
 16+ * -p Will refresh only property pages (and other explicitly named namespaces)
 17+ * -t Will refresh only type pages (and other explicitly named namespaces)
1518 *
1619 * @author Yaron Koren
1720 * @author Markus Krötzsch
@@ -35,6 +38,25 @@
3639 $verbose = false;
3740 }
3841
 42+$filter = false;
 43+$categories = false;
 44+$properties = false;
 45+$types = false;
 46+$articles = false;
 47+
 48+if ( array_key_exists( 'c', $options ) ) {
 49+ $filter = true;
 50+ $categories = true;
 51+}
 52+if ( array_key_exists( 'p', $options ) ) {
 53+ $filter = true;
 54+ $properties = true;
 55+}
 56+if ( array_key_exists( 't', $options ) ) {
 57+ $filter = true;
 58+ $types = true;
 59+}
 60+
3961 global $wgParser;
4062
4163 $dbr =& wfGetDB( DB_MASTER );
@@ -50,6 +72,17 @@
5173 for ($id = $start; $id <= $end; $id++) {
5274 $title = Title::newFromID($id);
5375 if ( ($title === NULL) ) continue;
 76+ if ($filter) {
 77+ $ns = $title->getNamespace();
 78+ $doit = false;
 79+ if (($categories) && ($ns == NS_CATEGORY))
 80+ $doit = true;
 81+ if (($properties) && (($ns == SMW_NS_RELATION) || ($ns == SMW_NS_ATTRIBUTE)))
 82+ $doit = true;
 83+ if (($types) && ($ns == SMW_NS_TYPE))
 84+ $doit = true;
 85+ if (!$doit) continue;
 86+ }
5487 if ($verbose) {
5588 print "($num_files) Processing page with ID " . $id . " ...\n";
5689 }
@@ -64,7 +97,7 @@
6598 }
6699 } else {
67100 smwfGetStore()->deleteSubject($title);
68 - // sleep to be nice to the server
 101+ // sleep to be nice to the server
69102 // (for this case, sleep only every 1000 pages, so that large chunks of e.g. messages are processed more quickly)
70103 if ( ($delay !== false) && (($num_files+1) % 1000 === 0) ) {
71104 usleep($delay);

Status & tagging log