@gmail.com" * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html * * @file */ use Wikimedia\Rdbms\IDatabase; /** * This abstract class implements many basic API functions, and is the base of * all API classes. * The class functions are divided into several areas of functionality: * * Module parameters: Derived classes can define getAllowedParams() to specify * which parameters to expect, how to parse and validate them. * * Self-documentation: code to allow the API to document its own state * * @ingroup API */ abstract class ApiBase extends ContextSource { /** * @name Constants for ::getAllowedParams() arrays * These constants are keys in the arrays returned by ::getAllowedParams() * and accepted by ::getParameterFromSettings() that define how the * parameters coming in from the request are to be interpreted. * @{ */ /** (null|boolean|integer|string) Default value of the parameter. */ const PARAM_DFLT = 0; /** (boolean) Accept multiple pipe-separated values for this parameter (e.g. titles)? */ const PARAM_ISMULTI = 1; /** * (string|string[]) Either an array of allowed value strings, or a string * type as described below. If not specified, will be determined from the * type of PARAM_DFLT. * * Supported string types are: * - boolean: A boolean parameter, returned as false if the parameter is * omitted and true if present (even with a falsey value, i.e. it works * like HTML checkboxes). PARAM_DFLT must be boolean false, if specified. * Cannot be used with PARAM_ISMULTI. * - integer: An integer value. See also PARAM_MIN, PARAM_MAX, and * PARAM_RANGE_ENFORCE. * - limit: An integer or the string 'max'. Default lower limit is 0 (but * see PARAM_MIN), and requires that PARAM_MAX and PARAM_MAX2 be * specified. Cannot be used with PARAM_ISMULTI. * - namespace: An integer representing a MediaWiki namespace. Forces PARAM_ALL = true to * support easily specifying all namespaces. * - NULL: Any string. * - password: Any non-empty string. Input value is private or sensitive. * would be an appropriate HTML form field. * - string: Any non-empty string, not expected to be very long or contain newlines. * would be an appropriate HTML form field. * - submodule: The name of a submodule of this module, see PARAM_SUBMODULE_MAP. * - tags: A string naming an existing, explicitly-defined tag. Should usually be * used with PARAM_ISMULTI. * - text: Any non-empty string, expected to be very long or contain newlines. *