Skip to content

Commit

Permalink
Ported mocha templatedata.js to phpunit TemplateDataTest.php
Browse files Browse the repository at this point in the history
* Found an issue with WikitestSerializer where under test
  conditions of new content, NoFormatWithParamOrder it accesses
  $tplData['params'] which are not set causing a crash. I
  removed $params as a seperate variable and allow the merged
  $aliases = $tplData['params'][$key]['aliases'] ?? [];
  to define an empty array if it is not set.

Bug: T237693
Change-Id: I802444e426bd6819bcd628a26ce93cd48b6af1f7
  • Loading branch information
simmunity authored and jenkins-bot committed Dec 4, 2019
1 parent b81bbf4 commit 462ac75
Show file tree
Hide file tree
Showing 2 changed files with 435 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/Html2Wt/WikitextSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -614,13 +614,12 @@ private function createParamComparator(
$aliasMap = [];
$keys = [];
if ( $tplData && isset( $tplData['paramOrder'] ) ) {
$params = $tplData['params'];
foreach ( $tplData['paramOrder'] as $i => $key ) {
$tplDataOrder[$key] = [ 'order' => $i ];
$aliasMap[$key] = [ 'key' => $key, 'order' => -1 ];
$keys[] = $key;
// Aliases have the same sort order as the main name.
$aliases = $params[$key]['aliases'] ?? [];
$aliases = $tplData['params'][$key]['aliases'] ?? [];
foreach ( $aliases as $j => $alias ) {
$aliasMap[$alias] = [ 'key' => $key, 'order' => $j ];
}
Expand Down

0 comments on commit 462ac75

Please sign in to comment.