jenkins-bot has submitted this change and it was merged.

Change subject: Hygiene: Reach through MWTimestamp for the DateTime object
......................................................................


Hygiene: Reach through MWTimestamp for the DateTime object

Rather than newing up an appropriate DateTime object, reach through
the MWTimestamp for its DateTime which keeps timezone handling
centralized.

Change-Id: I33643b1f29756e920a36e6b60c527ace6f817387
---
M includes/Import/LiquidThreadsApi/ConversionStrategy.php
M includes/Import/LiquidThreadsApi/Objects.php
M includes/Import/Wikitext/ImportSource.php
3 files changed, 6 insertions(+), 12 deletions(-)

Approvals:
  Matthias Mullie: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/Import/LiquidThreadsApi/ConversionStrategy.php 
b/includes/Import/LiquidThreadsApi/ConversionStrategy.php
index fce7da0..51782aa 100644
--- a/includes/Import/LiquidThreadsApi/ConversionStrategy.php
+++ b/includes/Import/LiquidThreadsApi/ConversionStrategy.php
@@ -3,14 +3,13 @@
 namespace Flow\Import\LiquidThreadsApi;
 
 use DatabaseBase;
-use DateTime;
-use DateTimeZone;
 use Flow\Import\Converter;
 use Flow\Import\IConversionStrategy;
 use Flow\Import\ImportSourceStore;
 use Flow\Import\Postprocessor\LqtRedirector;
 use Flow\UrlGenerator;
 use LqtDispatch;
+use MWTimestamp;
 use Title;
 use User;
 use WikitextContent;
@@ -111,10 +110,9 @@
         * @return WikitextContent
         */
        public function createArchiveCleanupRevisionContent( WikitextContent 
$content, Title $title ) {
-               $now = new DateTime( "now", new DateTimeZone( 'GMT' ) );
                $arguments = implode( '|', array(
                        'from=' . $title->getPrefixedText(),
-                       'date=' . $now->format( 'Y-m-d' ),
+                       'date=' . 
MWTimestamp::getInstance()->timestamp->format( 'Y-m-d' ),
                ) );
 
                $newWikitext = preg_replace(
diff --git a/includes/Import/LiquidThreadsApi/Objects.php 
b/includes/Import/LiquidThreadsApi/Objects.php
index de4c8c0..cef3426 100644
--- a/includes/Import/LiquidThreadsApi/Objects.php
+++ b/includes/Import/LiquidThreadsApi/Objects.php
@@ -3,8 +3,6 @@
 namespace Flow\Import\LiquidThreadsApi;
 
 use ArrayIterator;
-use DateTime;
-use DateTimeZone;
 use Flow\Import\IImportHeader;
 use Flow\Import\IImportObject;
 use Flow\Import\IImportPost;
@@ -14,6 +12,7 @@
 use Flow\Import\IObjectRevision;
 use Flow\Import\IRevisionableObject;
 use Iterator;
+use MWTimestamp;
 use Title;
 use User;
 
@@ -349,10 +348,9 @@
                        $wikitextForLastRevision
                );
                $templateName = wfMessage( 
'flow-importer-lqt-converted-template' )->inContentLanguage()->plain();
-               $now = new DateTime( 'now', new DateTimeZone( 'UTC' ) );
                $arguments = implode( '|', array(
                        'archive=' . $archiveTitle->getPrefixedText(),
-                       'date=' . $now->format( 'Y-m-d' ),
+                       'date=' . 
MWTimestamp::getInstance()->timestamp->format( 'Y-m-d' ),
                ) );
 
                $newWikitext .= "\n\n{{{$templateName}|$arguments}}";
diff --git a/includes/Import/Wikitext/ImportSource.php 
b/includes/Import/Wikitext/ImportSource.php
index 013a748..d737c51 100644
--- a/includes/Import/Wikitext/ImportSource.php
+++ b/includes/Import/Wikitext/ImportSource.php
@@ -3,13 +3,12 @@
 namespace Flow\Import\Wikitext;
 
 use ArrayIterator;
-use DateTime;
-use DateTimeZone;
 use FlowHooks;
 use Flow\Exception\FlowException;
 use Flow\Import\Plain\ImportHeader;
 use Flow\Import\Plain\ObjectRevision;
 use Flow\Import\IImportSource;
+use MWTimestamp;
 use Parser;
 use ParserOptions;
 use Revision;
@@ -62,10 +61,9 @@
                }
 
                $template = wfMessage( 'flow-importer-wt-converted-template' 
)->inContentLanguage()->plain();
-               $now = new DateTime( "now", new DateTimeZone( "GMT" ) );
                $arguments = implode( '|', array(
                        'from=' . $this->title->getPrefixedText(),
-                       'date=' . $now->format( 'Y-m-d' ),
+                       'date=' . 
MWTimestamp::getInstance()->timestamp->format( 'Y-m-d' ),
                ) );
                $content .= "\n\n{{{$template}|$arguments}}";
 

-- 
To view, visit https://gerrit.wikimedia.org/r/177105
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I33643b1f29756e920a36e6b60c527ace6f817387
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <ebernhard...@wikimedia.org>
Gerrit-Reviewer: Matthias Mullie <mmul...@wikimedia.org>
Gerrit-Reviewer: SG <shah...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to