Commit graph

210 commits

Author SHA1 Message Date
C. Scott Ananian
97d9659904 Replace deprecated calls to OutputPage::parseInline()
Every one of these seemed to previously use the wrong value for
`$interface` -- the interface messages in ProtectionForm and
SpecialVersion were being parsed as content language (which is the
default for `OutputPage::parseInline`), and the one place where we
have actual data in the content language (the user signature, which
gets parsed in the content language with the rest of the (talk) page
content, see Parser.php::pstPass2) was being parsed as an interface
message!

Forcing the caller to be very explicit about AsContent() or AsInterface()
will help mitigate this in the future, one hopes.

Bug: T198214
Change-Id: Ib9d5d8d733a47c967bdf7db3e23fa39f11687063
2018-10-29 15:34:43 -04:00
C. Scott Ananian
c0ed262053 Use OutputPage::addWikiTextAsInterface() instead of untidy addWikiText()
This change ensures that the output is tidy, and is necessary to support
future parsers which will not be able to produce untidy output.

Bug: T198214
Change-Id: I743f4185a03403f8d9b9db010ff1ee4e9342e062
2018-10-17 10:35:28 -04:00
C. Scott Ananian
e8a53ecf36 Use <div> wrappers instead of <p> in ProtectionForm
<p>-wrappers are fragile in case the wrapped content contains `<div>`,
`<p>` (or wikitext double newlines).  Use <div> wrappers consistently
in MediaWiki.

Bug: T205624
Change-Id: Ieee77f4220c7895ac5dccb2b638baef0dc22c84f
2018-09-27 11:44:15 -04:00
Umherirrender
130ec2523d Fix PhanTypeMismatchDeclaredParam
Auto fix MediaWiki.Commenting.FunctionComment.DefaultNullTypeParam sniff

Change-Id: I865323fd0295aabd06f3e3c75e0e5043fb31069e
2018-07-07 00:34:30 +00:00
Bartosz Dziewoński
5c7b0addd5 Allow limiting comment length by characters rather than bytes in JS
For unfortunate historical reasons, browsers' native maxlength counts
the number of UTF-16 code units rather than Unicode codepoints [1],
which means that codepoints outside the Basic Multilingual Plane
(e.g. many emojis) count as 2 characters each. That could be good
enough, but we want our software to be excellent rather than merely
good enough.

1. Introduce a few new functions, added to the existing modules:
   * mediawiki.String:
     * codePointLength() counts the length of a string in Unicode
       codepoints (characters).
     * trimCodePointLength() trims a string to the desired length in
       Unicode codepoints (characters).
   * jquery.lengthLimit:
     * $.fn.codePointLimit() enforces the specified maximum length in
       codepoints of an input field.
   * mediawiki.widgets.visibleLengthLimit:
     * mw.widgets.visibleCodePointLimit() enforces the maximum length
       in codepoints of an OOUI widget and displays the remaining
       length in an inline label.

2. Add client-side mw.config variables:
   * wgCommentByteLimit for the old byte limit, equal to 255.
   * wgCommentCodePointLimit for the new codepoint limit, equal to 1000.

   Only one of them may be set, depending on which limit should be applied.

3. Make use of both of these new features. For the sake of an example,
   I updated the forms shown on action=edit (using visibleCodePointLimit)
   and on action=protect (using codePointLimit). Many remain to be updated.

[1] https://www.w3.org/TR/html5/sec-forms.html#limiting-user-input-length-the-maxlength-attribute

Bug: T185948
Change-Id: Ia1269fd898dabbcf1582618eab46cef97e10a3b1
2018-02-23 22:12:29 +00:00
Umherirrender
a9007e8baf Add missing & to @param documentation to match functon call
Change-Id: I81e68310abcbc59964b22e0e74842d509f6b1fb9
2017-08-11 18:47:46 +02:00
jenkins-bot
258761ce1e Merge "Revert "Added reason suggestion in block/delete/protect forms"" 2017-01-21 19:47:27 +00:00
Florianschmidtwelzow
4b49705613 Revert "Added reason suggestion in block/delete/protect forms"
See the task, this was probably entirely my fault not having
looked at this more carefully. Technically the change is ok,
however, it seems to doesn't make much sense in combination
with the Reason dropdown box.

This reverts commit faab2411c2.

Task: T34950
Change-Id: I1eeb9c68ff0db20d29e7d5f0fb18f0bfa3224416
2017-01-21 20:03:45 +01:00
Yuriy Shnitkovskiy
55667f024d Replaced all deprecated Linker methods with proper ones in core(1)
Change-Id: Ie3a718dc1eae1507f8829fcf419c64c6846d2cb6
2017-01-20 11:46:13 +02:00
rlot
8c7095be85 Improved parsing in reason suggests
Bug: T155086
Change-Id: I3a3167b7bfd9b5921df1cf3e4a3cf3e1da4ca001
2017-01-11 19:00:00 +01:00
rlot
faab2411c2 Added reason suggestion in block/delete/protect forms
Bug: T34950
Change-Id: I9778c4992b127c36355949665b4fdf7482e7e0e7
2017-01-10 21:18:51 +00:00
Erik Bernhardson
d67197fa11 Cleanup some incorrect return annotations
Most of these are simply changing annotations to reflect
reality. If a function can return false to indicate failure
the @return should indicate it.

Some are fixing preg_match calls, preg match returns 1, 0 or false,
but the functions all claim to return booleans.

This is far from all the incorrect return types in mediawiki, there
are around 250 detected by phan, but have to start somewhere.

Change-Id: I1bbdfee6190747bde460f8a7084212ccafe169ef
2016-12-12 10:15:05 -08:00
Aaron Schulz
56f8bde0fc Avoid master queries on GET in ProtectionForm
Bug: T92357
Change-Id: I58c5e793164faaafeea45ec5e986edcc7537ccab
2016-05-09 22:12:38 -07:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
Amir E. Aharoni
ddbba62d03 Make lines short to pass phpcs in 2 files under includes/
Bug: T102614
Change-Id: Iae4d4fbdba88ebcd9bcb018a2a0015d0c0ac607c
2015-09-30 05:20:03 +00:00
Geoffrey Mon
0d83dd176f Use XmlSelect in ProtectionForm
Bug: T93234
Change-Id: I47e08fb364dda6e4f59cd84c4c135e267e2c7bd9
2015-07-30 20:00:41 +00:00
umherirrender
f32e0cdd3a Use Linker::linkKnown for some links to MediaWiki pages from navigation
The title used for Linker::link in all places are mediawiki pages, which
are known to be exists (and blue), because there are definied in en.json

Change-Id: Ib3b6e4f4f6cef059a502aaabfcfc17730b4445a6
2015-06-19 18:55:30 +02:00
umherirrender
e51eaf619f Fix edit link for messages in $wgForceUIMsgAsContentMsg
Some special pages or actions have a link for users with editinterface
rights to edit the message used in scroll down menu.
When the message is parsed for the scroll down menu the config
$wgForceUIMsgAsContentMsg is used, but that was not used for the edit
link.

Add a new function Message::getTitle and use it in all places in core.

Most benefit will have the edit link for MediaWiki:Licenses on
Special:Upload, because commons.wikimedia.org has that message in
$wgForceUIMsgAsContentMsg.

Change-Id: Ib800b9adcc9ae88ef53228b66838bf61d2065f0f
2015-05-15 20:38:32 +02:00
Brad Jorsch
ac6f81d9ad Clean up handling of 'infinity'
There's a bunch of stuff that probably only works because the database
representation of infinity is actually 'infinity' on all databases
besides Oracle, and Oracle in general isn't maintained.

Generally, we should probably use 'infinity' everywhere except where
directly dealing with the database.

* Many extension callers of Language::formatExpiry() with $format !==
  true are assuming it'll return 'infinity', none are checking for
  $db->getInfinity().
* And Language::formatExpiry() would choke if passed 'infinity', despite
  callers doing this.
* And Language::formatExpiry() could be more useful for the API if we
  can override the string returned for infinity.
* As for core, Title is using Language::formatExpiry() with TS_MW which
  is going to be changing anyway. Extension callers mostly don't exist.
* Block already normalizes its mExpiry field (and ->getExpiry()),
  but some stuff is comparing it with $db->getInfinity() anyway. A few
  external users set mExpiry to $db->getInfinity(), but this is mostly
  because SpecialBlock::parseExpiryInput() returns $db->getInfinity()
  while most callers (including all extensions) are assuming 'infinity'.
* And for that matter, Block should use $db->decodeExpiry() instead of
  manually doing it, once we make that safe to call with 'infinity' for
  all the extensions passing $db->getInfinity() to Block's contructor.
* WikiPage::doUpdateRestrictions() and some of its callers are using
  $db->getInfinity(), when all the inserts using that value are using
  $db->encodeExpiry() which will convert 'infinity'.

This also cleans up a slave-lag issue I noticed in ApiBlock while
testing.

Bug: T92550
Change-Id: I5eb68c1fb6029da8289276ecf7c81330575029ef
2015-03-13 11:19:53 -04:00
JuneHyeon Bae
511525a136 Refactor out 'infinity' variants
Refactor out 'infinity' vartiant values which used in blocking and
protecting actions. This patchset adds GlobalFunction wfIsInfinity.

Bug: T68646
Change-Id: I60cc55a5bbd43c72916a1c2ea3807457d4e33765
2015-03-12 16:38:02 +00:00
umherirrender
b532948417 Avoid double escaped expiry time on action=protect
Xml::option passed the first param to Html::element which escaped the
value, so no htmlspecialchars is needed for $show. The htmlspecialchar
moved closer to output, because the comparision does not need it

Bug: T85864
Change-Id: Ib8b948563095143de686756ceaf46c48cab2c5e0
2015-01-27 20:44:34 +01:00
umherirrender
82ad84d0ba Use Context on ProtectionForm for messages
Also use Language::userTimeAndDate instead of Language::timeAndDate,
avois using $wgUser for the timezone.

Change-Id: I3547bdc2ee2b787bcb301c4023512e31bc18b67f
2015-01-18 11:19:58 +01:00
Aaron Schulz
e369f66d00 Replace wfRunHooks calls with direct Hooks::run calls
* This avoids the overhead of an extra function call

Change-Id: I8ee996f237fd111873ab51965bded3d91e61e4dd
2014-12-10 12:26:59 -08:00
jenkins-bot
523c6c0e41 Merge "Don't break existing expiry time of "infinity" when modifying protection" 2014-09-18 02:27:56 +00:00
Alex Monk
c805e14eec Clean up mediawiki.legacy.protect a bit.
Also kills some inline JS stuff in ProtectionForm

Bug: 33871
Change-Id: Ie43c80bf5ebd6107458d5284cc68b7128f29359a
2014-09-13 15:43:30 +01:00
Jackmcbarn
e0400a2da0 Don't break existing expiry time of "infinity" when modifying protection
Currently, modifying protection with infinite expiry time causes it to
be set to a blank "Other time", which causes an error. This fixes it to
act the same way as existing expiry times.

Bug: 70062
Change-Id: I3a7d45a677151597a941ecb11584bc1d67001136
2014-09-02 14:10:37 +00:00
Kunal Mehta
6d0c68c844 ProtectionForm: Stop using global objects
Also use Config instead of global variables

Change-Id: Idad1d0648f8ab6aba472845df4fef8ef83043bb2
2014-08-23 01:30:53 -07:00
Alexandre Emsenhuber
a2713be323 Some misc cleanup to ProtectionForm
- Set variables near to where they are used in buildForm()
  and put variables that only need to be set once out of loops
- Move the definition of 'wgCascadeableLevels' javascript variable
  near the inclusion of mediawiki.legacy.protect module, so that
  this doesn't need to be set as a side effect of buildCleanupScript()

Change-Id: Ifb54723e7609f6fc5a8939e4fada5c2e664a22bd
2014-07-06 20:53:18 +02:00
Reedy
0bad5a9374 Collapse duplicate $existingExpiry == 'infinity' case into else
Change-Id: I1cc612e9f646dd75f58cc6ae0ae073ebffa7d6d3
2014-06-16 00:49:34 +01:00
Siebrand Mazeland
3f0a2a94c9 Make phpcs-strict pass on includes/ (6/~10)
Change-Id: I566183b5d660a55bb3b2aa7186aaed5355ead2c6
2014-05-12 16:46:52 +02:00
umherirrender
8ad1c92441 Fixed some @params documentation (includes/*)
Swapped some "$var type" to "type $var" or added missing types
before the $var. Changed some other types to match the more common
spelling. Makes beginning of some text in captial.
Also added some missing @param.

Change-Id: I7f605aa9e117b5fd80d9b1440864fe526d2b14a5
2014-04-20 21:16:57 +02:00
Ladsgroup
1ba0445c12 Changing URLs of mediawiki.org in scripts to the SSL-based website
http://www.mediawiki.org --> https://www.mediawiki.org

Part 2

Change-Id: I3be61fe3dfb502cc20180486eb1a8016eac151df
2014-03-12 23:24:03 +00:00
Brad Jorsch
8862991ce1 Improve UI for page protection with $wgNamespaceProtection
Right now, if you set $wgNamespaceProtection, the protection interface
is confusing: it will allow you to apply "useless" protection levels for
any namespace except MediaWiki, where it will refuse to let you set any
protection at all.

The fix is to find which restriction levels are more restrictive than
the $wgNamespaceProtection restriction (i.e. where there is at least one
group that can pass $wgNamespaceProtection but not the level from
$wgRestrictionLevels), and use only those in the protection form. If
there are no such levels, we can skip showing the "protect" tab
entirely.

Change-Id: I9e2b29ade566abcd008ea2ad1e2f9818e315bb32
2013-12-03 22:27:28 +00:00
shirayuki
1b8155403c Give grep a chance to find the usages
Change-Id: I7fc00b055b21bbbbab209a1b1d23f23172862a0b
2013-09-05 18:29:47 +09:00
Timo Tijhof
90749a261c doc: Remove repetitive "Give grep a chance" phrase from comments
* Follows-up b2e2b2e016.
* Minor clean up of surrounding documentation comments.
* Fixed missing keys for messages in WebInstallerPage

Change-Id: Iaa692064262f3c0e10cfa5e4b1ec8c86e5d02362
2013-08-29 10:46:46 -07:00
Tychay
bfaa602229 Merge "Make it slightly easier for extensions to hook into page protection." 2013-08-26 22:03:18 +00:00
Matthias Mullie
92859c59c3 Make it slightly easier for extensions to hook into page protection.
Split parts of doUpdateRestrictions() into several more concise functions.
The biggest drawback is increasing $dbw->encodeExpiry() calls times 3. This is
not much of a problem given that's a very inexpensive function and it is only
called very few times ($limit holds 2 values in current codebase)

Added $reason to the ProtectionForm::save hook, so that other code hooking into
and adding their own settings into page protection form can also process the
reason for the protection change.

Change-Id: I879290ed83e4e47e9561d4c352fbd50c07d7e18a
2013-08-26 14:13:43 -07:00
shirayuki
b2e2b2e016 Give grep a chance to find the usages
Change-Id: I18846326539b814fa7fa93ca54117dac3572e4b0
2013-08-16 22:07:38 +09:00
Brad Jorsch
d24779328e Fix protection rights usage
It has long been recognized that using the 'protect' right to control
the ability to edit sysop-protected pages is troublesome. r31247 fixed
this by adding an 'editprotected' right, but for some reason in r32164
this was changed to bypass protection completely instead of fixing the
bug identified in r31462.

This patch goes back to do it the right way: editprotected no longer
bypasses all protection, and it is used instead of 'protect' for
controlling access to sysop-protected pages. For good measure, the same
is done with autoconfirmed protection (semiprotection): a new
editsemiprotected right is created instead of overloading the
existing autoconfirmed right.

This also fixes bug 27152 by making editprotected no longer special.

Bug: 13137
Bug: 27152
Change-Id: I6bf650a3fbdab8589ae6945c8c916eafd949e41c
2013-07-04 15:38:36 +10:00
Brad Jorsch
18062eb3b0 Add user rights 'viewmywatchlist', 'editmywatchlist'
These are needed for OAuth grants.

Note that, even if 'editmywatchlist' is not granted, various actions
will still allow for adding but not removing of pages.

Change-Id: Ie33446a228dd6ed0114730935c1bf65667f5ce01
2013-06-26 10:20:40 -04:00
umherirrender
15ff79312d Fixed spacing and removed unneeded parenthesis
Added spaces after/before parenthesis
Removed unneeded parenthesis around some statements
Broke a long line

Change-Id: I7fbe129f7bbf524dd0598ece2a9708643f08453b
2013-05-17 16:12:08 +00:00
Platonides
854797abd5 Variable $wgRestrictionLevels unused since 1cbaa921
Change-Id: I251ecaf319b2b4379ef80417ba23022a56064a94
2013-05-12 16:18:25 +02:00
MatmaRex
1cbaa92158 Add $wgCascadingRestrictionLevels
A page can only be protected with cascading protection if the
requested restriction level is included in this array.

This replaces previously hard-coded values of 'sysop' and 'protect'.

This is necessary, because if any protection could be
cascading, users could who cannot normally protect pages could
"protect" them by transcluding them on protected pages they are
allowed to edit.

Bug: 47617
Change-Id: I5f8bcc899b46d466161894606cd27bf3b8624bd0
2013-05-12 00:31:13 +02:00
umherirrender
ef2f507d23 Fixed spacing in files direct in includes folder
Added spaces before if, foreach
Added some braces for one line statements

Change-Id: Ibb8dd102db045522d12ff939075ba7420d95ab6b
2013-04-21 06:38:49 +00:00
umherirrender
15abcf71ca Added/Removed spaces around string concatenation
And added/removed spaces around some other tokens,
like +, -, *, /, <, >, =, !

Fixed windows newline style

Change-Id: I0b9c8c408f3f6bfc0d685a074d7ec468fb848fc8
2013-04-13 13:36:24 +02:00
Alexandre Emsenhuber
df5265e14d Fix case of some Title methods
Change-Id: I37ce7fe392f4941c500fa0a88007664501d7e338
2013-03-27 14:36:05 +01:00
Tyler Anthony Romeo
4dcc7961df Fixed @param tags to conform with Doxygen format.
Doxygen expects parameter types to come before the
parameter name in @param tags. Used a quick regex
to switch everything around where possible. This
only fixes cases where a primitve variable (or a
primitive followed by other types) is the variable
type. Other cases will need to be fixed manually.

Change-Id: Ic59fd20856eb0489d70f3469a56ebce0efb3db13
2013-03-11 13:15:01 -04:00
umherirrender
d63121016d fix some spacing
Added/removed spaces around logical/arithmetic operator
Reduced multiple empty lines to one empty line
Removed wrong tabs before comments at end of line
Removed too many spaces in assigments

Change-Id: I2bba4e72f9b5f88c53324d7b70e6042f1aad8f6b
2013-03-07 17:53:21 +01:00
umherirrender
1044b0b8df fix some spacing
Change-Id: I8f976013f33c5818e4402604fe8610aa3f43b0c6
2013-02-04 20:18:33 +00:00
Marius Hoch
19973572dd Disable protection in case there aren't any restriction types
This change disables the protection form and hides the protect
links in case there aren't any restriction types avialable.
Having no restriction types available let to a PHP notice and an
uggly, broken form. This became necessary as there are cases
in which no restriction types are avialable (caused by extensions)
eg. https://gerrit.wikimedia.org/r/34662

Change-Id: I0e5d3cfb299808ca14ead6baec0a18091acaa2b2
2013-01-07 14:26:59 +01:00