Commit graph

137 commits

Author SHA1 Message Date
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
Umherirrender
1cee41b9dc Call Database::timestamp in some tests
Also add non-optional database fields to insert.
The fields are defined with a default in mysql,
but not in postgres or oracle.

Bug: T195807
Change-Id: I201638e3438cb0e5004f8da121e64a770e6a8fca
2018-05-29 22:28:36 +02:00
Amir Sarabadani
0175c3b054 Enable deleteAutoPatrolLogs to delete pre-2011 autopatrol logs as well
Bug: T184485
Change-Id: I3f123ea0ae69f80beec7425be0f3e4c00a409c0d
2018-05-24 01:19:01 +02:00
Stanislav Malyshev
bc9e1a086e Create update SPARQL for category changes
This script creates SPARQL UPDATE statements for changes in a given time
period. These statements can be applied to an existing database to
update it.

See tests for examples of how the statements look like.

Bug: T173774
Change-Id: I9867ad566c0619b55a48a011bd3c55321b1bfcff
2018-04-20 16:40:35 -07:00
Aaron Schulz
e7feb5fd6d Add missing "use" clause to DumpTestCase
Change-Id: I0420e95003509634a87b98df279242cdc05843b2
2018-04-04 21:46:55 -07:00
jenkins-bot
8198ea31fd Merge "Add further test cases to deleteAutoPatrolLogsTest" 2018-04-03 06:13:33 +00:00
Marius Hoch
40220100ad Add further test cases to deleteAutoPatrolLogsTest
Also make --batch-size work and make an if check nicer
(makes no functional difference AFAICT).

Bug: T189594
Change-Id: I3ce63386cb35441acfa226f313ec8aac1aa417a6
2018-04-03 07:53:53 +02:00
jenkins-bot
2c46e06676 Merge "Introduce deleteAutoPatrolLogs maintenance script" 2018-04-03 05:25:53 +00:00
Amir Sarabadani
e1a23c9aad Introduce deleteAutoPatrolLogs maintenance script
It's useful to delete old patrol logs that are not useful

Bug: T189594
Change-Id: I605bb85f172eb25df45ed83ce50a3d1044f1c281
2018-04-03 03:42:04 +02:00
Max Semenik
aa9bbe6051 tests: Remove some unused stuff in phpunit tests
Change-Id: Ica20e4f4ac0887b7cac12700ffcd15f587b3ba01
2018-03-26 22:45:29 +00:00
Umherirrender
63d96c15fd build: Updating mediawiki/mediawiki-codesniffer to 16.0.0
Change-Id: I59b59f79bbf3ce4feff3b3a20c1c31bc16370531
2018-02-17 13:29:13 +01:00
Umherirrender
45da581551 Use ::class to resolve class names in tests
This helps to find renamed or misspelled classes earlier.
Phan will check the class names

Change-Id: Ie541a7baae10ab6f5c13f95ac2ff6598b8f8950c
2018-01-26 22:49:13 +01:00
Lucas Werkmeister
cf6d72ad8b Add missing Maintenance import
Without this import, the @var Maintenance comment on $maintenance
doesn’t refer to the right class.

Change-Id: I2b5efa422f3e9d50f2132658b04ea2814af61954
2018-01-24 15:05:39 +01:00
Adam Roses Wight
2df1e9e5fc Replace some of MaintenanceTest with dataProviders
Bug: T184775
Change-Id: Icbaf3cbcf3c51e5b4cd53d55a5230534e74a0a38
2018-01-22 06:43:05 +00:00
Adam Roses Wight
a4df91da77 Refactor MaintenanceTest to use a base test case
Bug: T184775
Change-Id: I0cb2320f765e847a59c721918401da07a3a2b24a
2018-01-21 22:16:19 -08:00
Adam Roses Wight
c8f1ac23bc Begin splitting out maintenance test base classes
Bug: T184775
Change-Id: I73c2f3c6975deec50cf879201cf292c217b51c51
2018-01-21 22:16:19 -08:00
Adam Roses Wight
06fe44872c Revert accidentally removed trait
Change-Id: I82283be89f3f155d7793d4c900927d81a60d5e95
2018-01-18 19:08:25 +00:00
jenkins-bot
a39062ee40 Merge "Add more data to categories dump" 2018-01-17 21:58:31 +00:00
jenkins-bot
561b16bc08 Merge "New namespace MediaWiki\Tests\Maintenance" 2018-01-17 10:14:41 +00:00
Stanislav Malyshev
dc2fd34eb1 Add more data to categories dump
Hidden category: <cat> a mediawiki:HiddenCategory .
Pages count: <cat> mediawiki:pages 10 .
Subcats count: <cat> mediawiki:subcategories 5 .

Note that pages count includes only actual articles, unlike mediawiki
table.

Bug: T173980
Change-Id: I6d34c58f844411f891195776406e11acd2aef7b1
2018-01-17 00:40:16 +00:00
jenkins-bot
58858df842 Merge "Port categories dump header fix" 2018-01-17 00:19:43 +00:00
Adam Roses Wight
c7e8c25e8f New namespace MediaWiki\Tests\Maintenance
Bug: T184775
Change-Id: I041b8eb4f1ef3cf882a8082ff3f208604b8edf96
2018-01-16 15:09:44 -05:00
Adam Roses Wight
f28c5739fd Minor documentation cleanup
Bug: T184775
Change-Id: I883a2ebc0a1ce7667a92623a4861be80df26a65d
2018-01-16 13:50:32 -05:00
Chad Horohoe
93d44c9a42 Move BaseDump into includes/export/
There's no reason for this to have to live in Maintenance land. It's
generally useful and lets us avoid some random require/include calls

Change-Id: I60419c7f9fc52313905053bbeb3aa81666c9160c
2018-01-08 22:10:25 -08:00
Umherirrender
255d76f2a1 build: Updating mediawiki/mediawiki-codesniffer to 15.0.0
Clean up use of @codingStandardsIgnore
- @codingStandardsIgnoreFile -> phpcs:ignoreFile
- @codingStandardsIgnoreLine -> phpcs:ignore
- @codingStandardsIgnoreStart -> phpcs:disable
- @codingStandardsIgnoreEnd -> phpcs:enable

For phpcs:disable always the necessary sniffs are provided.
Some start/end pairs are changed to line ignore

Change-Id: I92ef235849bcc349c69e53504e664a155dd162c8
2018-01-01 14:10:16 +01:00
Kunal Mehta
75160bdd3b Use MediaWikiCoversValidator for tests that don't use MediaWikiTestCase
Change-Id: I8c4de7e9c72c9969088666007b54c6fd23f6cc13
2018-01-01 08:28:02 +00:00
jenkins-bot
df3e3f44cb Merge "maintenance: Add unit test for Benchmarker class" 2017-12-28 09:22:01 +00:00
Timo Tijhof
25ce819e1c maintenance: Add unit test for Benchmarker class
Change-Id: I3f835fc07741fd42b8adb5b019f72589429cc14f
2017-12-27 22:15:21 +00:00
Kunal Mehta
772e734cba Add @covers tags to CategoriesRdfTest
Change-Id: I6e2eae3fc2ac722dc94bee1a7aa6632e08a4d097
2017-12-24 15:23:49 -08:00
Stanislav Malyshev
bb2453fa7c Port categories dump header fix
This fix is ported from https://gerrit.wikimedia.org/r/#/c/372905
since it does not belong to SPARQL updates really.

It changes main node for category dump to
<http://acme.test/wiki/Special:CategoryDump>
thus allowing to support multiple wikis living on the same domain.w

Change-Id: Ie1ac5ddf6b3b73f3966274f90abc1db50061b494
2017-11-28 18:04:43 -08:00
Kunal Mehta
0e1fc6575e Refactor some Installer code into ExecutableFinder
Refactor Installer::locateExecutableInDefaultPaths() into a separate
utility class, ExecutableFinder. This class is already used in plenty of
places outside of the installer, so it's ripe for being extracted.

This class is located in utils/ due to the dependency upon
Shell::command(). Once that no longer has a dependence upon MediaWiki,
this class can be moved to libs/ too.

Change-Id: I175465acc0d64f990445ce05fabcee8b88a0b259
2017-10-26 11:42:05 -07:00
MusikAnimal
d09554b6ef Add basic IP range support to Special:Contributions
This works by using the new table introduced with T156318.

The only thing that differs from normal Special:Contribs is we are
showing the IP address next to each entry. This is it how it is
displayed if you request to see newbie contributions:
https://en.wikipedia.org/wiki/Special:Contributions?contribs=newbie

For the time being, Special:DeletedContributions does not support
IP ranges. Various other irrelevant links such as Uploads and Logs
are also hidden.

Refer to P4725 for a way to automate creation of edits by random
IPs in your dev environment.

IP::isValidBlock() has been deprecated with this dependent change:
https://gerrit.wikimedia.org/r/#/c/373165/

Bug: T163562
Change-Id: Ice1bdae3d16cf365da14c6df0e8d91d2b914e064
2017-09-05 16:15:33 -04:00
Stanislav Malyshev
d9bb673b72 Produce RDF dump of all categories and subcategories in a wiki.
Example:
http://en.wiki.local.wmftest.net:8080/wiki/Category:Ducks> a mediawiki:Category ;
        rdfs:label "Ducks" ;
        mediawiki:isInCategory <http://en.wiki.local.wmftest.net:8080/wiki/Category:Birds> .

Bug: T157676
Change-Id: I59b9603581b37af59d17dd6c38247c85aee44911
2017-08-28 00:30:35 -07: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
Aaron Schulz
6fb5844fec Fix TextPassDumperDatabaseTest::testPrefetchPlain postgres failures
The insertId() method was returning a string, which caused the
returnValueMap not to trigger due to int/string mismatches.

Also add sanity integer cast to WikiPage::insertOn().

Added a few more type docs.

Bug: T75174
Change-Id: Id1090f3e3d0481272a3d13c3af8f2588f06dc912
2017-05-26 21:43:17 +00:00
Timo Tijhof
447ce7e39a phpunit: Avoid use of deprecated getMock for PHPUnit 5 compat
The default will remain PHPUnit 4.x due to PHP 5.5 support.

But, we should allow developers to run tests with newer PHPUnit
versions which are noticably faster (especially for code coverage
reports).

* <https://github.com/sebastianbergmann/phpunit/wiki/Release-Announcement-for-PHPUnit-5.4.0>
  PHPUnit 5 deprecates the getMock() shortcut for getMockBuilder()->getMock().
  It instead introduces the shortcut createMock() which has better defaults
  than getMockBuilder(). For example, it sets 'disableArgumentCloning' and
  other things by default.

  Going forward, code should either use getMockBuilder directly and configure
  it using the setter methods (instead of the confusing variadic arguments
  of getMock) or simply use the new minimalistic createMock method. This patch
  backports the createMock method to MediaWikiTestCase so that we can start
  using it.

Change-Id: I091c0289b21d2b1c876adba89529dc3e72b99af2
2017-04-06 00:44:32 +00:00
James D. Forrester
1e9c361960 tests: 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: I46261416f7603558dceb76ebe695a5cac274e417
2017-02-21 02:14:34 +00:00
Antoine Musso
ccecd52b84 tests: speed up fetchTextTest
The test is adding/resetting database data on every tests, however it is
not necessary.

Switch from addDBData to addDBDataOnce.
Drop the tablesUsed[] additions, they are not needed and trigger a
resetDB().
Change the textId### variables tracking created revisions to static
variables so they are kept between tests.

On my setup the test run time goes down from 1.7 sec to 0.5 sec.

Change-Id: Ibd3183b7fbf7dcf2c0c6d1268e1b94b11919cbf3
2017-01-03 15:39:27 +01:00
Thiemo Mättig
00c3f09566 Remove empty lines from PHP and JavaScript comment blocks
This is a pure documentation change. It mostly removes empty lines from
comments (and entirely empty comments), as well as adds a few missing
documentation blocks and fixes a minor mistake. I hope it's ok to have
this in one patch. I can split it, please tell me.

Change-Id: I9668338602ac77b903ab6b02ff56bd52743c37c4
2016-12-09 09:01:06 +00:00
addshore
b12086b618 Get ConfigFactory & MainConfig from MediaWikiServices
Change-Id: Iafdd7e00747060572463ffb05aae4543f3a06163
2016-11-23 00:12:38 +00:00
Ori Livneh
b19ff38846 Clean-up of MediaWikiTestCase::checkHasGzip()
* Move the method from MediaWikiTestCase to DumpTestCase. Only subclasses of
  DumpTestCase use it, and it is not sufficiently well-designed to be a part
  of MediaWikiTestCase. (I'd want something more generic, like
  "$this->markSkippedUnlessExecutable()", rather than a method dedicated solely
  to establishing the availability of the gzip binary.)
* Fix it so that the result of the check is actually cached. It wasn't,
  previously, because of how 'static' works in PHP.
* Be content with checking that gzip is in $PATH instead of actually executing
  it.

Change-Id: Iec687a6bfe75912e1875afc3abb4fb6197a0b3aa
2016-06-01 10:44:23 -07:00
umherirrender
932c37e3cb Use english messages for background use of Status::getWikiText
Status::getWikiText is used for internal logging, api error messages and
maintenance scripts. All this places are usually in english, so pass an
english language to getWikiText.

Change-Id: I3010fca8eb5740a3a851c55a8b12e171714c78f7
2016-04-12 20:01:44 +02:00
Reedy
b5656b6953 Many more function case mismatches
Change-Id: I5d3a5eb8adea1ecbf136415bb9fd7a162633ccca
2016-03-19 00:20:58 +00:00
Reedy
1834ee3d8e Fix numerous class/function casing
Change-Id: I23982bfa0548c9ea3bdb432be7982f1563930715
2016-03-18 23:14:49 +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
This, that and the other
4abb459392 Refactor dumpBackup.php and dumpTextPass.php to be Maintenance subclasses
Use the Maintenance class's new $orderedOptions and support for
passing options multiple times. This allows for option "chaining".

The BackupDumper and TextPassDumper class now extend Maintenance, but
should continue to function as before. The public function processArgs()
has been removed and replaced by processOptions(), which takes no
parameters. It is unlikely that users of these classes were calling
processArgs.

Inheritors of these classes that overrode processOption() will now need to
override processOptions() and use Maintenance::getOption() and friends.

The maintenance/backupTextPass.inc file has been deleted. Users should
include maintenance/dumpTextPass.php instead.

Bug: T122587
Change-Id: I2473ee119c185d1b2b00ac4b1e70ee8a6cafe4a3
2015-12-31 20:46:54 +11:00
Andrew H
1ae06b4f3e Add loadWithArgv() to Maintenance class
Very useful for passing in arguments to test Maintenance scripts.
Also, add a comment clarifying when $orderedOptions is available.

Change-Id: Ib25b3b36816bdf566c427b67646554a31a9fef0f
2015-12-31 01:18:48 +00:00
Andrew H
0a0b02b56c Add support for specifying options multiple times in Maintenance scripts.
Bug: T122588
Change-Id: I847d45684ccd4054f4a159394266dc3e5506bbdb
2015-12-30 04:33:29 +00:00
umherirrender
41c0c205ae Move comment in backup_PageTest.php
Move the comment at the begin of the function out of it to a doc
comment.

Change-Id: I6febf51a74de88204d54b1e3251df187197c1819
2015-10-14 09:08:52 +00:00
umherirrender
977c810302 Remove empty line comments
Remove empty line comments as found by the
MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.EmptyComment sniff

Change-Id: I5d694f7a7d3bc97e16300ba03c60ad17f3c912a5
2015-10-14 09:46:44 +02:00