Devirk has uploaded a new change for review. https://gerrit.wikimedia.org/r/296909
Change subject: Update the contributors table with each edit using Hooks ...................................................................... Update the contributors table with each edit using Hooks Bug : T134939 Change-Id: I82a111862405e8906cba6e1a00af139322229c85 --- M extension.json M includes/ContributorsHooks.php 2 files changed, 39 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Contributors refs/changes/09/296909/1 diff --git a/extension.json b/extension.json index 2f5cae0..bfe2b1a 100644 --- a/extension.json +++ b/extension.json @@ -26,6 +26,9 @@ "ContributorsHooks": "includes/ContributorsHooks.php" }, "Hooks": { + "PageContentSaveComplete": [ + "ContributorsHooks::onPageContentSaveComplete" + ], "LoadExtensionSchemaUpdates": [ "ContributorsHooks::onLoadExtensionSchemaUpdates" ], diff --git a/includes/ContributorsHooks.php b/includes/ContributorsHooks.php index 30b9b9a..575f640 100644 --- a/includes/ContributorsHooks.php +++ b/includes/ContributorsHooks.php @@ -123,5 +123,41 @@ return true; } + public static function onPageContentSaveComplete( + $article, $user, $content, $summary, $isMinor, + $isWatch, $section, $flags, $revision, $status, $baseRevId + ) { + $dbw = wfGetDB( DB_MASTER ); + $dbr = wfGetDB( DB_MASTER ); + $pageId=$article->getId(); + $userId=$user->getId(); + $text=$user->getName(); + $res = $dbr->select( + 'contributors', + array( 'cn_revision_count' ), + array( 'cn_page_id' => $pageId,'cn_user_id' => $userId ), + __METHOD__ + ); + $dbw->upsert( + 'contributors', + array( + 'cn_page_id' =>$pageId, + 'cn_user_id' =>$userId, + 'cn_user_text' =>$text, + 'cn_revision_count' =>1 + + ), + array( + 'cn_page_id', + 'cn_user_id' + ), + array( + 'cn_revision_count' => $res + 1 + ), + __METHOD__ + ); + } + + } -- To view, visit https://gerrit.wikimedia.org/r/296909 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I82a111862405e8906cba6e1a00af139322229c85 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Contributors Gerrit-Branch: master Gerrit-Owner: Devirk <devikrishna...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits