Cenarium has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/277446

Change subject: Cleanup references data in API call
......................................................................

Cleanup references data in API call

This cleanups the references data returned by the API.
Text is trimed and strip markers removed. Count is set
to its usual meaning and number param is removed.

Change-Id: I251a08cd8c7a51ad9b58234fd6e8692d40ae79d4
---
M ApiQueryReferences.php
1 file changed, 24 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Cite 
refs/changes/46/277446/1

diff --git a/ApiQueryReferences.php b/ApiQueryReferences.php
index a91f9ee..95e8504 100644
--- a/ApiQueryReferences.php
+++ b/ApiQueryReferences.php
@@ -74,6 +74,30 @@
                                                        }
                                                        $ref['group'] = $group;
                                                        $ref['reflist'] = 
$index;
+
+                                                       // remove spaces or 
newlines added at the beginning or end of refs
+                                                       $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'] );
+
+                                                       // core and extension 
tags (including <ref>, <nowiki>, etc)
+                                                       // inside {{#tag:ref}} 
calls get replaced by the parser with
+                                                       // a strip marker 
before Cite::ref is called and the original
+                                                       // wikitext cannot be 
recovered at this point, so remove them
+                                                       $stripState = new 
StripState();
+                                                       $text = 
$stripState->killMarkers( $ref['text'] );
+                                                       if ( $ref['text'] !== 
$text ) {
+                                                               $ref['text'] = 
$text;
+                                                               // let callers 
know about the removed strip markers
+                                                               $ref['markers'] 
= true;
+                                                       }
+
                                                        $allReferences[$id] = 
$ref;
                                                }
                                        }

-- 
To view, visit https://gerrit.wikimedia.org/r/277446
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I251a08cd8c7a51ad9b58234fd6e8692d40ae79d4
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

Reply via email to