r98908 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98907‎ | r98908 | r98909 >
Date:20:46, 4 October 2011
Author:awjrichards
Status:ok
Tags:
Comment:
Modified paths:
  • /branches/wmf/1.18wmf1/extensions/CentralNotice/special/SpecialNoticeTemplate.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.18wmf1/extensions/CentralNotice/special/SpecialNoticeTemplate.php
@@ -769,7 +769,7 @@
770770 $article = new Article(
771771 Title::newFromText( "centralnotice-template-{$name}", NS_MEDIAWIKI )
772772 );
773 - $article->doDeleteArticle( 'CentralNotice Automated Removal' );
 773+ $article->doDeleteArticle( 'CentralNotice automated removal' );
774774 }
775775 }
776776
@@ -850,7 +850,7 @@
851851 return;
852852 }
853853
854 - $initialBannerSettings = CentralNoticeDB::getBannerSettings( $name );
 854+ $initialBannerSettings = CentralNoticeDB::getBannerSettings( $name, true );
855855
856856 $dbr = wfGetDB( DB_SLAVE );
857857 $res = $dbr->select( 'cn_templates', 'tmp_name',
@@ -875,26 +875,17 @@
876876 Title::newFromText( "centralnotice-template-{$name}", NS_MEDIAWIKI )
877877 );
878878
879 - $bodyPage = Title::newFromText(
880 - "Centralnotice-template-{$name}", NS_MEDIAWIKI );
881 - $curRev = Revision::newFromTitle( $bodyPage );
882 - $oldbody = $curRev ? $curRev->getText() : '';
883 -
884879 $article->doEdit( $body, '', EDIT_FORCE_BOT );
885 -
886 - $curRev = Revision::newFromTitle( $bodyPage );
887 - $newbody = $curRev ? $curRev->getText() : '';
888880
889 - //test for body changes
890 - $contentChanged = 0;
891 - if ($newbody !== $oldbody){
892 - $contentChanged = 1;
893 - }
894 -
895881 $bannerId = SpecialNoticeTemplate::getTemplateId( $name );
896 - $finalBannerSettings = CentralNoticeDB::getBannerSettings( $name );
897 - $this->logBannerChange( 'modified', $bannerId, $initialBannerSettings, $finalBannerSettings, $contentChanged);
 882+ $finalBannerSettings = CentralNoticeDB::getBannerSettings( $name, true );
898883
 884+ // If there are any difference between the old settings and the new settings, log them.
 885+ $diffs = array_diff_assoc( $initialBannerSettings, $finalBannerSettings );
 886+ if ( $diffs ) {
 887+ $this->logBannerChange( 'modified', $bannerId, $initialBannerSettings, $finalBannerSettings );
 888+ }
 889+
899890 return;
900891 }
901892 }
@@ -1013,12 +1004,8 @@
10141005 * @param $bannerId integer: ID of banner
10151006 * @param $beginSettings array of banner settings before changes (optional)
10161007 * @param $endSettings array of banner settings after changes (optional)
1017 - * @param $beginContent banner content before changes (optional)
1018 - * @param $endContent banner content after changes (optional)
10191008 */
1020 - function logBannerChange( $action, $bannerId, $beginSettings = array(),
1021 - $endSettings = array(), $contentChanged = 0 )
1022 - {
 1009+ function logBannerChange( $action, $bannerId, $beginSettings = array(), $endSettings = array() ) {
10231010 global $wgUser;
10241011
10251012 $dbw = wfGetDB( DB_MASTER );
@@ -1028,8 +1015,7 @@
10291016 'tmplog_user_id' => $wgUser->getId(),
10301017 'tmplog_action' => $action,
10311018 'tmplog_template_id' => $bannerId,
1032 - 'tmplog_template_name' => SpecialNoticeTemplate::getBannerName( $bannerId ),
1033 - 'tmplog_content_change' => $contentChanged
 1019+ 'tmplog_template_name' => SpecialNoticeTemplate::getBannerName( $bannerId )
10341020 );
10351021
10361022 foreach ( $beginSettings as $key => $value ) {
Property changes on: branches/wmf/1.18wmf1/extensions/CentralNotice/special/SpecialNoticeTemplate.php
___________________________________________________________________
Modified: svn:mergeinfo
10371023 Merged /trunk/extensions/CentralNotice/special/SpecialNoticeTemplate.php:r95515-98907

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r95686proper capitalizationkaldari19:05, 29 August 2011
r95929fix for a concurrency issue when loggingkaldari01:32, 1 September 2011
r96496follow up to r92922 - removing banner content change detection from the banne...kaldari21:02, 7 September 2011

Status & tagging log