Commit graph

60 commits

Author SHA1 Message Date
Arlo Breault 1d687e23f3 Use the dir parameter only from the full definition of a named ref tag
Bug: T196827
Change-Id: Iaf84966e37cea730c9eca07c19a555971ffeadf3
2018-08-22 19:31:23 -04:00
James D. Forrester a33f107079 VE: Make the OOUI citation icons available
This allows on-wiki use to be migrated to the standard icons rather than
in-repo ones, so that they can (later) be removed.

Change-Id: I19bec075c77396f163977962bbe1afb69a231c1e
2018-08-14 11:55:44 -07:00
Timo Tijhof e86ffeba3a Deal with <references/> inside a <ref> in automatic references list
The Cite extension already had a recursion guard around the parsing of
`<references/>`, to prevent another `<ref>` containing `<references/>`
from producing a weirdly nested references list.

When an explicit `<references/>` tag is not included in the page, or
`<ref>` tags exist after the last explicit `<references/>`, the extension
automatically adds a reference list at the end of the page, to make the
references still displayed.

This automatic references list creation was bypassing the recursion
guard, causing the weirdly nested output *and* a PHP Notice from
`mRefs[$group]` becoming undefined. This commit sets the recursion guard
state during that automatic references list creation to prevent this.

Bug: T182929
Change-Id: I87737dcf39a4fc15e119a1090a9c34d6b9633c21
2018-07-25 15:39:20 +00:00
Umherirrender 2e4222bd04 Remove reference to archived InlineEditor
Change-Id: Ie549357942a321962e5886c767d36975074f6cb6
2018-05-17 19:24:39 +02:00
Thiemo Kreuz 0fe9dbb366 Don't expect objects by reference in hook handlers
The motivation for this patch is to make the code less complex, better
readable, and less brittle.

Example:

public function onExampleHook( Parser &$parser, array &$result ) {
    /* This is the hook handler */
}

In this example the $result array is meant to be manipulated by the
hook handler. Changes should become visible to the caller. Since PHP
passes arrays by value, the & is needed to make this possible.

But the & is misplaced in pretty much all cases where the parameter is
an object. The only reason we still see these & in many hook handlers
is historical: PHP 4 passed objects by value, which potentially caused
expensive cloning. This was prevented with the &.

Since PHP 5 objects are passed by reference. However, this did not
made the & entirely meaningless. Keeping the & means callees are
allowed to replace passed objects with new ones. The & makes it look
like a function might intentionally replace a passed object, which is
unintended and actually scary in cases like the Parser. Luckily all
Hooks::run I have seen so far ignore unintended out-values. So even if
a hook handler tries to do something bad like replacing the Parser
with a different one, this would not have an effect.

Removing the & does not remove the possibility to manipulate the
object. Changes done to public properties are still visible to the
caller.

Unfortunately these & cannot be removed from the callers as long as
there is a single callee expecting a reference. This patch reduces the
number of such problematic callees.

Change-Id: Ib3a9da257b50326d569ab1973b523c952963c16b
2018-05-17 17:09:55 +00:00
Thiemo Kreuz 8a42f61697 Remove all default "return true" from all hook handlers
This is the default for many years now. Returning true does nothing. It's
identical to returning nothing (null). The only meaningful value a hook
handler can return is false, and even this is meaningful only for very
few hooks.

TL;DR: A "return true" in a hook handler is always meaningless, dead code.

I'm interested in this because we (WMDE) might start working on this
extension soon and I want the code to be small and easy to maintain.

Change-Id: If4f32a55cdc38a3cc8af286d1cca7c0089bbfc43
2018-05-15 10:43:23 +02:00
jenkins-bot cfd18814be Merge "Support directionality for reference" 2018-05-02 15:59:33 +00:00
Eranroz 1ca27aa0d8 Support directionality for reference
Adding option for dir attribute in ref tags. The value must be a valid
direction ('ltr' or 'rtl', case insensitive) or the direction will be
stripped out.

The directionality of the li element is set using a css class accordingly.

Bug: T15673
Change-Id: Iff480bc8cc4f81403b310e8efecd43e29d1d4449
2018-05-02 17:27:32 +02:00
jenkins-bot d85b33b04a Merge "CiteDataModule: Remove origin restriction" 2018-04-30 20:35:21 +00:00
Bartosz Dziewoński 2e35d29223 CiteDataModule: Remove origin restriction
Without this change it would no longer load in safe mode (T185303)
because the module would be missing.

I think this has been copy-pasted from VisualEditor, see commit
I6d097ccbf1dc2462843219adcf96bf8313e30289 there for explanation.

Bug: T185303
Change-Id: I6f6857ec50e7b8c6e25022024c29b59726c656e3
2018-04-30 22:18:06 +02:00
MGChecker 5ca090c67d Clean up backwards-compatibility code
Since Cite requires 1.25+ now, the checks for PPFrame::setVolatile(),
which was introduced in 1.24, can be removed.

Change-Id: I91df2e91b2f7a21b2b1147aa6af194980527f86b
2018-04-18 22:26:54 +02:00
Ed Sanders b8a9115d27 Use resource loader for icons
Change-Id: I6614d2b33936e4e4f04412b76df67dc5554bf3f7
2018-04-11 17:56:19 +01:00
Thalia a2722ca947 Add separate message for missing reference in references list
Message indicates that a preview of the reference is missing,
instead of implying that the user was trying to edit it.

Bug: T188682
Change-Id: I5f5f8d5d0910ab2608696bbed380d4592cb6c7f1
2018-03-24 17:32:55 +00:00
Thiemo Mättig bbc1f2c91d Use standard form for @license tags
See https://spdx.org/licenses/

Change-Id: Ic091ebc3844abcd6de90b3241382fb4732200a6d
2018-03-20 03:18:37 +00:00
jenkins-bot a6ec270d65 Merge "Remove failed experiment $wgCiteCacheReferences" 2018-02-28 19:47:40 +00:00
Tim Starling db85682b63 Remove failed experiment $wgCiteCacheReferences
This was briefly enabled in WMF production in 2009 and found not to work.
As far as I know, it's been disabled since then. Retaining it requires
maintaining the complex "half-parsed serialization" feature in the core
parser, which I'm deprecating in I838d7ac7f9a218. The core feature was
added solely to support this Cite caching experiment and is not used for
anything else.

Change-Id: I446e0c46913a390dbdf7b49b84040bf47ed6c2f9
2018-02-28 21:04:42 +11:00
James D. Forrester 43344b56b0 VisualEditor: Describe reflist responsiveness changes too
Bug: T160589
Change-Id: Idb590bf0f3edbe8d056f544a148323da30211467
2018-02-22 16:01:46 -08:00
Ed Sanders 8e5ae11be0 Create first unit test for reference diffs
Depends-On: Ia34b535c34aeed933164a18a0be76d7c0ac28bc6
Depends-On: Ic70bd3e8ba090c2d174164fd1ecebdf6f2225254
Change-Id: Ib8b485663dea6fcc50c0197451d0a553e5d89c27
2018-02-13 19:22:58 +00:00
Ed Sanders 495d9420f0 Treat template-generated reference lists as real ones
This will allow them to auto-update, and be used in the
visual diff.

We record a templateGenerated attribute to prevent them
being edited, and to ensure they roundtrip back to
templates.

Bug: T52769
Change-Id: I4460d2c98166581e942e35921b20091990f5f6c7
2018-02-07 10:48:57 +00:00
jenkins-bot 6b1e7e126f Merge "doc: Bump copyright year" 2018-01-03 19:18:07 +00:00
Kunal Mehta 1e6ff5c2fc Address PhanUndeclaredClassMethod warning
Don't use the \Database alias, use the namespaced version when calling
Database::getCacheSetOptions.

And document why the remaining issue is suppressed.

Change-Id: I80a102f2e82efedcfa999d8e714bfe049263ffeb
2018-01-03 16:34:01 +00:00
James D. Forrester 0999d771b6 doc: Bump copyright year
Also make the overly-terse statement clearer.

Change-Id: I752bb82444bf7cb41480076bace42331dc35a598
2018-01-02 17:05:50 -08:00
libraryupgrader 1ca3dd57be build: Updating mediawiki/mediawiki-codesniffer to 15.0.0
Change-Id: I11e6d584932dbde52fc5e5d463029270976a47df
2017-12-29 23:28:16 +00:00
Thiemo Mättig 9c8ed18938 Remove some obscure comments
A good bunch of these comments literally repeats what the code already
says.

Change-Id: I9c128f748971bf20a61a85ed57d3261d27c465f0
2017-12-29 12:21:53 -08:00
Phantom42 67ed343ecc Add phan configuration for static analysis
Bug: T179554
Change-Id: I2bfd52c08aac1aa8f34e0664e6314835f79a0324
2017-12-29 11:50:01 -08:00
Umherirrender 817c8a95bd Change typehint from DatabaseBase to IDatabase
Change-Id: I34bde9717d7799406dd9a30e8f9b610da53f374c
2017-12-22 21:28:29 +01:00
Max Semenik 351a08d1b7 Don't break when reference names contain []
Bug: T29694
Bug: T179544
Depends-On: I189bdefbc9034cf8d221a89d7158195de1c0fa6c
Change-Id: Iec3439f76ecc2a3543b30b35f8735c92b0cfb711
2017-11-15 23:23:45 +00:00
Alexander Mashin 3023f55605 T177134: Nulls passed to preg_match in Cite
Line 334 of Cite/includes/Cite.php contains two preg_match () calls. The subject lines for them are produced by Cite::refArgs () and are set to null or false when no name or follow attribute is provided in the <ref></ref> tag.

However, preg_match () is supposed to accept only strings as its subject, and the nowhere in the documentation it is said that it is nullable.

At least, in HHVM 3.12 this causes an exception.

The enclosed patch adds simple checks making sure that preg_match () is not called when $key or $follow are null or false.

Change-Id: I3e00d31d6bf216271ace7e851d88c68c4fd5ed00
2017-10-11 17:01:37 +00:00
Umherirrender 0802a73cae Improve some parameter docs
Change-Id: I7d50eaabfba309a62d1dbd16ded0cbcab3beb82f
2017-10-06 21:22:30 +02:00
jenkins-bot d0199aaf53 Merge "Use HTML5 id attributes; remove use of deprecated Sanitizer::escapeId()" 2017-10-03 22:23:42 +00:00
C. Scott Ananian 14459c226b Use HTML5 id attributes; remove use of deprecated Sanitizer::escapeId()
When using HTML5 ids, we need to take greater care to properly escape the
id (or derived strings) before passing them back through
Parser::recursiveTagParse().

Bug: T176170
Change-Id: I89a4f8ba24b867f2d5ccdc2bf9a4312ab9b385a9
2017-09-19 15:42:41 -04:00
Ed Sanders a3a4bd945b VE: Support 'responsive' attribute
Bug: T53260
Change-Id: I1e0ae39e8c30653b7ba0f537723a4bcd79ac3162
2017-09-19 17:03:39 +01:00
Arlo Breault d465b4e001 API: Expose $wgCiteResponsiveReferences via meta=siteinfo
Bug: T159894
Change-Id: I2404999ab11b5cf7b740ae43696c4676ab1b6d22
2017-09-11 23:04:25 -04:00
jenkins-bot 8b51182b13 Merge "VisualDiff: Show less information about ref nodes" 2017-09-05 13:27:38 +00:00
Thalia ed8b563add VisualDiff: Show less information about ref nodes
If a ref node is highlighted as changed because its index
has changed (e.g. because an earlier reference was inserted
or removed), describe this more elegantly.

Bug: T170235
Bug: T171377
Change-Id: I2513bb82099a92529516e4e217e61a2d0a2dd43b
2017-09-05 14:01:39 +01:00
Max Semenik 14b17e8c32 DB_SLAVE -> DB_REPLICA
Change-Id: I3e949fcf15b44ee199830df19f6db039a704b450
2017-09-01 17:06:45 -07:00
Kunal Mehta b46b060f2f build: Updating mediawiki/mediawiki-codesniffer to 0.10.1
Change-Id: Icc6b4568557583a62a630bd1d5a889fc3cad77bc
2017-07-23 00:10:18 -07:00
jenkins-bot 8b3ca486a6 Merge "Visual diff: Show correct reference indices in diff" 2017-06-26 19:35:32 +00:00
Thalia 1a5d90b4e3 Visual diff: Show correct reference indices in diff
Bug: T162819
Change-Id: I7eec4ee12a24ff99388cc0c95a24d50f321511f9
2017-06-26 19:19:03 +00:00
jenkins-bot 66dabf8821 Merge "VisualEditor: Add a placeholder to MWReferenceDialog to make it less awful when empty" 2017-06-20 19:19:03 +00:00
Kunal Mehta 635ee1cce0 build: Updating mediawiki/mediawiki-codesniffer to 0.9.0
The following sniffs are failing and were disabled:
* MediaWiki.Commenting.FunctionComment.MissingParamComment
* MediaWiki.Commenting.FunctionComment.MissingParamName
* MediaWiki.Commenting.FunctionComment.MissingParamTag
* MediaWiki.Commenting.FunctionComment.MissingReturn
* MediaWiki.Commenting.FunctionComment.ParamNameNoMatch
* MediaWiki.Commenting.FunctionComment.WrongStyle
* MediaWiki.FunctionComment.Missing.Public
* MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment

Change-Id: I5a7f01d6d5d8b56583940524b251d4de1ca09f5e
2017-06-19 19:32:30 -07:00
James D. Forrester 347f21d11e VisualEditor: Add a placeholder to MWReferenceDialog to make it less awful when empty
Change-Id: I086d7243127ee411ea043bf29f4d4a5ae5d657a0
2017-06-17 01:21:48 +00:00
Bartosz Dziewoński f07c7a2e10 Add appropriate OOjs UI icon pack dependencies
modules/ve-cite/ve.ui.MWReferenceDialog.js
* Add 'alerts' as it uses 'alert'
* Add 'interactions' as it uses 'settings'

Bug: T166730
Change-Id: I39d98c197220d463f18d473a9605e242ec9755a9
2017-06-03 12:45:02 +02:00
James D. Forrester 9a17d9342b Describe group changes for references and references lists
Bug: T160589
Change-Id: Ifccafdf08704f67027dae2703ff2ded809fb6ab7
2017-05-20 14:26:58 +00:00
jenkins-bot e5c5886287 Merge "doc: Bump copyright year notice, 'team' name" 2017-04-20 23:24:51 +00:00
James D. Forrester efce5f2b49 Drop the pointless "AllowCiteGroups" config setting
Bug: T161144
Change-Id: Ie1454926b8bfa108a62d088991e66b6dae9c9f10
2017-04-20 22:56:08 +00:00
James D. Forrester 0d20873fa6 doc: Bump copyright year notice, 'team' name
Change-Id: Ia090c417a1aa716b255613199b5e49616bf0517a
2017-04-20 16:50:43 +00:00
Ed Sanders 5b477ce3a1 Bring in wikitext paste tests from ve-mw
Depends-On: Ibea6994a208e4b0b1022896eb31dd2f36f0fd6c6
Change-Id: I244570c39e2f3595137c02e62cb91ba8eeab8a4a
2017-04-20 16:27:50 +00:00
James D. Forrester ddb3e9088a i18n: Don't try to spell out all the options that are allowed
Bug: T160628
Change-Id: Ibf728277c5bd4df5d3e8534848ee686239090376
2017-04-08 04:10:29 +00:00
Timo Tijhof 04c3ad0107 Implement responsive columns for reference lists
This is based on the popular 'count' parameter from Template:Reflist on
English Wikipedia, which has also been adopted by many other wikis.

That template's 'count' parameter allows maximum flexibility on a per-
page basis. This was important because the template can't know how many
references the list will contain. Users typically manually add (and
later, increment) the 'count' parameter when the list exceeds a certain
threshold.

The template currently sets an exact column count (via the CSS3
property `column-count`).

This patch improves on that by instead using the closely related CSS3
`column-width` property. This automatically derives the column count
based on the available space in the browser window. It will thus create
two or three columns on a typical desktop screen, and two or no columns
on a mobile device.

The specified width is the minimum width of a column. This ensures that
the list is not split when rendered on a narrow screen or mobile device.

It also hooks into the raw list before parsing and adds the class only
when the list will contain more than a certain number of items. This
prevents very short lists from being split into multiple columns.

Templates like Template:Reflist on English Wikipedia currently are not
able to set inline styles on the list element directly, which is why
they set it on a `<div>` wrapping the `<references />` output. Because
of this, the feature of the Cite extension must not be enabled at the
same time, as that would result in both the template's wrapper and the
references list being split. The end result would involve sitations with
three columns split in four sub-columns, creating a complicated mess of
nine intermixed columns.

To provide a smooth migration for wikis, this feature can be disabled by
default using `$wgCiteResponsiveReferences = false`. Each individual
template createing reference list can then be migrated, by removing the
wrapper column styles and instead settting the new "responsive"
attribute, like so: `<references responsive />`.

Once any conflicting templates have been migrated, the default for the
wiki can be swapped by setting `$wgCiteResponsiveReferences = true`.

If wikis wish for some templates to keep their custom column splitting
behaviour, templates can also opt-out by setting `responsive="0"`, which
will make sure that it will keep behaving the current way even after the
feature becomes enabled by default for the wiki.

In summary, when disabled by default, pages can opt into this system
with `<references responsive />`. When enabled by default, pages can opt
out of the system with `<references responsive=0 />`.

* Deprecate cite_references_prefix/cite_references_suffix.

  This message is rarely used and opens up compatibility hazards.
  It was already removed by Parsoid, but the PHP implementation
  still had it. It's typically used to add inline styles to the
  wrapper which is more appropiately done in Common.css (or
  obsoleted as part of the skin or Cite extenion itself nowadays
  depending on what style in question).

  It was also a HTML-style message with separated open and close
  segments, which is an anti-pattern in itself.

* Declare module target explicitly and include mobile. The absence of
  this stylesheet caused subtle BiDi/RTL bugs on mobile.

Bug: T33597
Change-Id: Ia535f9b722e825e71e792b36356febc3bd444387
2017-03-07 22:42:47 +00:00