Add link to Special:PrefixIndex in delete dialog
authorÉtienne Beaulé <beauleetienne0@gmail.com>
Fri, 1 Aug 2014 02:56:27 +0000 (22:56 -0400)
committerKunal Mehta <legoktm@member.fsf.org>
Wed, 19 Jul 2017 21:41:30 +0000 (14:41 -0700)
This change adds a warning to ?action=delete with a link to a
Special:PrefixIndex of the page being deleted if the page being deleted
has subpages.

If there are less than 50 subpages, the exact count will be mentioned in
the message.

Bug: T32666
Change-Id: Ibd705ed77452a55f782ed855c676d7ee23e9ad61

includes/page/Article.php
languages/i18n/en.json
languages/i18n/qqq.json

index 16328bc..d13fb3c 100644 (file)
@@ -1673,11 +1673,20 @@ class Article implements Page {
                $outputPage->setPageTitle( wfMessage( 'delete-confirm', $title->getPrefixedText() ) );
                $outputPage->addBacklinkSubtitle( $title );
                $outputPage->setRobotPolicy( 'noindex,nofollow' );
+
                $backlinkCache = $title->getBacklinkCache();
                if ( $backlinkCache->hasLinks( 'pagelinks' ) || $backlinkCache->hasLinks( 'templatelinks' ) ) {
                        $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
                                'deleting-backlinks-warning' );
                }
+
+               $subpageQueryLimit = 51;
+               $subpages = $title->getSubpages( $subpageQueryLimit );
+               $subpageCount = count( $subpages );
+               if ( $subpageCount > 0 ) {
+                       $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
+                               [ 'deleting-subpages-warning', Message::numParam( $subpageCount ) ] );
+               }
                $outputPage->addWikiMsg( 'confirmdeletetext' );
 
                Hooks::run( 'ArticleConfirmDelete', [ $this, $outputPage, &$reason ] );
index e0ac829..52645cb 100644 (file)
        "delete-warning-toobig": "This page has a large edit history, over $1 {{PLURAL:$1|revision|revisions}}.\nDeleting it may disrupt database operations of {{SITENAME}};\nproceed with caution.",
        "deleteprotected": "You cannot delete this page because it has been protected.",
        "deleting-backlinks-warning": "<strong>Warning:</strong> [[Special:WhatLinksHere/{{FULLPAGENAME}}|Other pages]] link to or transclude the page you are about to delete.",
+       "deleting-subpages-warning": "<strong>Warning:</strong> The page you are about to delete has [[Special:PrefixIndex/{{FULLPAGENAME}}/|{{PLURAL:$1|a subpage|$1 subpages|51=over 50 subpages}}]].",
        "rollback": "Roll back edits",
        "rollbacklink": "rollback",
        "rollbacklinkcount": "rollback $1 {{PLURAL:$1|edit|edits}}",
index 33b2f8f..92010ab 100644 (file)
        "delete-warning-toobig": "Parameters:\n* $1 - the upper limit of number of revisions\nSee also:\n* {{msg-mw|Delete-toobig}}",
        "deleteprotected": "Used as error message when deleting the page.\n\n\"If protection keeps them from editing, they shouldn't be able to delete.\"",
        "deleting-backlinks-warning": "A warning shown when a page that is being deleted has at least one link to it or is transcluded in at least one page.",
+       "deleting-subpages-warning": "A warning shown when a page that is being deleted has at least one subpage. $1 is the number of subpages of the page. For any number of subpages over 50, $1 will be 51.\nSee also:\n* {{msg-mw|Deleting-backlinks-warning}}",
        "rollback": "{{Identical|Rollback}}",
        "rollbacklink": "{{Doc-actionlink}}\nThis link text appears on the recent changes page to users who have the \"rollback\" right.\nThis message has a tooltip {{msg-mw|tooltip-rollback}}\n{{Identical|Rollback}}",
        "rollbacklinkcount": "{{doc-actionlink}}\nText of the rollback link showing the number of edits to be rolled back. See also {{msg-mw|rollbacklink}}.\n\nParameters:\n* $1 - the number of edits that will be rolled back. If $1 is over the value of <code>$wgShowRollbackEditCount</code> (default: 10) {{msg-mw|rollbacklinkcount-morethan}} is used.\n\nThe rollback link is displayed with a tooltip {{msg-mw|Tooltip-rollback}}",