Index: trunk/extensions/CentralNotice/special/SpecialCentralNotice.php |
— | — | @@ -1695,32 +1695,40 @@ |
1696 | 1696 | * @param $endSettings array of campaign settings after changes (optional) |
1697 | 1697 | * @param $beginAssignments array of banner assignments before changes (optional) |
1698 | 1698 | * @param $endAssignments array of banner assignments after changes (optional) |
| 1699 | + * @return integer: ID of log entry (or null) |
1699 | 1700 | */ |
1700 | 1701 | function logCampaignChange( $action, $campaignId, $beginSettings = array(), |
1701 | 1702 | $endSettings = array(), $beginAssignments = array(), $endAssignments = array() ) |
1702 | 1703 | { |
1703 | 1704 | global $wgUser; |
1704 | 1705 | |
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 |
1706 | 1708 | |
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; |
1717 | 1732 | } |
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; |
1725 | 1733 | } |
1726 | 1734 | } |
1727 | 1735 | |