SPARQL;
+ /**
+ * Delete query
+ */
+ const SPARQL_DELETE = <<<SPARQLD
+DELETE {
+?category ?x ?y
+} WHERE {
+ VALUES ?category {
+ %s
+ }
+};
+
+SPARQLD;
+
/**
* Delete/Insert query
*/
global $wgRCMaxAge;
$this->initialize();
-
$startTS = new MWTimestamp( $this->getOption( "start" ) );
+
$endTS = new MWTimestamp( $this->getOption( "end" ) );
$now = new MWTimestamp();
fwrite( $output, $this->updateTS( $this->endTS ) );
}
+ /**
+ * Get the text of SPARQL INSERT DATA clause
+ * @return string
+ */
+ private function getInsertRdf() {
+ $rdfText = $this->getRdf();
+ if ( !$rdfText ) {
+ return "";
+ }
+ return sprintf( self::SPARQL_INSERT, $rdfText );
+ }
+
/**
* Get SPARQL for updating set of categories
* @param IDatabase $dbr
$this->writeParentCategories( $dbr, $pages );
}
- return "# $mark\n" . sprintf( self::SPARQL_DELETE_INSERT,
- $this->getRdf(),
- implode( ' ', $deleteUrls ) );
+ return "# $mark\n" . sprintf( self::SPARQL_DELETE, implode( ' ', $deleteUrls ) ) .
+ $this->getInsertRdf();
}
/**
$this->writeParentCategories( $dbr, $pages );
- fwrite( $output, sprintf( self::SPARQL_INSERT, $this->getRdf() ) );
+ fwrite( $output, $this->getInsertRdf() );
}
}
}
$this->writeParentCategories( $dbr, $pages );
- fwrite( $output, sprintf( self::SPARQL_INSERT, $this->getRdf() ) );
+ fwrite( $output, $this->getInsertRdf() );
}
}
# Changes
DELETE {
?category ?x ?y
-} INSERT {
+} WHERE {
+ VALUES ?category {
+ <http://acme.test/wiki/Category:Changed_category>
+ }
+};
+INSERT DATA {
<http://acme.test/wiki/Category:Changed_category> a mediawiki:Category ;
rdfs:label "Changed category" ;
mediawiki:subcategories "2"^^xsd:integer ;
mediawiki:isInCategory <http://acme.test/wiki/Category:Parent_of_30> .
-} WHERE {
- VALUES ?category {
- <http://acme.test/wiki/Category:Changed_category>
- }
};
# Moves
DELETE {
?category ?x ?y
-} INSERT {
+} WHERE {
+ VALUES ?category {
+ <http://acme.test/wiki/Category:Test> <http://acme.test/wiki/Category:MovedTo> <http://acme.test/wiki/Category:Test_2> <http://acme.test/wiki/Category:Test_3> <http://acme.test/wiki/Category:Test_4>
+ }
+};
+INSERT DATA {
<http://acme.test/wiki/Category:MovedTo> a mediawiki:Category ;
rdfs:label "MovedTo" ;
<http://acme.test/wiki/Category:AlsoMoved> mediawiki:isInCategory <http://acme.test/wiki/Category:Parent_of_5> .
-} WHERE {
- VALUES ?category {
- <http://acme.test/wiki/Category:Test> <http://acme.test/wiki/Category:MovedTo> <http://acme.test/wiki/Category:Test_2> <http://acme.test/wiki/Category:Test_3> <http://acme.test/wiki/Category:Test_4>
- }
};