mirror of
https://github.com/Universal-Omega/PortableInfobox.git
synced 2024-11-14 19:31:44 +00:00
Don't reparse infoboxes in templates every time in PIDataService
This commit is contained in:
parent
2c2553a253
commit
30a6c6a094
|
@ -36,7 +36,12 @@ class PortableInfoboxHooks {
|
|||
* @return bool
|
||||
*/
|
||||
public static function onPageContentSave( Page $article ) {
|
||||
PortableInfoboxDataService::newFromTitle( $article->getTitle() )->delete();
|
||||
$dataService = PortableInfoboxDataService::newFromTitle( $article->getTitle() );
|
||||
$dataService->delete();
|
||||
|
||||
if ( $article->getTitle()->inNamespace( NS_TEMPLATE ) ) {
|
||||
$dataService->reparseArticle( true );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -62,11 +62,7 @@ class PortableInfoboxDataService {
|
|||
* @return array in format [ [ 'data' => [], 'metadata' => [] ] or [] will be returned
|
||||
*/
|
||||
public function getData() {
|
||||
if ( $this->title->exists() && $this->title->inNamespace( NS_TEMPLATE ) ) {
|
||||
$result = $this->reparseArticle();
|
||||
} else {
|
||||
$result = $this->get();
|
||||
}
|
||||
$result = $this->get();
|
||||
|
||||
return $result ? $result : [];
|
||||
}
|
||||
|
@ -197,7 +193,7 @@ class PortableInfoboxDataService {
|
|||
return [];
|
||||
}
|
||||
|
||||
protected function reparseArticle() {
|
||||
public function reparseArticle() {
|
||||
if ( $this->title->inNamespace( NS_TEMPLATE ) ) {
|
||||
$result = $this->parsingHelper->parseIncludeonlyInfoboxes( $this->title );
|
||||
} else {
|
||||
|
@ -231,6 +227,7 @@ class PortableInfoboxDataService {
|
|||
$infobox['parser_tag_version'] !== PortableInfoboxParserTagController::PARSER_TAG_VERSION
|
||||
) {
|
||||
$infoboxes = $this->reparseArticle();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,7 +101,7 @@ class PortableInfoboxDataServiceTest extends MediaWikiTestCase {
|
|||
->purge()
|
||||
->setPagePropsProxy( new PagePropsProxyDummy() )
|
||||
->setParsingHelper( new ParsingHelperDummy( null, $data ) )
|
||||
->getData();
|
||||
->reparseArticle();
|
||||
|
||||
$this->assertEquals( $data, $result );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue