Info object
A MediaWiki installation is able to supply an enormous wealth of info that can be useful for bot tasks. Apibot is able to fetch this info and supply it to the programs that use it. To decrease the wiki online traffic, the info is cached and reused according to specified settings. All this is done by the Info
object, which is part of the Apibot Mains object.
This class exports over 500 functions that return wiki and user info, as well as some useful conversions and tasks that rely on this info - more than any other part of Apibot. If the bot doesn't know the information returned by the function you called, it will try to auto-fetch and possibly cache it. If the information is still unavailable, the function will typically return NULL
.
Types of info
Apibot divides the information from the wiki into several types:
- general - common things about the wiki; matches the General subtype of the MediaWiki Meta Siteinfo.
- siteinfo - all other MediaWiki Meta Siteinfo
- userinfo - the MediaWiki Meta Userinfo
- allmessages - the MediaWiki Meta Allmessages
- paraminfo - the MediaWiki Paraminfo
Info classes
The Info
class is actually the last descendant in a class hierarchy:
-
Info_Fetcher
- fetches the info; also, exports functions that return the general info -
Base_Info
- extendsInfo_Fetcher
; exports functions that return the siteinfo, userinfo, allmessages and paraminfo -
Extended_Info
- extendsBase_Info
; exports functions that are convenient shortcuts for some frequently used specific function calls, and functions that provide useful stuff relying on the wiki info -
Info
- extendsExtended_Info
; by default implements no new functions - it is a place for the bot user's custom functions, should s/he implement some. TheInfo
object in the ApibotMains
object is of this class.
All of these classes are implemented in PHP files with matching names, situated in the directory common/info
.
Creating
Creating an object of the class Info
requires three parameters:
-
$exchanger_api
- an API exchanger object -
$infostore
- an Infostore object -
$settings
- a Settings object
In addition, it can also take forth paramerer:
-
$force_load
- if true, will automatically fetch all wiki info on the object creation. Default isfalse
- this allows fetching the info from the wiki only when it is needed.
Public properties
-
$autoload
- whether to request the info from the wiki automatically on need. Default istrue
. Iffalse
, info will be requested from wiki only if the wiki info fetching functions are explicitly called.
Public functions
Due to their numbers, the functions are listed in separate subpages:
- Global info management
- Wiki general info
- Wiki siteinfo
- Wiki paraminfo
- Wiki userinfo
- Wiki allmessages
- Extended wiki info
(The class may also contain other types of info functions, eg. global user info, which are still not official.)