EBernhardson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/177105
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, 5 insertions(+), 12 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow
refs/changes/05/177105/1
diff --git a/includes/Import/LiquidThreadsApi/ConversionStrategy.php
b/includes/Import/LiquidThreadsApi/ConversionStrategy.php
index d896e80..1c5f93f 100644
--- a/includes/Import/LiquidThreadsApi/ConversionStrategy.php
+++ b/includes/Import/LiquidThreadsApi/ConversionStrategy.php
@@ -4,14 +4,13 @@
use ArrayIterator;
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;
@@ -112,10 +111,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..6b64909 100644
--- a/includes/Import/Wikitext/ImportSource.php
+++ b/includes/Import/Wikitext/ImportSource.php
@@ -3,8 +3,6 @@
namespace Flow\Import\Wikitext;
use ArrayIterator;
-use DateTime;
-use DateTimeZone;
use FlowHooks;
use Flow\Exception\FlowException;
use Flow\Import\Plain\ImportHeader;
@@ -62,10 +60,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: newchange
Gerrit-Change-Id: I33643b1f29756e920a36e6b60c527ace6f817387
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits