Commit graph

8129 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
jenkins-bot
2ff855cd49 Merge "Add missing use statements" 2018-07-04 00:44:28 +00:00
Kunal Mehta
6849ebc7d1 Maintenance: Don't try shelling out if it's disabled
Change-Id: Ib30c55aa9e048960f8fa66a41f7e2aa2fa03b253
2018-07-02 22:15:53 +00:00
jenkins-bot
1dd2c77734 Merge "Use array_merge to merge indexed arrays in categoryChangesAsRdf.php." 2018-07-02 17:23:04 +00:00
daniel
ed5ab7c856 Use array_merge to merge indexed arrays in categoryChangesAsRdf.php.
Bug: T198356
Change-Id: Ic29568ecfc26da7e6d8c9a875232bfa4e0f9f380
2018-07-02 17:43:41 +02:00
Kevin Israel
a50f61009d MWNamespace: Add getCategoryLinkType() method
This method returns the value used as cl_type for category links that
are "from" pages within the namespace, and is added to avoid duplication
of code across a few classes.

Change-Id: I4e55932a5a27858cfedb12009b455fcd02f9b5df
2018-06-29 15:37:11 +00:00
Krinkle
c04f2eb05d Merge "resourceloader: Embed 'mediawiki' directly in startup response" 2018-06-28 01:43:55 +00:00
Gergő Tisza
2f1e5a8d22 Merge "[MCR] populateContentTables maintenance script" 2018-06-27 18:57:01 +00:00
Umherirrender
ae2f5d6232 Add missing use statements
Swap some ResultWrapper/Database to interface IResultWrapper/IDatabase

Change-Id: I312cb3cca5742f72efdb0965ba35362f2eb1129d
2018-06-27 20:49:23 +02:00
Timo Tijhof
b7b84d55d4 resourceloader: Embed 'mediawiki' directly in startup response
Embed the essential files to define mw.loader directly as part of
the startup module.

* This means the internal 'mediawiki' module no longer exists.
  This is safe to remove because:
  1) While registered server-side for loading from startup.js, a PHPUnit
     structure test disallowed being specified as a dependency.
  2) Anything that attempted to load it client-side failed because the
     module was marked in the registry as 'raw', thereby excluding it
     from the data sent to the client-side. As such, it was seen as an
     unknown module that the client refused to fetch from the server.

* Deprecate getStartupModules() and getLegacyModules().
  These are no longer needed. There are no known callers anywhere in
  Wikimedia Git or elsewhere indexed by Codesearch, but easy enough
  to leave as no-op for one release.

* Remove ResourceLoaderRawFileModule class.
  No longer needed. Was created as a hack specifically for the 'mediawiki'
  module so that it would not leak global variables in debug mode.
  It has no usage anywhere in Wikimedia Git, nor elsewhere in Codesearch.
  Remove without deprecation given this was meant to be a 'private' class.

* Introduce (private) getBaseModules(). Previously, this list only existed
  locally in getStartupModulesUrl() by merging getStartupModules() and
  getLegacyModules(). This value was factored out into its own method.

* Make getStartupModulesUrl() private and rename to getBaseModulesUrl().
  It is only used internally to export the 'baseModulesUri' value.
  Its name was already confusing before, but it would've been even more
  confusing now given it doesn't even call getStartupModules() any more.

Bug: T192623
Change-Id: I14ba282d7b65e99ca54b7c2f77ba6e1adaddd11c
2018-06-27 17:06:35 +00:00
jenkins-bot
6638505a85 Merge "Add some output for progress in populateChangeTagDef.php" 2018-06-26 10:54:25 +00:00
Amir Sarabadani
4493944510 Add some output for progress in populateChangeTagDef.php
I ran it on beta cluster and all was done without one single line of output

Bug: T193871
Change-Id: I05a7c7827203eb159b5845a874b94d74f5d5e299
2018-06-25 17:38:58 +02:00
Aaron Schulz
b87c6d3f0b resourceloader: spin base module code out as a proper module
Bug: T192623
Change-Id: I6f7dc40488a990d0f8a25e84ebc9eb25ad4c2975
2018-06-25 16:05:29 +01:00
aude
c22a2c9f75 [MCR] populateContentTables maintenance script
This introduces a maintenance script for populating the tables
introduced by the MCR storage schema, namely:

  slots
  slot_roles
  content
  content_models

Per default, both the revision and archive tables are processed.

This script is part of the MCR schema migration: after instructing
RevisionStroe to write both the old and the new schema by setting
$wgMultiContentRevisionSchemaMigrationStage = MIGRATION_WRITE_BOTH,
this script can be used to back-fill the new schema for existing
revisions.

Doing this is a precondition to later setting
$wgMultiContentRevisionSchemaMigrationStage = MIGRATION_NEW to
complete the schema migration.

Bug: T182682
Change-Id: Iecc67c1b8c082be1a1039eeb52e76ad16b965226
2018-06-25 15:40:01 +02:00
Marius Hoch
2bb5329595 Maintenance::finalSetup: Make sure we re-create LBFactory
This seems to work anyway (as no connections are needed at
this time), but I guess it's more robust to explicitly
destroy any existing instances.

Bug: T147169
Change-Id: Id56a62d1830fc1464a80dd4420ffddd797bf8b51
2018-06-19 19:46:01 +02:00
jenkins-bot
e43395cf79 Merge "Allow passing the default DB group to use in Maintenance scripts" 2018-06-19 05:22:44 +00:00
Amir Sarabadani
cfa0717d4a Move lbFactory defintion from construct to execute in populateChangeTagDef
It seems the class doesn't load needed classes in construct so we get
Uncaught Error: Class 'MediaWiki\MediaWikiServices' not found

Bug: T193871
Change-Id: I0d6a49232cbc256a34ab49e8a4e41f6cc942fe4b
2018-06-18 18:34:48 +02:00
jenkins-bot
85724779ef Merge "Add maintenance to populate change_tag_def table and ct_tag_id field" 2018-06-16 12:59:28 +00:00
Amir Sarabadani
f1e450564f Add maintenance to populate change_tag_def table and ct_tag_id field
Bug: T193871
Change-Id: I5e863ffcfad5f2b66fb8d50666494acae3480d1a
2018-06-15 17:57:27 +02:00
jenkins-bot
84fa176c9c Merge "Avoid deprecated LinkCache::singleton()" 2018-06-14 23:48:54 +00:00
Timo Tijhof
658227bd2b maintenance: Update update-oojs.sh to use misc files from package
These are already included in the package. Using them from the dist/
directory is somewhat against the way things are normally done in NPM,
given the repository itself already becomes the package.

If we were building a separate directory for a tarball, that
would make more sense, but that isn't the case.

Note: In verions prior to OOjs v2.2.1, all files were included in the package,
version v2.2.1 added the 'files' whitelist which included only dist/, LICENSE*,
README*, History* and package.json, which in particular means AUTHORS.txt
is missing. This was fixed in v2.2.2 on the same day. MediaWiki will upgrade
from v2.2.0 to v2.2.2 directly.

Change-Id: I4bd91811c754addac6c9826e91580eff47c7c5d6
2018-06-14 19:13:04 +00:00
Marius Hoch
d74413bbe7 Allow passing the default DB group to use in Maintenance scripts
Also allows setting it via a global, although that is probably
less useful.

Bug: T147169
Change-Id: Ic51204a6f6ce9db4cc96108e823e388512724eff
2018-06-12 23:52:40 +02:00
Fomafix
e1630b6a53 PHP: Use short ternary operator (?:) where possible
Change-Id: Idcc7e4fcdd4d8302ceda44bf6d294fa8c2219381
2018-06-11 11:26:35 +02:00
Kunal Mehta
c4e5a9dd97 Avoid deprecated LinkCache::singleton()
Change-Id: Ie0e5c4ef0fe6ec896378bb2433af0898655dd907
2018-06-10 23:55:11 -07:00
jenkins-bot
2f8e83821b Merge "Replace call_user_func_array(), part 2" 2018-06-09 14:25:26 +00:00
Max Semenik
6e956d55aa Replace call_user_func_array(), part 2
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.

In one occurrence, a simple conditional instead of trickery was much more readable.

This patch finishes all the easy stuf in the core, the remainder is either unobvious
or would result in smaller readability gains. It will be carefully dealt with in
further commits.

Change-Id: I79a16c48bfb98b75e5b99f2f6f4fa07b3ae02c5b
2018-06-07 20:19:26 -07:00
Kunal Mehta
c2b506a59f Hard deprecate Interwiki static methods
Change-Id: I803df3ef90bf6b602e85ae48f25745f4dc6aab3a
2018-06-07 11:40:46 -07:00
Aaron Schulz
b566f66107 resourceloader: move Message methods from mediawiki.js to base module
Also set "use strict" in the base module.

Bug: T192623
Change-Id: I18a710e167df8be47a70da93a7aba0784fc62aef
2018-06-07 10:15:13 +00:00
addshore
b816cdbb6b maintenance/purgePage.php output page being purged
This is useful when piping lists of pages into the script
to see progress.

Change-Id: I077249ad012d0c463306c0a1a1e38d00624c5170
2018-06-05 12:01:41 +00:00
jenkins-bot
a3dfaf0586 Merge "Use PHP 7 "\u{NNNN}" Unicode codepoint escapes in string literals" 2018-06-04 18:37:31 +00:00
Bartosz Dziewoński
0313128b10 Use PHP 7 "\u{NNNN}" Unicode codepoint escapes in string literals
In cases where we're operating on text data (and not binary data),
use e.g. "\u{00A0}" to refer directly to the Unicode character
'NO-BREAK SPACE' instead of "\xc2\xa0" to specify the bytes C2h A0h
(which correspond to the UTF-8 encoding of that character). This
makes it easier to look up those mysterious sequences, as not all
are as recognizable as the no-break space.

This is not enforced by PHP, but I think we should write those in
uppercase and zero-padded to at least four characters, like the
Unicode standard does.

Note that not all "\xNN" escapes can be automatically replaced:
* We can't use Unicode escapes for binary data that is not UTF-8
  (e.g. in code converting from legacy encodings or testing the
  handling of invalid UTF-8 byte sequences).
* '\xNN' escapes in regular expressions in single-quoted strings
  are actually handled by PCRE and have to be dealt with carefully
  (those regexps should probably be changed to use the /u modifier).
* "\xNN" referring to ASCII characters ("\x7F" and lower) should
  probably be left as-is.

The replacements in this commit were done semi-manually by piping
the existing "\xNN" escapes through the following terrible Ruby
script I devised:

  chars = eval('"' + ARGV[0] + '"').force_encoding('utf-8')
  puts chars.split('').map{|char|
    '\\u{' + char.ord.to_s(16).upcase.rjust(4, '0') + '}'
  }.join('')

Change-Id: Idc3dee3a7fb5ebfaef395754d8859b18f1f8769a
2018-06-04 16:20:13 +00:00
jenkins-bot
52f599341f Merge "Make archive.ar_rev_id unique" 2018-06-04 14:41:34 +00:00
jenkins-bot
708f51c2c6 Merge "Make cleanupSpam.php query for http and https" 2018-06-04 08:58:36 +00:00
Brad Jorsch
c84083e413 Make archive.ar_rev_id unique
To follow up I39b0825c, this change replaces the existing non-unique
index on the column with a unique index, to help avoid some of these
sort of bugs in the future.

Bug: T193180
Change-Id: I932478c9c6a13210bc9dff75286d0f08da56682c
2018-06-04 08:52:06 +00:00
Reedy
0a1144fb2a Make cleanupSpam.php query for http and https
Bug: T186795
Change-Id: I9e350306f85d3d3ca4daba626e49a0792605acc7
2018-06-03 22:00:11 +00:00
jenkins-bot
f7d107e3a3 Merge "Exit maintenance script with non-zero status if execute() returns false" 2018-05-31 19:01:39 +00:00
jenkins-bot
5a6c78c441 Merge "Use PHP 7 '??' operator instead of '?:' with 'isset()' where convenient" 2018-05-31 19:01:07 +00:00
jenkins-bot
a2882874bb Merge "Use PHP 7 '<=>' operator in 'sort()' callbacks" 2018-05-31 18:48:34 +00:00
Tim Starling
72f2e98499 Exit maintenance script with non-zero status if execute() returns false
There's a whole lot of shutdown code in doMaintenance.php that is
skipped when you use exit() directly. In HHVM by default, destructors
are not even called.

There are a few cases where maintenance scripts want to do something after
doMaintenance.php returns, so returning null should continue to mean no exit.

Change-Id: I0891e2ee3af7ef2c64c03b70edcf9e281ce1e7ba
2018-05-31 16:46:14 +10:00
Tim Starling
25503cf011 Maintenance script to wrap the mysql binary
This is more or less equivalent to the WMF shell script "sql", but it is
reasonably portable and written in a less hackish way.

Change-Id: I240d8d4e65ce46680cac257ee376a9b026c13f92
2018-05-31 15:42:51 +10: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
Bartosz Dziewoński
b191e5e860 Use PHP 7 '<=>' operator in 'sort()' callbacks
`$a <=> $b` returns `-1` if `$a` is lesser, `1` if `$b` is lesser,
and `0` if they are equal, which are exactly the values 'sort()'
callbacks are supposed to return.

It also enables the neat idiom `$a[x] <=> $b[x] ?: $a[y] <=> $b[y]`
to sort arrays of objects first by 'x', and by 'y' if they are equal.

* Replace a common pattern like `return $a < $b ? -1 : 1` with the
  new operator (and similar patterns with the variables, the numbers
  or the comparison inverted). Some of the uses were previously not
  correctly handling the variables being equal; this is now
  automatically fixed.
* Also replace `return $a - $b`, which is equivalent to `return
  $a <=> $b` if both variables are integers but less intuitive.
* (Do not replace `return strcmp( $a, $b )`. It is also equivalent
  when both variables are strings, but if any of the variables is not,
  'strcmp()' converts it to a string before comparison, which could
  give different results than '<=>', so changing this would require
  careful review and isn't worth it.)
* Also replace `return $a > $b`, which presumably sort of works most
  of the time (returns `1` if `$b` is lesser, and `0` if they are
  equal or `$a` is lesser) but is erroneous.

Change-Id: I19a3d2fc8fcdb208c10330bd7a42c4e05d7f5cf3
2018-05-30 18:05:20 -07:00
Bartosz Dziewoński
4fd27f006f Use PHP 5.6 '**' operator instead of 'pow()' function
Change-Id: Ieb22e1dbfcffaa4e7b3dcfabbcc999e5dd59a4bf
2018-05-30 18:05:19 -07:00
Reedy
3391c0bc1e Increase cleanupTitles.php batch size
Change-Id: I086892e44936fdaf9d5d1f3667325daaaaa7260e
2018-05-26 00:26:20 +00:00
jenkins-bot
d8a144d38e Merge "languages: Use static array files for normalizer data" 2018-05-25 23:03:18 +00:00
James D. Forrester
70c711a6bc Follow-up If8dfdaf1: Hard-deprecate, drop two uses, other pre-5.3 back-compat code
Change-Id: I1c5eee3fe30d6687d88e07011a3d40b6770d0daf
2018-05-24 17:01:02 -07:00
Kunal Mehta
a2c166cb51 Have class match filename in some maintenance scripts
Each of these scripts had a class name that was not referenced outside
of the script file itself, and are safe to rename as a result.

Change-Id: Id605aca11db51ee433baeaa998a0e33184c930ca
2018-05-23 19:36:51 -07:00
jenkins-bot
b988eee2b4 Merge "Fix MediaWiki.Commenting.LicenseComment.InvalidLicenseTag errors" 2018-05-24 00:27:01 +00:00
jenkins-bot
5e3ecf6a4e Merge "Enable deleteAutoPatrolLogs to delete pre-2011 autopatrol logs as well" 2018-05-23 23:48:44 +00:00
Kunal Mehta
e0193327bd Fix MediaWiki.Commenting.LicenseComment.InvalidLicenseTag errors
Change-Id: I936c3f5fca1a0061f215e80469f5d882cb32ee29
2018-05-23 16:23:42 -07:00