Commit graph

100 commits

Author SHA1 Message Date
physikerwelt a7a072edc0 Ignore parsers without extCite
If a parser does not include the extCite property, ignore
the call and do not check references.

Depends on Ic77aa79aa6e2bf2a9ec00be4cc775d0123bed91a

Bug: T105598
Change-Id: Ic2257eef94fd73932f1e95a84b3b8b0eb245bafc
2015-07-22 15:03:10 +00:00
Timo Tijhof de550c717c Hygiene: Main return as root structure (handle errors early)
Restructure code to return early for errors instead of nesting
conditionals. This leaves the outer tree of the function as
the natural flow of the primary purpose.

Makes code more resilient by ensuring that new code added to the
function will not execute under error conditions by removing the
need to keep everything encapsulated in the various levels of
error conditionals.

Change-Id: I1b4a67d344fd9843ca088d008487914f87b1c640
2015-07-18 15:55:32 -05:00
Amir E. Aharoni 147f6ced19 Change == to === according to PHP coding conventions
Change-Id: I2a93194e3c2160000d30f2f2fd7717f4ba501c23
2015-07-07 15:20:53 +03:00
Bartosz Dziewoński 3f30e08d77 Revert "Do all of Cite's real work during unstrip" and followup
This reverts commits 944b245428
and fa7be37d15.

These resulted in too many new exciting behaviors for the improvement
of nested refs behavior to be worth it. We should try again later.

Also, use Parser::MARKER_PREFIX instead of $parser->uniqPrefix()
which has been deprecated in the meantime by 12571bde.

Fixes T101390, fixes T100477. Reopens T22707, reopens T18330.

Bug: T100477
Bug: T101390
Change-Id: I1a71854cf24e85697ab171be43eeec9054bc504c
2015-06-08 16:24:27 +02:00
Derk-Jan Hartman 05cb5cc1a0 Cleanup style RL modules for Cite
Move the JS which is purely for accessibility purposes into a separate
JS RL module named ext.cite.a11y. Move all pure CSS, which is not dependant
on accompanying JS into a separate ext.cite.styles module

Bug: T101559
Change-Id: I58adcfbcf9af2bb3b6d5dabb6c38c42af78e0416
2015-06-06 15:43:27 +02:00
Jackmcbarn fa7be37d15 Don't run references if the output type isn't HTML
It's possible that the output type is set to HTML when extensionSubstitution
is called, but that when we eventually get unstripped, it isn't anymore. If
this happens, detect it and bail out.

Bug: T99787
Change-Id: I32abaefeebc5357a2ab3fd23bcd47aa9b2a1663a
2015-05-25 13:34:02 +00:00
Jackmcbarn 944b245428 Do all of Cite's real work during unstrip
Cite has side effects that currently happen at the same time that the
preprocessor is running. This can cause oddities like references being out
of order, or references showing up in the reference list but never used in
the text. By moving the work to unstrip, only references actually used in
the final text will be present, and the numbering order will always match
the order they were used in the text. This depends on If83b0623 in core.

Change-Id: I0e136f952302b65f1abeeac5273bd842867e1dac
2015-05-13 02:54:37 +00:00
Kunal Mehta db9ff2bd18 Get rid of "wfCite" global function
As of Icdf82cb9771e6, MediaWiki core now looks for the "Cite" class
instead of the "wfCite" global function. The WYSIWYG extension is also
checking for wfCite and a patch was submitted for that in I3de3e069e4be.

Change-Id: Ie0f190b7bd9c9226856f150c95a0b139812dcf98
2015-04-30 11:41:06 -07:00
Kunal Mehta 49c2a5d595 Move CITE_DEFAULT_GROUP constant to Cite::DEFAULT_GROUP
Change-Id: I13c77f78563beb6e4ebf2a6d19327273ee2dbc07
2015-04-30 11:34:47 -07:00
Chad Horohoe b818a87315 Remove obvious function-level profiling
Change-Id: I435365313846d7529601a2440ea2e3c40a5418f3
2015-02-10 13:53:33 -08:00
Ori Livneh ee4d83a1a7 MWException -> Exception
Change-Id: Ibc0d80f6cb66d96eb1bcb71bb1ee1b097c7878e6
2015-01-09 17:47:47 -08:00
Bryan Davis db56e255d4 Guard against unset array access
From prod error logs:
  Undefined index: 0 in Cite_body.php on line 396
  Undefined index: 1 in Cite_body.php on line 396
  Undefined index: 2 in Cite_body.php on line 396
  Undefined index: 3 in Cite_body.php on line 396
  Undefined index: follow in Cite_body.php on line 396

Change-Id: Id727f2fd7e72d8c4ceb74fdac42885d5c030b4af
2015-01-09 09:09:42 -07:00
Amir E. Aharoni c9a5b7b1cb Replace == with test for isset and empty string
The coding conventions suggest avoiding ==,
and for this condition definedness is actually more relevant
than whether the string has any text, but since
the string can also be '0', checking for !$text doesn't work.

Similar to I15b422d3345bf4522e68a17dce9682ff28484559 .

Change-Id: Ib823678b639bf4f1a92dffcd9e41c780b56ab128
2014-10-28 19:07:24 +00:00
Amir E. Aharoni 60a0821634 Replace == with isset
The coding conventions suggest avoiding ==,
and for this condition definedness is actually more relevant
than whether the string has any text.

Change-Id: I15b422d3345bf4522e68a17dce9682ff28484559
2014-10-28 19:06:33 +00:00
Amir E. Aharoni 458fb4e705 Replace srting comparison with boolean condition
In this function $text can be both false and empty string.
It is more intuitive to use a boolean operator here than
to rely on the fact that comparing to '' using == happens
to give the correct result.

Change-Id: I08248a3fcade7744287e9b9f3bc176d29ac1ecde
2014-10-01 17:42:18 +03:00
Amir E. Aharoni f85ae02fa9 iEarly return for readability
Change-Id: I80ccb1766b1635c32669818647aad85db95c4866
2014-10-01 17:25:58 +03:00
Amir E. Aharoni 09a1ae5929 Code cleanup for phpcs
Change-Id: I2419c904629e02e1ec4cb24325acd0e2db1297db
2014-09-27 19:56:47 +03:00
addshore f1c78e330f Use public instead of var in classes
Change-Id: I351e0b776497b9cfa9914400048e5ea9f00b5aac
2014-08-17 22:04:15 +01:00
Jforrester d7fc63b66d Revert "Provide way for users to find articles with the automatic <references />"
Apparently causing parser failures and corruptions in production.

This reverts commit 44472de458.

Change-Id: I923ed39f405d926b70a5098cbde6eee0538eee51
2014-07-24 12:27:02 -07:00
Alex Monk 44472de458 Provide way for users to find articles with the automatic <references />
By adding a tracking category

Bug: 67700
Change-Id: I62584de085ae7a849a099e127bd950692a0dff8a
2014-07-11 22:47:51 +01:00
James D. Forrester 672124cf26 Remove 'experimental' popups functionality that was never used
Bug: 67282
Change-Id: Ib0c8c0daae62c9398f15397917232447c6113069
2014-07-09 11:06:18 -07:00
Alex Monk 798b453771 If there's no main <references /> block on the page, show one automatically below the content
Rather than showing an error

Bug: 66860
Change-Id: I9c7c13269d5ec355ccb280402aa8c0cedd208883
2014-06-23 22:54:28 +01:00
Jackmcbarn 50d8e2e290 Kill code that's been unnecessary since 2006
We've had Parser::recursiveTagParse since MediaWiki 1.8, back in 2006.
Remove code that only gets used if it's not available.

Change-Id: I76eed5570a675a14cf70ab10981661e0bc8bda99
2014-06-05 13:51:48 -04:00
Brad Jorsch d945d82fb1 Mark parser hook output as volatile
Using the new functions introduced in I95b3cf87, mark the output of
<ref> and <references> as volatile so that caching can be avoided.

Bug: 46815
Bug: 31834
Change-Id: I897defba32ac6adf72b6bc9ea7e933a87b1ba17b
2013-12-06 18:43:45 -05:00
Kunal Mehta a94c871cd2 Only load RL modules when a <ref> tag is being used
Bug: 55684
Change-Id: I8f7528ef8468bf3fa1c901fd6dc67b5eebc0cbd6
2013-11-01 13:47:35 +00:00
Kunal Mehta f57bb804a3 Show error messages in content language to avoid cache issues
Bug: 31216
Change-Id: I725a972cbbf14fb179a24ab0682ad497524d4274
2013-10-15 21:38:45 -07:00
Kevin Israel b3becfb569 Add back serialize() calls for internal errors
For a value of the incorrect type, the type in question is a
relevant part of the error message.

Follows-up Ie0271de755a63fcda8a3671cc115af7bc931a02b.

Change-Id: I09d9f1975bdfabffe44a6f69b5296cdcbf03a51e
2013-09-28 19:40:17 +00:00
Kevin Israel a2f4a5a25d Remove calls to wfDebugDieBacktrace
Deprecated in I12336983e29524a450fc61ed9df4d840066be9b6.

Change-Id: Ie0271de755a63fcda8a3671cc115af7bc931a02b
2013-09-27 21:52:39 -04:00
Ed Sanders 4f3f9068b0 Add more specific class to cite errors
Problem:

* VisualEditor needs to be able to more reliably target Cite errors.

Solution:

* Add a more specific class to cite errors

Grumble:

* Ideally all extensions would use mw-ext-{extension name} as a prefix to
  their CSS classes (or something similar).

Bug: 51337
Change-Id: If4f5360cc1c7b765ad896b14901a9b024782cc93
2013-07-15 01:46:53 +00:00
Brad Jorsch e7de455f88 (bug 47291) Make sure cloned Cite is cleared
The cloned Cite object in the ParserCloned hook must be cleared, even if
the clone occurs inside a <ref> or <references> tag. The simple way to
do this is to set mInCite and mInReferences to false before calling
clearState().

While Cite could probably use a major cleanup, let's fix this bug now
instead of waiting for someone to get around to it.

Bug: 47291
Change-Id: Id3e91c41dc33a703b5326961fd57e1fe8ac61f5b
2013-04-16 15:52:49 -04:00
Brad Jorsch 73f856820e (bug 32368) Handle cloned parsers
If the parser is cloned, we need to clone our data object and
reassociate the hooks. Otherwise references may be lost when the clone
has ParserClearState called.

Change-Id: Ic1d75850e8d610ea890e34c38d062a358fd55178
Depends-On: Ieec65c908d71e89b9a66f83b9a626f842aadacbb
2013-02-22 21:24:14 +00:00
Brad Jorsch e6c76b5d23 (bug 13073) Work around Tidy confusion
If the <references> tag is wrapped (e.g. <div><references></div>) and
the first ref on the page contains a newline, Tidy will get confused and
insert extra paragraph breaks in the output.

We can avoid this easily enough by inserting a newline between
MediaWiki:cite_references_prefix and the first reference's <li>.

Note since this changes the output we also have to adjust the parser
tests to expect the new output.

Change-Id: I8222d53eaf2b20f842915fe90af724711a20bfc5
2012-11-26 19:29:03 +01:00
eranroz da8e6f3b45 Cite anchors should be numbered starting at 1
Fix for bug 10537: Cite anchors should be numbered starting at 1
On the way a small refactoring (getting rid of redundant variable)

Change-Id: Iee94917f3f860516cc310d1cdb1c4f9065d40984
2012-10-18 01:03:31 +02:00
Siebrand Mazeland 52ca5a1a5a Maintenance for Cite extension.
* Update deprecated calls.
* Remove superfluous newlines.
* Add @todo where uncertain.

Change-Id: Ifc79b199fa551c23fafa190664688c8320059338
2012-08-30 10:41:27 +02:00
Brad Jorsch 4933d7a682 (bug 17865) Fix wikilinking in "refs without references" error
The [[MediaWiki:Cite error refs without references]] message does not
correctly display wikilinks. This is because it takes effect during
ParserBeforeTidy, which misses the call to replaceLinkHolders(). And
parsing directly to HTML (with MessageCache::singleton()->parse()) would
lose categories and such added by the error message.

Gerrit change Iaa2755f994edb081eb1d176f632f7add41640dbf adds a
"ParserAfterParse" hook, which can be used to add this message in time
to be correctly handled by replaceLinkHolders().

Change-Id: I093d85d8f8c2ac3238609d145ae5b985602bb3fd
Depends-On: Iaa2755f994edb081eb1d176f632f7add41640dbf
2012-08-07 13:16:46 -04:00
Sam Reed 714af9033f Many other occurance/occurence typos 2012-03-19 14:59:29 +00:00
Max Semenik 53ae80785a Follow-up r102160: removed arrows from tooltips 2012-01-04 15:00:01 +00:00
Roan Kattouw 2142134491 (bug 17865) Fix double-parsed error messages in Cite. Modified patch by Brad Jorsch 2011-11-14 12:22:07 +00:00
Roan Kattouw 7103224ce0 (bug 20050) References containing numbered lists cause Tidy to corrupt the references list. Patch by Brad Jorsch 2011-11-14 12:02:23 +00:00
Gabriel Wicke f876382e67 Back out accidentally-committed r102967. 2011-11-14 11:14:39 +00:00
Gabriel Wicke 4a2232bbe2 Fixes bug #17865 2011-11-14 11:06:42 +00:00
Sam Reed 607f9bbd27 Whitespace/documentation 2011-09-14 15:07:20 +00:00
Platonides e9dff9d1e2 Follow up r89220. Misleading comment left from r88971 2011-05-31 17:51:30 +00:00
Platonides 9fc91b9899 Remove Cite singleton. Store it inside each associated parser at $parser->extCite
This fixes bug 20748 and bug 15819 without breaking the other tests. Reverts r88971.
The conflict with CategoryTree was the old problem of a message being called inside 
of a parser callback, this time with clearState for which the hook is global.
2011-05-31 17:49:22 +00:00
Sam Reed c48d4b674b Documentation 2011-05-28 20:44:24 +00:00
Kevin Brown 37ff765a58 Fix bug 20748 and bug 15819. 2011-05-27 15:22:36 +00:00
Sam Reed 3e5bbe33e7 Remove whitespace, unneeded globals, and swap and/or for &&/|| 2011-04-27 11:11:54 +00:00
Jan Paul Posma 68ea91084d Followup of r82891 and r82894. Fixes hook for InlineEditor, which forces a page reparse when either a <ref> or <references> tag shows up. Doesn't affect normal behaviour when not using InlineEditor. 2011-03-04 11:45:22 +00:00
Jan Paul Posma 1aac56bb83 Fixed call per http://www.mediawiki.org/wiki/Special:Code/MediaWiki/82891#c14483 2011-02-27 15:30:35 +00:00
Jan Paul Posma efb47a9d90 Added hook to support partial rendering for the InlineEditor extension. Doesn't affect normal behaviour. 2011-02-27 14:50:56 +00:00