r92676 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92675‎ | r92676 | r92677 >
Date:20:23, 20 July 2011
Author:kaldari
Status:ok
Tags:
Comment:
only log changes if they are done by actual users
Modified paths:
  • /trunk/extensions/CentralNotice/special/SpecialCentralNotice.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralNotice/special/SpecialCentralNotice.php
@@ -1695,32 +1695,40 @@
16961696 * @param $endSettings array of campaign settings after changes (optional)
16971697 * @param $beginAssignments array of banner assignments before changes (optional)
16981698 * @param $endAssignments array of banner assignments after changes (optional)
 1699+ * @return integer: ID of log entry (or null)
16991700 */
17001701 function logCampaignChange( $action, $campaignId, $beginSettings = array(),
17011702 $endSettings = array(), $beginAssignments = array(), $endAssignments = array() )
17021703 {
17031704 global $wgUser;
17041705
1705 - $dbw = wfGetDB( DB_MASTER );
 1706+ // Only log the change if it is done by an actual user (rather than a testing script)
 1707+ if ( $wgUser->getId() > 0 ) { // User::getID returns 0 for anonymous or non-existant users
17061708
1707 - $log = array(
1708 - 'notlog_timestamp' => $dbw->timestamp(),
1709 - 'notlog_user_id' => $wgUser->getId(),
1710 - 'notlog_action' => $action,
1711 - 'notlog_not_id' => $campaignId,
1712 - 'notlog_not_name' => CentralNotice::getNoticeName( $campaignId )
1713 - );
1714 -
1715 - foreach ( $beginSettings as $key => $value ) {
1716 - $log['notlog_begin_'.$key] = $value;
 1709+ $dbw = wfGetDB( DB_MASTER );
 1710+
 1711+ $log = array(
 1712+ 'notlog_timestamp' => $dbw->timestamp(),
 1713+ 'notlog_user_id' => $wgUser->getId(),
 1714+ 'notlog_action' => $action,
 1715+ 'notlog_not_id' => $campaignId,
 1716+ 'notlog_not_name' => CentralNotice::getNoticeName( $campaignId )
 1717+ );
 1718+
 1719+ foreach ( $beginSettings as $key => $value ) {
 1720+ $log['notlog_begin_'.$key] = $value;
 1721+ }
 1722+ foreach ( $endSettings as $key => $value ) {
 1723+ $log['notlog_end_'.$key] = $value;
 1724+ }
 1725+
 1726+ $res = $dbw->insert( 'cn_notice_log', $log );
 1727+ $log_id = $dbw->insertId();
 1728+ return $log_id;
 1729+
 1730+ } else {
 1731+ return null;
17171732 }
1718 - foreach ( $endSettings as $key => $value ) {
1719 - $log['notlog_end_'.$key] = $value;
1720 - }
1721 -
1722 - $res = $dbw->insert( 'cn_notice_log', $log );
1723 - $log_id = $dbw->insertId();
1724 - return $log_id;
17251733 }
17261734 }
17271735

Follow-up revisions

RevisionCommit summaryAuthorDate
r100100MFT r92510, r92676, r96496, r97304, r99160, r99165, r99169, r99176, r99178, r...awjrichards23:56, 17 October 2011

Status & tagging log