Commit graph

511 commits

Author SHA1 Message Date
Fomafix
6866cfec37 Simplify PHP by using ?? and ?:
Also remove not necessary surrounding parentheses.

Change-Id: I0eb5c9c1bdfb09a800258379cdcefb5fd4d3d21c
2018-07-10 20:03:17 +00:00
Fomafix
125cbd8c01 Use \u{00A0} instead of   or  
Directly use the UTF-8 encoding of the 'NO-BREAK SPACE' (U+00A0) instead of
the HTML/XML entities   or   or  .

With the UTF-8 character the generated HTML is shorter and better to read.

Also change the special value for the label in HTMLForm from   to
U+00A0 but also support   for backward compability.

Bug: T154300
Change-Id: I882599ac1120789bb4e524c4394870680caca4f4
2018-06-24 01:20:13 +00:00
Max Semenik
8085c58a4b Replace call_user_func_array(), part 1
Uses new PHP 5.6 syntax like ...parameter unpacking and
calling anything looking like a callback to make the code more readable.
There are much more occurrences but this commit is intentionally limited
to an easily reviewable size.

Change-Id: Idcec077ef3fdf029b632cceafd0150851ad723e3
2018-06-04 23:39:04 -07:00
Bartosz Dziewoński
485f66f174 Use PHP 7 '??' operator instead of '?:' with 'isset()' where convenient
Find: /isset\(\s*([^()]+?)\s*\)\s*\?\s*\1\s*:\s*/
Replace with: '\1 ?? '

(Everywhere except includes/PHPVersionCheck.php)
(Then, manually fix some line length and indentation issues)

Then manually reviewed the replacements for cases where confusing
operator precedence would result in incorrect results
(fixing those in I478db046a1cc162c6767003ce45c9b56270f3372).

Change-Id: I33b421c8cb11cdd4ce896488c9ff5313f03a38cf
2018-05-30 18:06:13 -07:00
Florian Schmidt
32be7421b1 WatchAction::onSubmit return correct value, not always true
The onSubmit method documentation states, that the caller can expect either
true for a successfull run, false if not tried and an array of error messages
in case of an failure. WatchAction however always returned false, even though
a Status object is availble with all needed information.

The behaviour of WatchAction::onSubmit is now changed to return the appropriate
value taken from the returned Status object of WatchAction::doSelf.

Also:
 * Added WatchAction test class to higher test coverage, especially for the
   static methods
 * Marked getUnwatchToken as deprecated, it's not used and a caller can easily
   switch to getWatchToken with "unwatch" as the action parameter

Change-Id: I2c1b91e1884a0d5f27f5e7ab9eafd6173642c21c
2018-05-23 20:36:37 +02:00
jenkins-bot
c004cfc116 Merge "Fix documentation of InfoAction::pageInfo" 2018-05-18 14:52:06 +00:00
Brian Wolff
355cccddf7 Add whether user is elevated to unsafe js load log
To better triage the log entries.

Change-Id: Idf6d967d06b118ebd7b4d848e12bb36faf55a1b6
2018-05-15 04:38:48 +00:00
Brian Wolff
0be838ed6a Disallow loading JS/CSS/Json subpages from unregistered users and log
Loading JS from an unregistered user's JS subpage is a severe
security risk as someone could potentially register that account
and then modify the JS.

Bug: T194204
Change-Id: I741736e12b0ed49e95f22c869a2b53e2c97b31f0
2018-05-15 00:49:35 +00:00
Gergő Tisza
d030da9ddc Fix documentation of InfoAction::pageInfo
This was added in I702f2f13d3b but doesn't seem to have been true
even back then.

Change-Id: I797061a6af52fed1b052dc69544fa418563892cc
2018-03-31 23:04:15 +00:00
James D. Forrester
2ae7d6b580 Add protection for User: JSON pages in the same manner as JS & CSS ones
Also recognise MediaWiki: JSON pages (with the existing protection of
the editinterface right).

Bug: T76554
Change-Id: Idba166d82ee6dd507d7345c9bdbefc8ca78ed7b4
2018-03-29 14:33:46 +00:00
Timo Tijhof
f66e75dd5a RawAction: Remove unused $gen variable
Follows-up 697c423259 (MW 1.27), which removed use of these variables.
The '$this->gen' member is never used, and neither is local $gen.

Change-Id: I663d343d0255d5e13d7d87b1d4e565a7df667449
2018-03-28 13:18:14 -07:00
Amir Sarabadani
9f22ed71fa Convert MarkpatrolledAction to use OOUI
Bug: T189385
Change-Id: I9bd78166be5ab80e58498d2934531185404b17de
2018-03-10 20:43:03 +01:00
Brad Jorsch
27c61fb1e9 Add actor table and code to start using it
Storing the user name or IP in every row in large tables like revision
and logging takes up space and makes operations on these tables slower.
This patch begins the process of moving those into one "actor" table
which other tables can reference with a single integer field.

A subsequent patch will remove the old columns.

Bug: T167246
Depends-On: I9293fd6e0f958d87e52965de925046f1bb8f8a50
Change-Id: I8d825eb02c69cc66d90bd41325133fd3f99f0226
2018-02-23 10:06:20 -08:00
RazeSoldier
f5ebacbe25 Convert the sha1 value from base-36 to base-16
Convert the sha1 value displayed on the file info page from base-36 to
base-16

Bug: T181651
Change-Id: I39d6d5d68973c9e67959b2bbbe77937f4ccca76a
2018-01-25 19:34:51 +00:00
jenkins-bot
a18476eab3 Merge "Remove @param comments that literally repeat what the code says" 2018-01-11 23:48:03 +00:00
Thiemo Mättig
ef470ebf7f Remove @param comments that literally repeat what the code says
These comments do not add anything. I argue they are worse than having
no comments, because I have to read them first to understand they
actually don't explain anything. Removing them makes room for actual
improvements in the future (if needed).

Change-Id: Iee70aad681b3385e9af282d5581c10addbb91ac4
2018-01-10 14:14:26 +01:00
RazeSoldier
5aea96df5a Display the file sha1 value in the file info page
When a visitor accesses an info page of an existing file, base-36 sha1 value of this file will displayed in the table of basic information.

Bug: T181651
Change-Id: Ib8cae3e4070a186e28e8625556d3c510af0701c2
2018-01-03 12:35:42 +00:00
Thiemo Mättig
544122a6c2 Remove self-explaining "section heading" comments from classes
I can see that "parent::__construct" literally calls the parent
constructor. I can see that stuff preceeded by the keyword "protected"
is protected. I really (really) don't need comments explaining such.

Change-Id: I7458e714976a6acd3ba6a7c93fdc27d03903df83
2017-12-28 16:12:08 +01:00
daniel
6af796f3e0 MCR: Deprecate and gut Revision class
This is a re-submission of I4f24e7fbb68.

As a first major step towards Multi-Content-Revisions (MCR),
this patch turns the Revision class into a legacy proxy for
the new RevisionRecord and RevisionStore classes.

Backwards compatibility is maintained for all but some
rare edge cases, like constructing a completely empty
Revision object.

For more information on MCR, see
<https://www.mediawiki.org/wiki/Requests_for_comment/Multi-Content_Revisions>.

NOTE: once this is merged, verify create/delete/restore cycle on beta,
      ideally with emulated replication lag.

Bug: T174025
Change-Id: Ia4c20a91e98df0b9b14b138eb4825c55e5200384
2017-12-21 18:08:54 +00:00
Daniel Kinzler
09bf4f5bb2 Revert "[MCR] Turn Revision into a proxy to new code."
This reverts commit 9dcc56b3c9.

With this patch applied, newly created revisions are sometimes not found
just after submitting an edit, until replicas have caught up.

Our best theory is that it somehow interfere with ChronologyProtector,
but we don't have a good idea how.

Also, as legoktm mentioned, the commit message is terrible and needs fixing.

Change-Id: Idf3404f3fa8f8d08a7fb2ab8268726e2c1edecfe
2017-12-19 12:38:48 +00:00
daniel
9dcc56b3c9 [MCR] Turn Revision into a proxy to new code.
Change-Id: I4f24e7fbb683cb51f3fd8b250732bae9c7541ba2
2017-12-18 14:37:29 +00:00
Étienne Beaulé
653a18f683 Show protection log on every use of moveddeleted-notice
As a follow-up to T171338, the other uses of the message were ignored.
This change adds the protection log to these uses; that is, history and
image pages.

Bug: T174889
Change-Id: Ib9f22d6e06c372c4a32e77a08c846d768853bc21
2017-12-03 20:04:22 +00:00
Brad Jorsch
3488f49532 Replace selectFields() methods with getQueryInfo()
Several classes have a "selectFields()" static method to tell callers
which fields to select from the database. With the recent comment table
change and the upcoming actor table change, this pattern has become too
simplistic as a SELECT will need to join several tables to be able to
retrieve all the needed fields.

Thus, we deprecate the selectFields() methods in favor of getQueryInfo()
methods that return tables and join conditions in addition to the
fields.

Change-Id: Idcfd15568489d9f03a7ba4460e96610d33bc4089
2017-10-30 22:57:33 +00:00
jenkins-bot
09b6dddae2 Merge "RawAction: Add json to the allowed content types" 2017-10-26 10:06:52 +00:00
addshore
3f18fe3f46 HistoryPager: Add missing $tagFilter property
Change-Id: Iec2d944d5583eb13fa9383c0a6a183b550f60aab
2017-10-25 17:00:46 +00:00
Amir Sarabadani
31f53f9836 RawAction: Add json to the allowed content types
This is not the best way to handle json type but
I'm trying to clean this up a little in other patches

Bug: T178060
Change-Id: Ia6d0c4b8c1062966da48e3bebf057c621b39ba87
2017-10-22 13:44:20 +02:00
Matěj Suchánek
7b28f7756e Avoid double escaping headers in InfoAction
Bug: T111763
Change-Id: I4f582ce5785448a4cb48f3a1d56371eddf38a232
2017-09-29 21:10:37 +02:00
Brian Wolff
729be8690b Fix CreditsAction when user has no real name set but real names enabled
Change-Id: Ief347739a1231fa8bd814694bdb5b4f44ba41a77
2017-09-28 02:36:31 +00:00
Kunal Mehta
5cd20435dc EditPage: Try to avoid using $wgTitle
The most common code path is from EditAction, so make sure
EditPage::setContextTitle() is called in that case.

Log any uses that fallback to $wgTitle in the GlobalTitleFail log group.

Bug: T144366
Change-Id: Ie6c7dfbaa432239389d210051372427b8fa045b4
2017-09-19 21:30:21 -07:00
Amir Sarabadani
4db32be1e8 Cleanup form for history
Also fixing regression caused by Ie119c92aa4936e2f8982163d4b00d08949f49264

Change-Id: I59f623d2dc43f83cfca3ff31ef79fed0230f68af
2017-09-18 22:17:36 +04:00
Umherirrender
f739a8f368 Improve some parameter docs
Add missing @return and @param to function docs and fixed some @param

Change-Id: I810727961057cfdcc274428b239af5975c57468d
2017-09-10 20:32:31 +02:00
Kunal Mehta
0cb2a09b6d Always put type information before variable name for @var tags
Like other tags, @var should have the type information before the
variable name.

<https://docs.phpdoc.org/references/phpdoc/tags/var.html>

Change-Id: I9eca6957b1990fa8cc687103dc02ee38af5f9086
2017-09-04 11:06:51 -07:00
Max Semenik
fd6e9ef2d4 Human-readable section ID support
It adds the ability to replace the current section ID escaping
schema (.C0.DE) with a HTML5-compliant escaping schema that is
displayed as Unicode in many modern browsers.

See the linked bug for discussion of various options that were
considered before the implementation. A few remarks:
* Because Sanitizer::escapeId() is used in a bunch of places without
  escaping, I'm deprecating it without altering its behavior.
* The bug described in comments for Parser::guessLegacySectionNameFromWikiText()
  is still there in some Edge versions that display mojibake.

Bug: T152540
Change-Id: Id304010a0342efbb7ef2d56c5b8b244f2e4fb2c5
2017-08-01 20:32:20 -07:00
Kunal Mehta
d1cf48a397 build: Update mediawiki/mediawiki-codesniffer to 0.10.1
And auto-fix all errors.

The `<exclude-pattern>` stanzas are now included in the default ruleset
and don't need to be repeated.

Change-Id: I928af549dc88ac2c6cb82058f64c7c7f3111598a
2017-07-22 18:24:09 -07:00
Bartosz Dziewoński
51be1c92de DeleteAction: Remove now-unnecessary RL modules
After 97a8fb78fa these are never used.

Change-Id: Ibb4ee45ad991651afab0f0363056d3066e740b24
2017-07-12 20:46:15 +02:00
Thiemo Mättig
d14faa6bed Remove auto-generated "Constructor" documentation on constructors
Having such comments is worse than not having them. They add zero
information. But you must read the text to understand there is
nothing you don't already know from the class and the method name.

Change-Id: I994d11e05f202b880390723e148d79c72cca29f0
2017-07-10 10:15:51 +00:00
jenkins-bot
8e185ecb2b Merge "Add canonical id to header on action=info" 2017-07-06 10:28:16 +00:00
Umherirrender
b5cddfb27b Remove empty lines at begin of function, if, foreach, switch
Organize phpcs.xml a bit

Change-Id: Ifb767729b481b4b686e6d6444cf48b1f580cc478
2017-07-01 11:34:16 +00:00
Umherirrender
3ed80375f2 Add canonical id to header on action=info
Have to use the h2, because the span can have only one id attribute

Bug: T44629
Change-Id: Iaa1c46611c56210b1177a665a5edfa082683977f
2017-06-28 21:56:37 +02:00
Matěj Suchánek
a3cdd0a4fc Replace a Linker::link() call in InfoAction.php
Bug: T149346
Change-Id: I41906d4d24468467e1c0740d748fe96ea2dab484
2017-06-17 21:37:04 +02:00
Amir Sarabadani
d062560f24 Require $key in msg() functions
Note: calling msg() with no parameter was never supported,
doing this on a RequestContext for example would result in:
PHP Warning:  Missing argument 1 for wfMessage() ...followed
by a bunch of fallout.

So this patch only formally declares what was already a
requirement in reality.

Change-Id: I1864afb8bcc641698689828914949a06506d8f3a
2017-06-14 13:26:27 +04:30
Gergő Tisza
016452cd09 ChangesList: Expose basic properties of lines as data attributes
We have several types of change lists (old RC/watchlist/related
changes, enhanced RC/watchlist, history) with slightly different
HTML, each with their own idiosyncracies. JavaScript code trying
to identify lines by log ID / revision ID has to jump through all
kinds of hoops to work with that.

To simplify the lives of frontend / gadget maintainers and provide
something approaching an API for these pages, we now expose the basic
attributes of each change line (revision ID for edits, log type/action
and ID for log events) as data attributes.

The OldChangesListRecentChangesLine, EnhancedChangesListModifyLineData,
EnhancedChangesListModifyBlockLineData, PageHistoryLine,
ContributionsLineEnding and DeletedContributionsLineEnding hooks
are updated accordingly. New hooks (LogEventsListLineEnding and
NewPagesLineEnding) are added for the change list pages which did
not yet have them.

Change-Id: I6dd006d0b1b0fd35c0020f0f9eea9113eca30b35
2017-06-08 23:19:45 +00:00
Kunal Mehta
3e4f40851a InfoAction: Avoid deprecated wfMemcKey()
And the deprecated ObjectCache::getMainWANInstance() while we're at it.

Change-Id: Id7bb6a8c3e8269345e054d2c2bf202304b74c3cf
2017-05-23 21:01:08 -07:00
jenkins-bot
6fbafe5494 Merge "Convert various FormActions to OOUI" 2017-04-16 19:30:55 +00:00
Aaron Schulz
d735dc562d Move Database and subclasses to Rdbms namespace
Change-Id: I52bef87512f9ddd155d1f4cc0052f6b7a0db5b42
2017-04-12 10:43:57 -07:00
Brad Jorsch
f4a306fb18 Deprecate "Avoid page_touched update for HTTP GET action=purge requests"
This reverts most of commit c84ba4d864.
The changes made there are no longer needed, and nothing in Gerrit seems
to have started using them since they were added.

The added constants in WikiPage, WikiPage::getLastPurgeTimestamp(), and
Article::getLastPurgeTimestamp() are deprecated, useless, and unused,
but not removed yet since they snuck into 1.28 so we can't revert them
without a deprecation period. Sigh.

Bug: T145649
Change-Id: I526fd4e004bee84c831a4cee71e44e92ee73480b
2017-03-27 10:10:26 -04:00
This, that and the other
44141e3a72 Convert various FormActions to OOUI
Support for OOUI is added to FormAction, and subclasses can enable it as
required.

PurgeAction, RevertAction, WatchAction and UnwatchAction are converted
to OOUI, with minor changes to the forms to give them a neater appearance.

Bug: T160236
Change-Id: I5294e5d886e8641e9b63eabc9d7fa8ea93e0df96
2017-03-11 16:48:17 +11:00
Aaron Schulz
e01fd44388 Move ResultWrapper subclasses to Rdbms
Change-Id: I6f3f0e85e268b24c57c537aa6ad8016e0b4cdddb
2017-03-03 00:44:41 +00:00
jenkins-bot
bab4f5d64e Merge "Use Database::addQuotes instead of hard coded apostrophs" 2017-02-24 20:56:22 +00:00
jenkins-bot
4cb9c1a24b Merge "Add GENDER to rollback-success message" 2017-02-22 22:01:18 +00:00