Commit graph

113 commits

Author SHA1 Message Date
Fomafix
43244db9a2 Use PHP 7 '??' operator instead of if-then-else
Change-Id: If9d4be5d88c8927f63cbb84dfc8181baf62ea3eb
2018-10-21 21:46:46 +02:00
Aryeh Gregor
90d4f56fe4 Mass conversion of $wgContLang to service
Brought to you by vim macros.

Bug: T200246
Change-Id: I79e919f4553e3bd3eb714073fed7a43051b4fb2a
2018-08-11 22:44:29 -06:00
jenkins-bot
e96b9055fb Merge "LogFormatter: Fail softer when trying to link an invalid titles" 2018-08-08 15:35:56 +00:00
Bartosz Dziewoński
26bb9d9b23 LogFormatter: Fail softer when trying to link an invalid titles
Old log entries contain titles that used to be valid, but now are not.

Bug: T185049
Change-Id: Ia66d901aedf1b385574b3910b29f020b3fd4bd97
2018-08-01 16:19:55 +02:00
Brian Wolff
6b19444b32 Force phan-taint-check to think LogFormatter stuff is safe for html
Whether or not LogFormatter::getActionText() and friends are safe
for html depends on the runtime value of LogFormatter::$plaintext
which is beyond the abilities of phan-taint-check's static analysis
to determine. Thus this method results in a lot of false positives.

To prevent that, add an annotation that marks the method as always
safe for html. This is not ideal, but refactoring this method while
maintaining back-compat looks like it would be very challenging.

Bug: T197002
Change-Id: I9aded350ed4acc733b4fb697dd3400686a178fa9
2018-07-08 16:56:37 +00: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
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
Kunal Mehta
e0193327bd Fix MediaWiki.Commenting.LicenseComment.InvalidLicenseTag errors
Change-Id: I936c3f5fca1a0061f215e80469f5d882cb32ee29
2018-05-23 16:23:42 -07:00
Kunal Mehta
6066f6c063 Declare LogFormatter::$parsedParameters property
And rework LogFormatterTest so it doesn't need to access that property.

Change-Id: I4d429430efe74dc083019a1a8bb07257785484b9
2018-05-01 19:56:13 -07:00
Umherirrender
cb68d6dacf Fix typo in word compatibility
Change-Id: Ic6ad14f5e156311cee3021cd427561dfcd68633a
2018-03-09 23:04:44 +01:00
Umherirrender
9aa56950c2 Remove @codingStandardsIgnore from long lines
Breaks some line where the ignore is not needed.

The sniff was changed upstream to be okay
with long unbreakable lines in comments

Change-Id: I2bbe2be7cedd4d3c0ce8dc3e62d0e268bc171876
2017-10-22 16:44:04 +02:00
jenkins-bot
732b5e2745 Merge "Use LogFormatter::getLinkRenderer in LogFormatter extensions" 2017-10-21 17:13:44 +00:00
Brad Jorsch
fa2724fa84 LogFormatter: Don't return a non-array from formatParameterValueForApi
If the title for a 'title' or 'title-link' type is invalid, the code
still must not return a non-array from the method.

I'm not sure this is what was behind T176938, but it's the only thing I
can find that might cause the errors I saw logged at about the same
time.

Change-Id: Iae77eb6ad9a64d8b67074164ff0c0fea36826f3c
2017-09-28 10:06:53 -04:00
Matěj Suchánek
d0fa4e8d15 Use LogFormatter::getLinkRenderer in LogFormatter extensions
And additionally, migrate another two usages of deprecated
Linker methods.

Bug: T149346
Change-Id: I222da144a37f7d77eaf4bdde901b58c992f1af85
2017-07-12 09:58:18 +02:00
Kunal Mehta
80847dcb32 Expose LinkRenderer for LogFormatter instances
Pass a LinkRenderer instance from SpecialLog, through LogEventsList,
onto LogFormatter instances, which tend to make many links.

Bug: T168924
Change-Id: I264da6f63678917c7335adee5a0b64cbcded66f3
2017-06-30 02:05:29 -07:00
James D. Forrester
9635dda73a includes: Replace implicit Bugzilla bug numbers with Phab ones
It's unreasonable to expect newbies to know that "bug 12345" means "Task T14345"
except where it doesn't, so let's just standardise on the real numbers.

Change-Id: I6f59febaf8fc96e80f8cfc11f4356283f461142a
2017-02-21 18:13:24 +00:00
Bartosz Dziewoński
01936fa994 BlockLogFormatter: Durations are relative to block's timestamp, not Unix epoch
Also fixed legacy code in LogFormatter producing messages for IRC feed.

Bug: T55907
Change-Id: I0df19574f74210a91ce72c79188b6618f04ef9a2
2017-01-18 13:21:56 +00: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
jenkins-bot
9df4c26c4b Merge "Fix doc of LogFormatter::newFromRow" 2016-01-30 12:24:49 +00:00
Max Semenik
796711e0c4 Kill vestiges of SVN times
Change-Id: Ib80c71ea93479eb326ac5afea295d4608f92babe
2016-01-30 01:32:36 -08:00
addshore
1159454506 Fix doc of LogFormatter::newFromRow
DatabaseLogEntry::newFromRow can take both
objects and arrays (arrays are cast to objects).

An array is passed into this method in the
CheckUser extension.

Fixing this phpdoc will mean static analysis
tools will no longer detect that as an error

Change-Id: I84f35c21f8b4e3be0f5b5bd2051f566bda6544fc
2016-01-29 15:41:32 +01:00
umherirrender
5cf7db33fa Skip user namespace prefix for rights log entry
The target of the right log entry is shown with namespace prefix, but it
is always a user, so skip the namespace prefix.

Change-Id: Ibe6005cc70ff3933836166d97c544267fb7d9951
2015-10-10 07:38:10 +02:00
umherirrender
d6961552b3 Migrate protect log to new log system
This localize the protect type, level and expiry on Special:Log/protect.
To allow i18n there are some details stored in the log params of new log
items, these details also shown on API output.
The details cannot get from the old existing data, because there are
containing L10n strings therefore i18n works only for new items.
In the api and for IRC the old description text is still stored in the
log params for backward compatibility.

This allows use of gender on Special:Log. Old messages are kept for use
in IRC. Tests already exists to ensure an unchanged IRC message.

Bug: T47988
Change-Id: I3bb85c61b857972e66c99c499d7d785c88cafb25
2015-09-25 17:07:50 +02:00
umherirrender
3964b4cc05 Migrate move protect log to new log system
Migrate the move protect log as first sub type of the protection log,
because it does not have complex log parameter, which needs some way of
handling/migration.
It also keeps the gerrit change smaller and hopefully makes review
easier.
The other sub types of the protection log will be migrated in a later
patch set.

This allows use of gender on Special:Log. Old message is kept for use
in IRC. A test was added to ensure an unchanged IRC message.

Bug: T47988
Change-Id: I57b3bd8a7dc823acdbb56520d2364f5542283373
2015-08-18 22:20:35 +00:00
umherirrender
f087bcb620 Use assertSame in LogFormatterTestCase
Using assertSame also checks for internal types to be correct.

Needs the following fixes:
- MergeLogFormatterTest: Use correct array key order
- NewUsersLogFormatterTest: Input user id as integer
- PatrolLogFormatter: Ensure in LogFormatter that
  integer is not casted to float

Change-Id: I2cab5335d6654f6cda15fc4e9fbae2c1ca1b27ff
2015-06-06 20:55:03 +02:00
Kevin Israel
272843a55d Move some global statements to top of function
These were flagged by mediawiki/tools/code-utils/check-vars.php
because they were located inside a switch statement, or inside an
if statement and used outside the statement. All other warnings
from that script are bogus, mostly because the script has no
support for PHP 5.3 namespaces.

Change-Id: If93bae4434b5c28845125095f6a22d6788a76efc
2015-05-06 20:19:32 +00:00
Brad Jorsch
61233fc847 API: Move parameter formatting into LogFormatter
This allows for extensions to format their log entry parameters, and
keeps the code for formatting API log entry parameters in the same place
as for other formatting.

This also takes the opportunity to rearrange the output format slightly
to avoid conflicts like what's happening in T73020.

Bug: T35235
Bug: T73020
Bug: T91466
Change-Id: I6846ce09322eb404c506b5a51780a44ce9279fe2
2015-04-17 04:59:41 +00:00
This, that and the other
ae3ab9eef0 Allow users to add, remove and apply change tags using the API
You can add tags at the same time as performing action=edit, as long as you
have the "applychangetags" right. Also, you can add or remove tags after
the fact from revisions and log entries using the API action=tags.

No UI is provided for either of these changes. The target audience is user
scripts, gadgets and similar tools.

Includes a new log parameter format type: "list", for a comma-separated
list of values.

Logging of change tag events is limited to those that do not accompany an
edit (i.e. those done after the fact), and is hidden from Special:Log by
default, similar to the patrol log.

Bug: T20670
Change-Id: I37275e0f73fa3127f55da0c320b892551b61ee80
2015-04-15 18:30:45 +00:00
Timo Tijhof
15e8dc1ecf LogFormatter: Indent code to fix Doxygen parse error
This file was not being indexed due to a parse error.

> /includes/logging/LogFormatter.php:844:
>   warning: Reached end of file while still inside a (nested) comment.
>   Nesting level 2 (probable line reference: 48, 26)

Change-Id: Ie34ae644d06e705991b934d4389e8c41bb7f77a7
2015-04-02 19:51:56 +00:00
umherirrender
4f60a37d4e Migrate import log to new log system
There is no need for an extra formatter class, because at the moment
there is nothing extra to format.

This allows use of gender on Special:Log. Old messages are kept for use
in IRC. A test was added to ensure an unchanged IRC message.

The new log message for import-interwiki is used from
I3ca8b21bce49b41cac7109efb8056ca4469b88d7 to avoid "transwiki jargon".

Bug: T57404
Change-Id: I590075b203548c071a98c1eaa4b1bc9250f60e22
2015-03-18 13:21:52 +00:00
umherirrender
68c945d796 Fix IRC lines for blocks published with the old logging system
The CheckUser and GlobalBlocking extension are inserting the block logs
over the old logging system, where the keys are numeric.
This case is not known when building the irc line, because that was
already migrated to just get the new style.
Added compatibility code for legacy rows.

Needs the legacy flag also in ManualLogEntry to make this happen,
because it is using the LogFormatter of the new logging system to format
the actionText.

Have not found the old way for block/reblock, so just for block/block.

Bug: T92713
Follow-Up: Ibc7fcaa5a952ff90d42a6477da4baa429f3de64b
Change-Id: I08aea8399ce766e98c1a76e237169f220c6cc751
2015-03-14 13:43:13 +01:00
umherirrender
ce4af8b873 Fix parameter order for block logs
The new block log params does not known the message number 4 (which is
index 3), therefore LogFormatter::getMessageParameters adds empty index
to keep the sequence in strong order.
But the loop was starting at index 4, not 3, which skips the needed
empty index 3 for the order.

Due to the missing $4 the legacy log params returning index 3 and 4,
therefore move them one up to match the new numbers.

Also fixed undefined index warnings for api's list=logevents

Follow-Up: Ibc7fcaa5a952ff90d42a6477da4baa429f3de64b
Change-Id: Ie23be129ee2bd1d2bf753c3b5cba293d64b8e0e8
2015-02-24 19:37:03 +01:00
jenkins-bot
8888bac668 Merge "Migrate block log to new log system" 2015-02-22 00:46:35 +00:00
Matthew Flaschen
bb704ad136 Define the context field in LogFormatter
Public for backwards-compatibility.

Change-Id: I6d66d14b58def1fe6674b47d1e4d3ff53034bf2c
2015-02-12 22:55:12 -05:00
umherirrender
c891ff00ed Migrate block log to new log system
This allows use of gender on Special:Log.
Old messages are kept for use in IRC.
A test was added to ensure an unchanged IRC message.

Bug: T57402
Change-Id: Ibc7fcaa5a952ff90d42a6477da4baa429f3de64b
2015-02-07 21:02:10 +01:00
Niklas Laxström
5e969b82d1 Escape word-separator in LogFormatter
Change-Id: I9428f5ff5b95d09932b3588f0118d6992a384390
2014-12-29 20:08:20 +00: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
umherirrender
52f5634ba0 Migrate merge log to new log system
This allows use of gender on Special:Log
Old message is kept for use in irc,
a test is added to ensure a unchanged irc message.

Change-Id: I0557a0d2751540cf0d7967333ffd767b934011c6
2014-10-21 16:49:06 +00:00
Aaron Schulz
bf8a180ab3 Show the revision list immediately on "umerge" log action links
Change-Id: I47804a54321fa317b36428d67c24b71d8c27a667
2014-08-27 16:55:43 -07:00
umherirrender
b883e8c7c0 Cleanup some docs (includes/[e-l])
- Swap "$variable type" to "type $variable"
- Added missing types
- Fixed spacing inside docs
- Makes beginning of @param/@return/@var/@throws in capital
- Changed some types to match the more common spelling

Change-Id: I41a84e8e1dec39170aa655250325ffc485eaeaef
2014-07-24 19:43:03 +02:00
umherirrender
b45420410f 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: Iced714bca004756b461b66067a49a925a7e3b877
2014-04-19 22:22:20 +02:00
umherirrender
edc924869f Changed some comments from /// to /** @var */
Change-Id: I55b30099e4464c272c35bcabbddbb0b1364a5d65
2014-04-07 05:01:19 +00:00
Kartik Mistry
2daafebc77 Do not use jargon in comment.
* luser -> user

Change-Id: Iab8033dea8f0cbf628563ca5434f3d939fe6b3df
2014-02-06 17:13:28 +05:30
umherirrender
073abe3e12 No variable assignment on return statement
Split the variable assignment and the return statement in two lines for
better readability.

When there was two return statements in one method the logic was swapped
to have only one return statement.

Change-Id: Id7a01b4a2df96036435f9e1a9be5678dd124b0af
2014-01-02 09:43:35 +00:00
Siebrand Mazeland
e64f4d9f12 Update documentation for log related classes
Change-Id: I4e00cda46cc7bbcbd17ac2d3d025a76281ee84b6
2013-12-06 00:07:12 +01:00
Siebrand Mazeland
86fe1da236 Break long lines in logging related classes
Also:
* Take function call out of for loop test part.
* Suppress CodeSniffer warnings for unavoidable long lines.

Change-Id: I14044f14b30d494d910541a1dac50921254a7398
2013-12-03 15:58:51 +01:00
Siebrand Mazeland
8a536b8591 Update formatting for log related classes
Change-Id: I6535467ed9b22d61b7c5caf3f18067a988871751
2013-12-03 15:36:21 +01:00
umherirrender
9f14ecf829 Added space after switch/Removed spaces after unset
While at it, added/removed some other spaces in the same files

Change-Id: I84d8001aa123a008807ad5eb76f396aed7c899a4
2013-04-26 16:42:31 +02:00
umherirrender
6c38a5eb72 Fixed spacing in logging/parser/profiler/rl/revdel/search folder
Added spaces before if, foreach
Added some braces for one line statements

Change-Id: I11bbcfa351e945b7bde10c2105d61a3cf5622205
2013-04-20 17:38:24 +02:00
Alexandre Emsenhuber
744c0c7541 Move subclasses of LogFormatter to their own file
Except LegacyLogFormatter.

includes/logging/LogFormatter.php is getting bigger and bigger with
the addition of new formatters when logs are changed to use them
instead of the old method, so better doing this now before we get
new formatters for remaining log types.

Change-Id: I6aab19c8d68bf47beddad42632b0360a7b12f251
2013-03-15 15:25:33 +01:00