Cenarium has uploaded a new change for review. https://gerrit.wikimedia.org/r/272657
Change subject: Cleanup references parameters before saving them to the database ...................................................................... Cleanup references parameters before saving them to the database Before saving references data, this processes the 'text' parameter by trimming it. This also provides a more meaningful 'count', that actually corresponds to the number of ref tags referencing a single named ref. And it removes the 'number'param that is only needed internally by Cite. Change-Id: Ib3fbf0075002e815d049c47acb571f51873c378f --- M CiteHooks.php 1 file changed, 30 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Cite refs/changes/57/272657/1 diff --git a/CiteHooks.php b/CiteHooks.php index a2df9ef..e69b477 100644 --- a/CiteHooks.php +++ b/CiteHooks.php @@ -82,6 +82,7 @@ if ( $refData === null ) { return; } + $refData = self::processReferencesData( $refData ); if ( $wgCiteCacheRawReferencesOnParse ) { // caching $cache = ObjectCache::getMainWANInstance(); @@ -103,6 +104,35 @@ } /** + * @param array $refData + */ + private static function processReferencesData( $refData ) { + $refs = $refData['refs']; + foreach ( $refs as $index => $listing ) { + foreach ( $listing as $group => $refsInGroup ) { + foreach ( $refsInGroup as $key => $ref ) { + // remove spaces or newlines added at the beginning or end of references + $ref['text'] = trim( $ref['text'] ); + + // return more meaningful count + if ( $ref['count'] < 0 ) { + $ref['count'] = 1; + } else { + $ref['count']++; + } + + // remove 'number' param, of no use after parse + unset( $ref['number'] ); + + $refs[$index][$group][$key] = $ref; + } + } + } + $refData['refs'] = $refs; + return $refData; + } + + /** * Callback for LinksUpdateComplete hook * If $wgCiteCacheRawReferencesOnParse is set to false, purges the cache * when references are modified -- To view, visit https://gerrit.wikimedia.org/r/272657 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib3fbf0075002e815d049c47acb571f51873c378f Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Cite Gerrit-Branch: master Gerrit-Owner: Cenarium <cenarium.sy...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits