Fix the fedmsg emitter for the wiki
Signed-off-by: Ryan Lerch <rlerch@redhat.com>
This commit is contained in:
parent
2a44fd60e5
commit
ba3d86568f
1 changed files with 23 additions and 22 deletions
|
@ -41,6 +41,16 @@
|
||||||
|
|
||||||
if (!defined('MEDIAWIKI')) {echo("Cannot be run outside MediaWiki"); die(1);}
|
if (!defined('MEDIAWIKI')) {echo("Cannot be run outside MediaWiki"); die(1);}
|
||||||
|
|
||||||
|
$wgExtensionCredits['parserhook'][] = array(
|
||||||
|
'path' => __FILE__,
|
||||||
|
'name' => 'Fedmsg emit',
|
||||||
|
'author' => 'Ralph Bean',
|
||||||
|
'url' => 'https://pagure.io/fedora-infra/ansible/blob/main/f/roles/mediawiki/files/fedmsg-emit.php',
|
||||||
|
'description' => "A MediaWiki plugin that emits messages to the Fedora Infrastructure Message Bus.",
|
||||||
|
'version' => 0.2.0,
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
// globals
|
// globals
|
||||||
$config = 0;
|
$config = 0;
|
||||||
$queue = 0;
|
$queue = 0;
|
||||||
|
@ -111,9 +121,9 @@ function initialize() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Register our hooks with mediawiki
|
# Register our hooks with mediawiki
|
||||||
$wgHooks['PageContentSaveComplete'][] = 'article_save';
|
$wgHooks['PageSaveComplete'][] = 'page_save';
|
||||||
$wgHooks['UploadComplete'][] = 'upload_complete';
|
$wgHooks['UploadComplete'][] = 'upload_complete';
|
||||||
|
#wfDebug("pants")
|
||||||
# This is a reimplementation of the python code in fedmsg/crypto.py
|
# This is a reimplementation of the python code in fedmsg/crypto.py
|
||||||
# That file is authoritative. Changes there should be reflected here.
|
# That file is authoritative. Changes there should be reflected here.
|
||||||
function sign_message($message_obj) {
|
function sign_message($message_obj) {
|
||||||
|
@ -194,34 +204,28 @@ function emit_message($subtopic, $message) {
|
||||||
$queue->send($envelope);
|
$queue->send($envelope);
|
||||||
}
|
}
|
||||||
|
|
||||||
function article_save(
|
function page_save(
|
||||||
&$article,
|
$wikiPage,
|
||||||
&$user,
|
$user,
|
||||||
$text,
|
|
||||||
$summary,
|
$summary,
|
||||||
$minoredit,
|
$flags,
|
||||||
$watchthis,
|
$revisionRecord,
|
||||||
$sectionanchor,
|
$editResult,
|
||||||
&$flags,
|
|
||||||
$revision,
|
|
||||||
&$status,
|
|
||||||
$baseRevId,
|
|
||||||
$undidRevId=0
|
|
||||||
) {
|
) {
|
||||||
|
|
||||||
# If for some reason or another we can't create our socket, then bail.
|
# If for some reason or another we can't create our socket, then bail.
|
||||||
if (!initialize()) { return false; }
|
if (!initialize()) { return false; }
|
||||||
|
|
||||||
$topic = "article.edit";
|
$topic = "article.edit";
|
||||||
$title = $article->getTitle();
|
$title = $wikiPage->getTitle();
|
||||||
if ( $title->getNsText() ) {
|
if ( $title->getNsText() ) {
|
||||||
$titletext = $title->getNsText() . ":" . $title->getText();
|
$titletext = $title->getNsText() . ":" . $title->getText();
|
||||||
} else {
|
} else {
|
||||||
$titletext = $title->getText();
|
$titletext = $title->getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( is_object($revision) ) {
|
if ( is_object($revisionRecord) ) {
|
||||||
$url = $title->getFullURL('diff=prev&oldid=' . $revision->getId());
|
$url = $title->getFullURL('diff=prev&oldid=' . $revisionRecord->getId());
|
||||||
} else {
|
} else {
|
||||||
$url = $title->getFullURL();
|
$url = $title->getFullURL();
|
||||||
}
|
}
|
||||||
|
@ -231,11 +235,8 @@ function article_save(
|
||||||
$msg = array(
|
$msg = array(
|
||||||
"title" => $titletext,
|
"title" => $titletext,
|
||||||
"user" => $user->getName(),
|
"user" => $user->getName(),
|
||||||
"minor_edit" => $minoredit,
|
"minor_edit" => $revisionRecord->isMinor(),
|
||||||
"watch_this" => $watchthis,
|
"revision" => $revisionRecord,
|
||||||
"section_anchor" => $sectionanchor,
|
|
||||||
"revision" => $revision,
|
|
||||||
"base_rev_id" => $baseRevId,
|
|
||||||
"url" => $url,
|
"url" => $url,
|
||||||
#"summary" => $summary, # We *used* to send this, but it mucked things up.
|
#"summary" => $summary, # We *used* to send this, but it mucked things up.
|
||||||
# https://fedorahosted.org/fedora-infrastructure/ticket/3738#comment:7
|
# https://fedorahosted.org/fedora-infrastructure/ticket/3738#comment:7
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue