Write category parent hierarchy when handling categorization

Since we do brute force update (DELETE ALL+INSERT ALL) of the parent
categories we need to always write the parent category hierarchy.

Bug: T246568
Change-Id: Id9c3282a97bf3fc3d5355cc08a0c9d833c72c9b2
This commit is contained in:
David Causse 2020-07-30 16:40:06 +02:00
parent 6cbe99618e
commit 01eada74ef
2 changed files with 6 additions and 17 deletions

View file

@ -54,23 +54,6 @@ DELETE {
SPARQLD;
/**
* Delete/Insert query
*/
private const SPARQL_DELETE_INSERT = <<<SPARQLDI
DELETE {
?category ?x ?y
} INSERT {
%s
} WHERE {
?category ?x ?y
VALUES ?category {
%s
}
};
SPARQLDI;
/**
* @var RdfWriter
*/
@ -639,6 +622,7 @@ SPARQL;
continue;
}
$this->writeCategoryData( $row );
$pages[$row->page_id] = $row->rc_title;
$deleteUrls[] = '<' . $this->categoriesRdf->labelToUrl( $row->rc_title ) . '>';
$this->processed[$row->page_id] = true;
}
@ -682,6 +666,7 @@ SPARQL;
continue;
}
$this->writeCategoryData( $row );
$pages[$row->page_id] = $row->rc_title;
$deleteUrls[] = '<' . $this->categoriesRdf->labelToUrl( $row->rc_title ) . '>';
if ( $row->page_id ) {
$this->processed[$row->page_id] = true;

View file

@ -24,4 +24,8 @@ INSERT DATA {
mediawiki:pages "0"^^xsd:integer ;
mediawiki:subcategories "1"^^xsd:integer .
<http://acme.test/wiki/Category:CategoryChangesAsRdfTest_L2> mediawiki:isInCategory <http://acme.test/wiki/Category:CategoryChangesAsRdfTest_L1> .
<http://acme.test/wiki/Category:CategoryChangesAsRdfTest_Page> mediawiki:isInCategory <http://acme.test/wiki/Category:CategoryChangesAsRdfTest_L2> .
};