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

Change subject: Fix importation of weird file names in importTextFiles.php
......................................................................


Fix importation of weird file names in importTextFiles.php

When importing a file whose name contains a #, the script would call
e.g. Title::newFromText( '#foo' ), which succeeds (because titles
are allowed to contain fragments) but causes problems when trying
to create the revision.

Also avoid fatals on actual invalid titles.

Bug: T142675
Change-Id: I6b4c8fd8dd09db14c0704c74137e112b292c964a
---
M maintenance/importTextFiles.php
1 file changed, 5 insertions(+), 5 deletions(-)

Approvals:
  Legoktm: Looks good to me, approved
  Samwilson: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/maintenance/importTextFiles.php b/maintenance/importTextFiles.php
index 5531ffc..2894653 100644
--- a/maintenance/importTextFiles.php
+++ b/maintenance/importTextFiles.php
@@ -103,16 +103,16 @@
                        $timestamp = $useTimestamp ? wfTimestamp( TS_UNIX, 
filemtime( $file ) ) : wfTimestampNow();
 
                        $title = Title::newFromText( $pageName );
-                       $exists = $title->exists();
-                       $oldRevID = $title->getLatestRevID();
-                       $oldRev = $oldRevID ? Revision::newFromId( $oldRevID ) 
: null;
-
-                       if ( !$title ) {
+                       // Have to check for # manually, since it gets 
interpreted as a fragment
+                       if ( !$title || $title->hasFragment() ) {
                                $this->error( "Invalid title $pageName. 
Skipping.\n" );
                                $skipCount++;
                                continue;
                        }
 
+                       $exists = $title->exists();
+                       $oldRevID = $title->getLatestRevID();
+                       $oldRev = $oldRevID ? Revision::newFromId( $oldRevID ) 
: null;
                        $actualTitle = $title->getPrefixedText();
 
                        if ( $exists ) {

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I6b4c8fd8dd09db14c0704c74137e112b292c964a
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: TTO <at.li...@live.com.au>
Gerrit-Reviewer: Alex Monk <a...@wikimedia.org>
Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com>
Gerrit-Reviewer: Parent5446 <tylerro...@gmail.com>
Gerrit-Reviewer: Samwilson <s...@samwilson.id.au>
Gerrit-Reviewer: TTO <at.li...@live.com.au>
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