Mainframe98 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/403473 )

Change subject: Fix message ambiguity and allow omitting pipe
......................................................................

Fix message ambiguity and allow omitting pipe

The message shown on Special:DeleteBatch is commonly interpreted
as that the reason is optional, including the pipe that separates
the page name from the reason. While this is not necessarily an
issue, the real problem is that the script assumes there will be
a pipe and does not verify if the given line actually contained
one. This results in an error, but the script still continues to
run. Since the pipe is superfluous, allow omitting it.

Bug: T182455
Change-Id: If4d32cff2b09c9830ab07d17b93485d0b9be6cc8
---
M DeleteBatch.body.php
M i18n/en.json
2 files changed, 19 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DeleteBatch 
refs/changes/73/403473/1

diff --git a/DeleteBatch.body.php b/DeleteBatch.body.php
index 893bbee..bafa2f7 100644
--- a/DeleteBatch.body.php
+++ b/DeleteBatch.body.php
@@ -255,25 +255,37 @@
                if ( $filename ) { /* if from filename, delete from filename */
                        for ( $linenum = 1; !feof( $file ); $linenum++ ) {
                                $line = trim( fgets( $file ) );
-                               if ( $line == false ) {
+                               if ( !$line ) {
                                        break;
                                }
                                /* explode and give me a reason
                                   the file should contain only "page 
title|reason"\n lines
                                   the rest is trash
                                */
-                               $arr = explode( "|", $line );
-                               is_null( $arr[1] ) ? $reason = '' : $reason = 
$arr[1];
-                               $this->deletePage( $arr[0], $reason, $dbw, 
true, $linenum );
+                               if ( strpos( $line, '|' ) !== -1 ) {
+                                       $arr = explode( '|', $line );
+                               } else {
+                                       $arr = [ $line ];
+                               }
+                               if ( count( $arr ) < 2 ) {
+                                       $arr[1] = '';
+                               }
+                               $this->deletePage( $arr[0], $arr[1], $dbw, 
true, $linenum );
                        }
                } else {
                        /* run through text and do all like it should be */
                        $lines = explode( "\n", $line );
                        foreach ( $lines as $single_page ) {
+                               $single_page =  trim( $single_page );
                                /* explode and give me a reason */
-                               $page_data = explode( "|", trim( $single_page ) 
);
-                               if ( count( $page_data ) < 2 )
+                               if ( strpos( $single_page, '|' ) !== -1 ) {
+                                       $page_data = explode( '|', $single_page 
);
+                               } else {
+                                       $page_data = [ $single_page ];
+                               }
+                               if ( count( $page_data ) < 2 ) {
                                        $page_data[1] = '';
+                               }
                                $this->deletePage( $page_data[0], 
$page_data[1], $dbw, false, 0, $OldUser );
                        }
                }
diff --git a/i18n/en.json b/i18n/en.json
index 5eb1f52..fd35453 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -6,7 +6,7 @@
        },
        "deletebatch": "Delete batch of pages",
        "deletebatch-desc": "[[Special:DeleteBatch|Delete a batch of pages]]",
-       "deletebatch-help": "Delete a batch of pages.\nYou can either perform a 
single delete, or delete pages listed in a file.\nChoose a user that will be 
shown in deletion logs.\nUploaded files should contain page name and optional 
reason, separated by a \"|\" character in each line.",
+       "deletebatch-help": "Delete a batch of pages.\nYou can either perform a 
single delete, or delete pages listed in a file.\nChoose a user that will be 
shown in deletion logs.\nUploaded files should contain page name and optional 
reason, separated by a \"|\".",
        "deletebatch-caption": "Page list:",
        "deletebatch-title": "Delete batch",
        "deletebatch-link-back": "Go back to the special page",

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If4d32cff2b09c9830ab07d17b93485d0b9be6cc8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DeleteBatch
Gerrit-Branch: master
Gerrit-Owner: Mainframe98 <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to