Extension:DynamicPageListEngine/de-formal

The  extension is a backend providing dynamic page lists, which can be used on php level for other extensions, or on Lua level with the Scribunto extension. The page selection and sorting criteria are compatible with DynamicPageList (Wikimedia).

Given that there are already DynamicPageList (Wikimedia) and DynamicPageList (third-party), which are not completely compatible, you might be wondering why yet another such extension. In short:
 * 1) I needed dynamic page lists on Lua level, and none of the two existing extensions provided that.
 * 2) Adding such a feature on top of DynamicPageList (Wikimedia) was not feasible due to its monolithic implementation.
 * 3) Adding such a feature on top of DynamicPageList (third-party) might have been possible, but then it would have been partially incompatible with the Wikimedia extension. More importantly, as the  the DPL manual states, "DPL at the moment is rather monolithic" as well.
 * 4) Hence the only solution was to create a new extension from scratch.
 * 5) The extremely high number of features in the third-party extension suggests the need for a configurable, modular and extensible backend.

Installation
Even though this extension has been tested on MediaWiki 1.30 only, it is likely to work on slightly earlier versions as well.

Upgrading
To upgrade, simply install the most recent version.

Upgrading from 0.3 or earlier
With version 1.0.0, almost all configuration parameters and messages names have been changed. If you have customized any of them, you need to adapt your configuration.

Since version 1.0.0, pages using DynamicPageListEngine are assigned to a tracking category. If you already have such pages, you can fix the categories either by performing a null edit on each page or by executing the script. Note that the latter may take a considerable amount of time.

LocalSettings.php
There is a number of parameters that can be customized in LocalSettings.php. The default configuration aims at maximum compatibility with DynamicPageList (Wikimedia) and is likely to satisfy your needs if you use this extension for the first time.


 * $wgDpleMaxCost: Maxiumum cost of a dynamic page list in terms of database load. The default value NULL means that it is automatically set to the corresponding value for DynamicPageList (Wikimedia).


 * $wgDpleMaxResultCount: Maxiumum number of records to fetch for one list. The default value NULL means that it is automatically set to the corresponding value for DynamicPageList (Wikimedia).


 * $wgDpleFeatures: Features to enable. An associative array between feature name/class and a boolean to indicate enabled (true) or not (false). See Usage for details. You should always enable at least, otherwise there is no limit to the number of fetched records, and  , otherwise there is no limit on the complexity of the query. If you want to use Lua, you also need  . Each of these may be replaced with a derived class or a class with similar semantics.:: The default list of features may be viewed in the extension's extension.json.
 * $wgDpleCondCostMap: Cost of selection conditions in terms of database load. A unit of 1 should correspond to an efficient table join. You can tune this map to reflect the real cost on your particular installation and/or prevent users from excessive use of certain features.


 * $wgDpleOrderCostMap: Cost of order methods in terms of database load, in units which should be vaguely comparable to those of.

Unless you are very concerned about performance issues, you may simply enable all features in  by copying it from the file   any uncommenting everything. In that case, to limit performance impact, you might decide to set  to a low value which however permits to use each feature, for instance 3.

Messages
Since the extension defines a lot of messages which are constantly evolving with further development, they are not documented here. Please refer to.

Usage
For use on php level, please refer to the integrated doxygen documentation. For use on Lua level, see Lua library.

The accepted parameters and other aspects of the behaviour are implemented as features corresponding to php classes. With the variable  in LocalSettings.php you can configure which features you want to enable. The bundled features are described in the following sections, where the titles correspond to the class names without the prefix "DynamicPageListEngineFeature".

Unless otherwise stated, using arrays as parameter values return the intersection of the individual result sets. If the parameters contradict each other (e.g. the same namespace is nominated in  and in  ), the results are undefined.

Namespace
Select by namespace. Recognizes the parameters  and   which may be a namespace name or namespace index or an array thereof. Any invalid value, including the empty string, is interpreted as the main namespace, for compatibility with DynamicPageList (Wikimedia).

If  is an array, the result set consists (obviously) in the pages in any of the namespaces, i.e. the result set is the union of the individual result sets, unlike other parameters (including  ) where the result set is the intersection.

Category
Select by category. Recognizes the parameters  and. Each of them may be a string or an array. If  is an array, the result set consists in the pages contained in all listed categories. If  is an array, the result set consists in the pages contained in none of the listed categories.

Redirects
Include or exclude redirects. Recognizes the parameter , which may be one of.

Default is, for compatibility with DynamicPageList (Wikimedia).This implies that enabling this feature in   will change the result set of a dynamic page list even for parameter sets which do not contain the   parameter, if the result set would contain redirects.

The value  selects only redirects just like , but in addition the target for each redirect is retrieved. This means that the result objuect for each page has a property  which is an associative array of properties of the redirect target.

Titlematch
Select by title prefix, suffix or fragment. Recognizes the parameters  and , each of which may be a title substring or an array thereof. As usual, spaces and underscores in titles are equivalent.

If  is an array, the result set consists (obviously) in the pages satisfying any of the conditions, i.e. the result is the union of the individual result sets, unlike other parameters (including  ) where the result set is the intersection.

This class implements a  condition for substrings, but not a general   for LIKE patterns, because escaping of the   and   characters depends on the database backend and hence it could not be ensured that a condition containing these metacharacters supplies the same result on all database backends.

Subpages
Include or exclude subpages. Recognizes the parameter, which may be one of. Default is, for consistency with the Redirects feature.

This implies that enabling this feature in $wgDynamicPageListEngineFeatures will change the result set of a dynamic page list even for parameter sets which do not contain the  parameter, if the result set would contain subpages.

Subpage selection works with a simple LIKE '%/%' expression, regardless of whether the namespace of a page has subpages enabled. To distinguish whether subpages are enabled, a CASE expression or something similar would need to be evaluated for each single row, and it would be difficult to implement this in an efficient and portable way.

Linksto
Select pages linking to the specified pages. Recognizes the parameters  and. Each of them may be a string or an array. The result set differs from the result of "What links here" because it does not contain redirects, for compatibility with DynamicPageList (third-party).

Linksfrom
Select paged linked from specified pages. Recognizes the parameters  and. Each of them may be a string or an array. The names are chosen for compatibility with DynamicPageList (third-party).

Redirectsto
Select pages redirecting to the specified pages. Recognizes the parameters  and. Each of them may be a string or an array.

Uses
Select pages using the specified pages as templates. Recognizes the parameters  and. Each of them may be a string or an array. The results are the same as with DynamicPageList (third-party).

Usedby
Select pages used as templates by the specified pages. Recognizes the parameters  and. Each of them may be a string or an array. The results are the same as with DynamicPageList (third-party).

Imageused
Select pages that contain the specified images. Recognizes the parameters  and. Each of them may be a string or an array. The names are chosen for compatibility with DynamicPageList (third-party).

Imagecontainer
Select images that are contained in the specified pages. Recognizes the parameters  and. Each of them may be a string or an array. The names are chosen for compatibility with DynamicPageList (third-party).

Contains
Select categories which contain the specified pages. Recognizes the parameters  and. Each of them may be a string or an array.

Extra
Select pages by extra information in category tags. You can add extra information in a category sort key, in constructs like. For MediaWiki, the whole string  is the sort key. The extension considers the part after the second pipe character ( in the example) as extra information.

The feature recognizes the parameters  and. selects exact matches of the extra information appended to the sort key for the first category specified with the  parameter. selects the complement of this. If no categories are selected, these parameters are silently ignored.

If  is an array, the result set consists (obviously) in the pages satisfying any of the conditions, i.e. the result is the union of the individual record sets, unlike other parameters (including  ) where the result set is the intersection.

Extrax
Select categories by extra information in category tags.

The feature recognizes the parameters  and. selects categories with exact matches for the extra information appended to the sort key for the first page specified with the  parameter. selects the complement of this. If no  parameter was used, these parameters are silently ignored.

If  is an array, the result set consists (obviously) in the pages satisfying any of the conditions, i.e. the result is the union of the individual record sets, unlike other parameters (including  ) where the result is the intersection.

User
Selection by modifying user. Recognizes the parameters  and , each of which may be a title substring or an array thereof.

If  is an array, the result set consists in the pages satisfying any of the conditions, i.e. the result is the union of the individual record sets, unlike other parameters (including  ) where the result is the intersection.

Use of  is likely to create much more database load than the other parameters because the record sets to join may be very large. This is reflected in, but you might need to adjust this value. You can effectively disable these parameters by setting their cost higher than the value of.

Count
Limit the number of records to fetch from the database. Recognizes the parameter  which gives the limit. Invalid values (including 0) are interpreted as 1, for compatibility with DynamicPageList (Wikimedia). In any case, the number is limited to.

Order
Sort the result records. Recognizes the parameters  (default  ) and   (default  ). Some values are replaced by fallback values if no category was indicated. Defaults and fallback values are chosen for compatibility with DynamicPageList (Wikimedia).

In addition to the  values recognized by DynamicPageList (Wikimedia), the value   is accepted as well. It sorts by title without namespace prefix.

Check
Check whether the whole specification is acceptable in terms of database load.

Results
Convert query results to other representations. See Lua library for details.

Bug reports and feature requests
Please report software bugs and feature requests on the talk page.