mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-12-18 01:30:32 +00:00
Merge two code paths about <references> sections
I'm not sure how much this helps. But this merges two code paths that are both about "we are in the middle of a <references> section right now. Nothing changes, as proven by the tests. Bug: T353266 Change-Id: I446e224b81d35c47736a437d78527c0cc8636f77
This commit is contained in:
parent
e64d944194
commit
bb01b0d74b
21
src/Cite.php
21
src/Cite.php
|
@ -147,23 +147,20 @@ class Cite {
|
||||||
// @phan-suppress-next-line PhanParamTooFewUnpack No good way to document it.
|
// @phan-suppress-next-line PhanParamTooFewUnpack No good way to document it.
|
||||||
$status->merge( $validator->validateRef( $text, ...array_values( $arguments ) ) );
|
$status->merge( $validator->validateRef( $text, ...array_values( $arguments ) ) );
|
||||||
|
|
||||||
if ( !$status->isGood() && $this->inReferencesGroup !== null ) {
|
|
||||||
// We know we are in the middle of a <references> tag and can't display errors in place
|
|
||||||
foreach ( $status->getErrors() as $error ) {
|
|
||||||
$this->mReferencesErrors[] = [ $error['message'], ...$error['params'] ];
|
|
||||||
}
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validation cares about the difference between null and empty, but from here on we don't
|
// Validation cares about the difference between null and empty, but from here on we don't
|
||||||
if ( $text !== null && trim( $text ) === '' ) {
|
if ( $text !== null && trim( $text ) === '' ) {
|
||||||
$text = null;
|
$text = null;
|
||||||
}
|
}
|
||||||
[ 'group' => $group, 'name' => $name ] = $arguments;
|
|
||||||
|
|
||||||
if ( $this->inReferencesGroup !== null ) {
|
if ( $this->inReferencesGroup !== null ) {
|
||||||
if ( $text !== null ) {
|
if ( !$status->isGood() ) {
|
||||||
$this->referenceStack->setText( $group, $name, $text );
|
// We know we are in the middle of a <references> tag and can't display errors in place
|
||||||
|
foreach ( $status->getErrors() as $error ) {
|
||||||
|
$this->mReferencesErrors[] = [ $error['message'], ...$error['params'] ];
|
||||||
|
}
|
||||||
|
} elseif ( $text !== null ) {
|
||||||
|
// Validation made sure we always have group and name while in <references>
|
||||||
|
$this->referenceStack->setText( $arguments['group'], $arguments['name'], $text );
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@ -181,7 +178,7 @@ class Cite {
|
||||||
$ref = $this->referenceStack->pushRef(
|
$ref = $this->referenceStack->pushRef(
|
||||||
$parser->getStripState(), $text, $argv, ...array_values( $arguments ) );
|
$parser->getStripState(), $text, $argv, ...array_values( $arguments ) );
|
||||||
return $ref
|
return $ref
|
||||||
? $this->footnoteMarkFormatter->linkRef( $parser, $group, $ref )
|
? $this->footnoteMarkFormatter->linkRef( $parser, $arguments['group'], $ref )
|
||||||
: '';
|
: '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue