Show a deprecation warning if parameter onlyroot is used

The parameter onlyroot is deprecated since July 2008.

Generate a tracking category for tracking the deprecation.

Bug: T290062
Change-Id: I8eb58fa7831e11e6a6719f11fb1ff310666cdc4e
This commit is contained in:
Fomafix 2021-08-31 09:18:25 +00:00
parent e5ac4d6907
commit 15a2d717d5
4 changed files with 24 additions and 3 deletions

View file

@ -185,6 +185,9 @@
} }
} }
}, },
"TrackingCategories": [
"categorytree-deprecation-category"
],
"ServiceWiringFiles": [ "ServiceWiringFiles": [
"includes/ServiceWiring.php" "includes/ServiceWiring.php"
], ],

View file

@ -32,5 +32,9 @@
"categorytree-no-pages": "no pages or subcategories", "categorytree-no-pages": "no pages or subcategories",
"categorytree-not-found": "Category <i>$1</i> not found", "categorytree-not-found": "Category <i>$1</i> not found",
"categorytree-error": "Problem loading data.", "categorytree-error": "Problem loading data.",
"categorytree-retry": "Please wait a moment and try again." "categorytree-retry": "Please wait a moment and try again.",
"categorytree-onlyroot-message": "Parameter <code>onlyroot</code> is deprecated. Use <code>depth=\"0\"</code> instead.",
"categorytree-deprecation-warning": "'''Warning:''' This page uses <code>&lt;categorytree&gt;</code> with deprecated parameter.",
"categorytree-deprecation-category": "Pages using deprecated categorytree parameters",
"categorytree-deprecation-category-desc": "The page uses deprecated categorytree parameters like <code>onlyroot</code>."
} }

View file

@ -51,5 +51,9 @@
"categorytree-no-pages": "Indicates that there are no pages or subcategories to be shown", "categorytree-no-pages": "Indicates that there are no pages or subcategories to be shown",
"categorytree-not-found": "Indicates that the given category ($1) was not found. Parameters:\n* $1 - category name", "categorytree-not-found": "Indicates that the given category ($1) was not found. Parameters:\n* $1 - category name",
"categorytree-error": "Indicates that an error has occurred while loading the node's content", "categorytree-error": "Indicates that an error has occurred while loading the node's content",
"categorytree-retry": "Instruction to try again later." "categorytree-retry": "Instruction to try again later.",
"categorytree-onlyroot-message": "Indicates that the deprecated parameter <code>onlyroot</code> is used.",
"categorytree-deprecation-warning": "Warning message on preview if a deprecated parameter is used.",
"categorytree-deprecation-category": "{{tracking category name}}\nThis message is used as a category name for a [[mw:Special:MyLanguage/Help:Tracking categories|tracking category]] where pages are placed automatically if they use a deprecate categorytree parameter like <code>onlyroot</code>.",
"categorytree-deprecation-category-desc": "Deprecated categorytree parameters category description. Shown on [[Special:TrackingCategories]].\n\nSee also:\n* {{msg-mw|categorytree-deprecation-category}}"
} }

View file

@ -223,9 +223,19 @@ class Hooks implements
$depth = $ct->optionManager->capDepth( $depthArg ); $depth = $ct->optionManager->capDepth( $depthArg );
if ( $onlyroot ) { if ( $onlyroot ) {
$depth = 0; $depth = 0;
$message = '<span class="error">'
. wfMessage( 'categorytree-onlyroot-message' )->inContentLanguage()->parse()
. '</span>';
if ( $parser ) {
$parser->getOutput()->addWarningMsg( 'categorytree-deprecation-warning' );
$parser->addTrackingCategory( 'categorytree-deprecation-category' );
}
} else {
$message = '';
} }
return $ct->getTag( $parser, $cat, $hideroot, $attr, $depth, $allowMissing ); return $message .
$ct->getTag( $parser, $cat, $hideroot, $attr, $depth, $allowMissing );
} }
/** /**