Add category output to ApiExpandTemplates
The preprocessor sometimes adds pages to categories itself, which don't have any representation in the output of ApiExpandTemplates. Because of this, add a new field containing these categories. Change-Id: I7ae2eb9daf68e032dcc7a650bd8391d445ee1037
This commit is contained in:
parent
d18ba4e9df
commit
e658bf0402
1 changed files with 12 additions and 0 deletions
|
|
@ -70,6 +70,18 @@ class ApiExpandTemplates extends ApiBase {
|
|||
}
|
||||
$frame = $wgParser->getPreprocessor()->newFrame();
|
||||
$retval = $wgParser->preprocess( $params['text'], $title_obj, $options, null, $frame );
|
||||
$categories = $wgParser->getOutput()->getCategories();
|
||||
if ( !empty( $categories ) ) {
|
||||
$categories_result = array();
|
||||
foreach ( $categories as $category => $sortkey ) {
|
||||
$entry = array();
|
||||
$entry['sortkey'] = $sortkey;
|
||||
ApiResult::setContent( $entry, $category );
|
||||
$categories_result[] = $entry;
|
||||
}
|
||||
$result->setIndexedTagName( $categories_result, 'category' );
|
||||
$result->addValue( null, 'categories', $categories_result );
|
||||
}
|
||||
|
||||
// Return result
|
||||
$retval_array = array();
|
||||
|
|
|
|||
Loading…
Reference in a new issue