[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Fix importation of weird file names in importTextFiles.php

2016-09-20 Thread jenkins-bot (Code Review)
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 
Gerrit-Reviewer: Alex Monk 
Gerrit-Reviewer: Legoktm 
Gerrit-Reviewer: Parent5446 
Gerrit-Reviewer: Samwilson 
Gerrit-Reviewer: TTO 
Gerrit-Reviewer: jenkins-bot <>

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


[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Fix importation of weird file names in importTextFiles.php

2016-08-13 Thread TTO (Code Review)
TTO has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/304603

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 starts with #, the script would call
Title::newFromText( '#foo' ), which succeeds (oddly enough) 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, 4 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/03/304603/1

diff --git a/maintenance/importTextFiles.php b/maintenance/importTextFiles.php
index 5531ffc..95e458d 100644
--- a/maintenance/importTextFiles.php
+++ b/maintenance/importTextFiles.php
@@ -103,16 +103,15 @@
$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 ) {
+   if ( !$title || $title->getPrefixedText() === '' ) {
$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: newchange
Gerrit-Change-Id: I6b4c8fd8dd09db14c0704c74137e112b292c964a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: TTO 

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