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:
Jackmcbarn 2014-05-29 13:50:27 -04:00
parent d18ba4e9df
commit e658bf0402

View file

@ -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();