To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit b012eabc authored by vermeul's avatar vermeul
Browse files

merge

parent 087c956d
......@@ -391,18 +391,17 @@ EOT;
}
}
/**
* This function is called after the save page request has been processed.
* @see https://www.mediawiki.org/wiki/Manual:Hooks/PageContentSaveComplete
*
* save all new or updated annotations. Annotations which are
* no longer present are being deleted.
/*
This function is called after the save page request has been processed.
@see https://www.mediawiki.org/wiki/Manual:Hooks/PageContentSaveComplete
save all new or updated annotations. Annotations which are
no longer present are being deleted.
*/
public static function onPageContentSaveComplete($wikiPage, $user, $content, $summary,
$isMinor, $isWatch, $section, $flags, $revision, $status, $baseRevId ) {
$status->fatal("lksjdfljsdl");
$dbw = wfGetDB( DB_MASTER );
$seen_bookmarks = array();
$seen_ids = array();
foreach ( self::$annotations as $bookmark => $annotation ){
$annotation_id = 0;
......@@ -446,6 +445,7 @@ EOT;
);
$annotation_id = $dbw->insertId();
}
array_push($seen_ids, $annotation_id);
# insert / update the annotation categories
if ( $annotation['categories'] ) {
......@@ -479,14 +479,14 @@ EOT;
)
);
}
$seen_bookmarks[] = $bookmark;
}
$where = array();
$where["page_id"] = $wikiPage->getId();
if ($seen_bookmarks) {
$where[] = 'bookmark NOT IN(' .$dbw->makeList($seen_bookmarks). ')';
$where = [
"page_id" => $wikiPage->getId()
];
if ($seen_ids) {
$where[] = 'id NOT IN(' .$dbw->makeList($seen_ids). ')';
}
# find all all annotations which are no longer present
......@@ -496,27 +496,40 @@ EOT;
$where
);
# delete all annotations which are no longer present
foreach( $annotations_to_delete as $annotation) {
try {
$dbw->delete(
'yata_annotation',
array(
id => $annotation->id
'id' => $annotation->id
)
);
}
catch (Exception $e) {
print($e->getMessage());
die;
}
# delete all annotation categories
# of these to-be-deleted annotations
foreach( $annotations_to_delete as $annotation) {
# delete all categories assigned to annotations
# which do not exist anymore
$delete_where = [
page_id => $wikiPage->getId(),
annotation_id => $annotation->id
];
try {
$dbw->delete(
'yata_annotation_category',
array(
id => $annotation->id
)
$delete_where
);
}
catch (Exception $e) {
print($e->getMessage());
die;
}
}
}
public static function add_category($dbw, $category_name, $hashtag, $description, $parent) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment