Alex Monk has uploaded a new change for review.
https://gerrit.wikimedia.org/r/158546
Change subject: Make it possible for API modules to hide their documentation
behind an 'includeinternal' parameter
......................................................................
Make it possible for API modules to hide their documentation behind an
'includeinternal' parameter
Bug: 62905
Change-Id: I33dfdd2cfb44fd974d17ae09a4529ec38374eced
---
M includes/api/ApiBase.php
M includes/api/ApiHelp.php
M includes/api/ApiMain.php
3 files changed, 27 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/46/158546/1
diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php
index 6914b02..17b8cd6 100644
--- a/includes/api/ApiBase.php
+++ b/includes/api/ApiBase.php
@@ -261,6 +261,16 @@
}
/**
+ * Returns whether this API module is considered to be internal or not.
+ *
+ * This is used to hide the module's documentation from action=help
unless an extra
+ * "includeinternal" parameter is given.
+ */
+ public function isInternalApi() {
+ return false;
+ }
+
+ /**
* Fetch the salt used in the Web UI corresponding to this module.
*
* Only override this if the Web UI uses a token with a non-constant
salt.
@@ -1853,6 +1863,9 @@
if ( $this->mustBePosted() ) {
$msg .= "\nThis module only accepts POST
requests";
}
+ if ( $this->isInternalApi() ) {
+ $msg .= "\nThis module is intended to be
internal. It may change without notice and should be considered unstable";
+ }
if ( $this->isReadMode() || $this->isWriteMode() ||
$this->mustBePosted()
) {
diff --git a/includes/api/ApiHelp.php b/includes/api/ApiHelp.php
index bcd6c12..868d9aa 100644
--- a/includes/api/ApiHelp.php
+++ b/includes/api/ApiHelp.php
@@ -140,6 +140,9 @@
ApiBase::PARAM_ISMULTI => true,
ApiBase::PARAM_DEPRECATED => true
),
+ 'includeinternal' => array(
+ ApiBase::PARAM_TYPE => 'boolean'
+ ),
);
}
@@ -149,6 +152,7 @@
'Can specify submodules with a \'+\'',
'querymodules' => 'Use modules=query+value instead.
List of query ' .
'module names (value of prop=, meta= or list=
parameter)',
+ 'includeinternal' => 'Include modules marked as
internal',
);
}
diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php
index 7f711b7..838b157 100644
--- a/includes/api/ApiMain.php
+++ b/includes/api/ApiMain.php
@@ -1269,8 +1269,10 @@
return $cached;
}
}
- $retval = $this->reallyMakeHelpMsg();
- if ( $cacheHelpTimeout > 0 ) {
+ $showInternal = $this->getRequest()->getBool( 'includeinternal'
);
+ $retval = $this->reallyMakeHelpMsg( $showInternal );
+ // Don't cache includeinternal page.
+ if ( $cacheHelpTimeout > 0 && !$showInternal ) {
$wgMemc->set( $key, $retval, $cacheHelpTimeout );
}
@@ -1278,9 +1280,10 @@
}
/**
+ * @param bool $showInternal
* @return mixed|string
*/
- public function reallyMakeHelpMsg() {
+ public function reallyMakeHelpMsg( $showInternal ) {
$this->setHelp();
// Use parent to make default message for the main module
@@ -1291,6 +1294,10 @@
foreach ( $this->mModuleMgr->getNames( 'action' ) as $name ) {
$module = $this->mModuleMgr->getModule( $name );
+ if ( $module->isInternalApi() && !$showInternal ) {
+ continue;
+ }
+
$msg .= self::makeHelpMsgHeader( $module, 'action' );
$msg2 = $module->makeHelpMsg();
--
To view, visit https://gerrit.wikimedia.org/r/158546
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I33dfdd2cfb44fd974d17ae09a4529ec38374eced
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Alex Monk <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits