Commit graph

221 commits

Author SHA1 Message Date
Umherirrender
db3a8beb77 Pass language to Status::getWikiText
Avoid use of $wgLang

Change-Id: I9cd633a20c5c60e56a101a9a699eea6db8b8eef0
2019-09-21 11:14:54 +00:00
Daimona Eaytoy
9699158f74 Declare dynamic properties
This is for all classes with 2 or more undeclared properties.

Change-Id: I1d80deb31f331bcc277b33f9e9f74857ba825637
2019-09-13 17:54:37 +00:00
Petr Pchelko
3cc3d00bcc Move getRestrictionLevels from NamespaceInfo to PermissionManager.
Bug: T11977
Change-Id: I051be9148c98086fdf53a66a74bf7c28699016db
2019-08-22 14:32:38 -07:00
Petr Pchelko
1d286560d2 Replace User::isAllowed with PermissionManager.
Covers root includes, actions, api, block, changes,
changetags, diff and PermissionManager itself.

Bug: T220191
Change-Id: Ic027d32f5dd8f4c74865df0c8a9fcf91123c889c
2019-08-20 14:43:51 -07:00
Umherirrender
49c618d833 Fix param documentation of ProtectionForm::show
It also allows array

Change-Id: I513d6fd356933a2c2f45a1773dd2f59b967a1bf2
2019-06-29 17:22:44 +02:00
Aryeh Gregor
2e1ac38485 Mass conversion to NamespaceInfo
Change-Id: I2fef157ceec772f304c0923a1cd8c0eef2e82a0f
2019-05-07 22:44:56 +02:00
Derick Alangi
c1e9a7c6df ProtectionForm: Follow up on I167ae6300b37d4e9292
Per code search string "\$this\-\>showLogExtract\( \$ou", method
is only called within the ProtectionForm class so can be safely
made private but there are methods with the same name in a class
like LogEventsList but do different things.

Inspired by @Thiemo's comment on I167ae6300b37d4e9292.

Change-Id: Ic4983ccffecc6285f848d6e926017c4c6df4855f
2019-03-16 21:12:18 +00:00
Derick Alangi
a6bd784b9b ProtectionForm: Add type hint to ::showLogExtract() header
https://codesearch.wmflabs.org/core/?q=showLogExtract%5C(&i=nope&files=&repos=
according to codesearch shows that this method takes as first argument an output
page object and also, objects are passed by reference by default so removed &.

Change-Id: I167ae6300b37d4e9292bd8ad14351f1ca35184d2
2019-03-10 19:12:48 +01:00
Fomafix
3ffc32ab8b ProtectionForm: Move JS config var to RL packageFiles
The check for type Array of the JavaScript config variable is obsolete.

Change-Id: I4a38cfc211360c831958ce8ca88584cdf56a727c
2019-02-11 12:20:01 +01:00
Kunal Mehta
cc5d9a92a2 build: Updating mediawiki/mediawiki-codesniffer to 24.0.0
Change-Id: I66b1775b7c1d36076d9ca78cbeb42787a743f2aa
2019-02-07 18:39:42 +00:00
Brad Jorsch
0abb9338f8 Mostly drop old comment schemas
This removes most of the pre-CommentStore text columns, and the
$wgCommentTableSchemaMigrationStage setting that used to determine
whether the columns were used.

rev_comment remains in the code, as on Wikimedia wikis the revision
table is too large to alter at this time. A future change will combine
that with the removal of rev_user_text, rev_content_model, and
rev_content_format (and the addition of rev_comment_id and rev_actor).

CommentStore's constructor continues to take a $stage parameter, and
continues to have the logic for handling it, for the benefit of
extensions that might need their own migration process.

Bug: T166733
Change-Id: I1479c73774e01ead1490adf6128f820c09bce9d4
2019-02-07 16:59:27 +11:00
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