Commit graph

48 commits

Author SHA1 Message Date
Amir Sarabadani
e7dcb3802e tests: Migrate Database::select usages to SelectQueryBuilder
Bug: T311866
Change-Id: I0324919f4e40f4e2db3dab1e9aacf74177170b20
2023-07-17 14:24:30 +02:00
Amir Sarabadani
77342327ee tests: Migrate calls to Database::update to UpdateQueryBuilder
Bug: T330640
Change-Id: I30f9e84658fbd996b5512e96dda3f6412ebf3a20
2023-07-14 15:40:11 +02:00
Timo Tijhof
cad9a5e96b Remove left-over complexity in SpecialPage classes for query groups
No longer used as of I7a31a07a8c3f1e265ac43ab59f23326590b407c3.

Bug: T263127
Change-Id: Ie58c0bb2ed8ff5b0fc6d4e42256010eb825fd9dd
2023-05-02 23:27:14 +00:00
Amir Sarabadani
830c51f0a2 Specials: Mass switch everything to IConnectionProvider from LB
Bug: T330641
Change-Id: Ie1772da59f92213fea598f02385c3e0ac6d200a7
2023-04-19 19:19:16 +02:00
James D. Forrester
ad06527fb4 Reorg: Namespace the Title class
This is moderately messy.

Process was principally:

* xargs rg --files-with-matches '^use Title;' | grep 'php$' | \
  xargs -P 1 -n 1 sed -i -z 's/use Title;/use MediaWiki\\Title\\Title;/1'
* rg --files-without-match 'MediaWiki\\Title\\Title;' . | grep 'php$' | \
  xargs rg --files-with-matches 'Title\b' | \
  xargs -P 1 -n 1 sed -i -z 's/\nuse /\nuse MediaWiki\\Title\\Title;\nuse /1'
* composer fix

Then manual fix-ups for a few files that don't have any use statements.

Bug: T166010
Follows-Up: Ia5d8cb759dc3bc9e9bbe217d0fb109e2f8c4101a
Change-Id: If8fc9d0d95fc1a114021e282a706fc3e7da3524b
2023-03-02 08:46:53 -05:00
Amir Sarabadani
bbe704b5c1 Reorg: Move some of request related classes to MediaWiki/Request
Redoing I5ea70120d74 but without moving WebRequest that caused issues
with phan-taint-plugin.

Moving:
 - DerivativeRequest
 - FauxRequest
 - FauxRequestUpload
 - PathRouter
 - WebRequestUpload

Bug: T321882
Change-Id: I832b133aaf61ee9f6190b0227d2f3de99bd1717b
2022-10-28 10:15:31 +00:00
Zabe
f6b9381d7f Revert "Reorg: Move some of request related classes to MediaWiki/Request"
This reverts commit 2bdc0b2b72.

Reason for revert: T166010#8349431

Bug: T166010
Change-Id: Idcd3025647aec99532f5d69b9c1718c531761283
2022-10-27 13:14:16 +00:00
Amir Sarabadani
2bdc0b2b72 Reorg: Move some of request related classes to MediaWiki/Request
Moving:
 - DerivativeRequest
 - FauxRequest
 - FauxRequestUpload
 - PathRouter
 - WebRequest
 - WebRequestUpload

Bug: T166010
Change-Id: I5ea70120d745f2876ae31d039f3f8a51e49e9ad8
2022-10-26 16:49:10 +02:00
Derick Alangi
d4ae3e8839 tests: Migrate away from setMwGlobals() to overrideConfigValue(s)()
Change-Id: I1b0e8e2cf4d85ae5ce8ad090cfc47f5086350702
2022-08-14 22:23:25 +01:00
Alexander Vorwerk
decbaf4f38 phpunit: use ->getServiceContainer() in integration tests
Change-Id: I38299cb65eeaadfdc0eb05db4e8c0b0119cfb37d
2022-01-27 22:04:16 +01:00
Tim Starling
c956ce85b7 Use STRAIGHT_JOIN when filtering on frequently used tags
MySQL was incorrectly doing the change_tag table first, even when that
required scanning ~1M rows, because it believed that the only alternative
was scanning the whole of recentchanges, ~10M rows. Use a better model
for the set sizes which takes the query limit into account.

Also:

* Factor out the change_tag_for_display_query hack and avoid copying
  the data more than once
* Add a cache for SpecialRecentChanges::getDB()
* Move the rc_new hack up closer to the other perf hacks

Bug: T298225
Change-Id: Ic3d16dd3ebdc683c7cfce6ae86b60e951145ad7a
2022-01-07 15:07:15 +11:00
Petr Pchelko
e50ccd0512 Fix order of joins in SpecialRecentChanges
After I4d6c175c637a2cb26c63e0b2b27d5ea8ce6b1e0d
some of the filter joins are applied to the query before
the RecentChange joins. Since filter joins depend on actor,
and RecentChange query is the one adding actor joins,
we need to reorder them.

Bug: T281981
Change-Id: Ifbdb24ff5b99b9ec12cb313c48227563696c48c9
2021-05-05 09:29:40 -07:00
Thiemo Kreuz
e4b51a4aae Fix mismatching type hints in ChangesListSpecialPageTest
Some of these parameters are marked as optional and nullable,
but can never be null (the test would fail then), and are
never missing.

While I'm here I also add more strict type hints for
parameters and return types. Note this is only done in tests
and impossible to cause trouble in production.

Change-Id: I1c66325c97d5ea86d9822e789a36542faad1272b
2021-05-01 15:39:54 +00:00
James D. Forrester
df5eb22f83 Replace uses of DB_MASTER with DB_PRIMARY
Just an auto-replace from codesniffer for now.

Change-Id: I5240dc9ac5929d291b0ef1c743ea2bfd3f428266
2021-04-29 09:24:31 -07:00
Petr Pchelko
bfa145fae7 Convert second batch of special pages to authority
Depends-On: Ifc82d29a00d3fd136c44e0699e6bbfa11b8cf2a6
Change-Id: Iaf559a72cc47ec5d2481d7f740ad0eb303c94002
2021-03-04 15:37:59 -07:00
Umherirrender
fc794afe9a Inject services into SpecialRecentChanges/SpecialRecentChangesLinked
This covers only directly used services by this special page and pager
Services used by the base class are not part of this patch set

Bug: T259960
Depends-On: I62855be191ea87bdc5157b6ab879c47815644156
Change-Id: I730ce17548fad3e35e8d8b6730eb3aafd734eac9
2020-11-25 08:53:46 -08:00
Umherirrender
b3e782ddbd Fix unit test in SpecialRecentchangesTest for postgres
Use Database::timestamp
Also pass function name for debugging

Bug: T259026
Change-Id: Id642976ed1d7f275abd90d6ec0e5d492b85d0c9a
2020-07-28 17:30:24 +02:00
Sam Wilson
1342c90537 Fix watchlist query and filters for RecentChanges
This query was correctly excluding expired items from RC, but it
was failing to include them when the unwatched filter was set.

This is a follow-up to https://gerrit.wikimedia.org/r/c/mediawiki/core/+/602211

Bug: T252136
Change-Id: I5d43d746df21cc3674eb2e92c3f604b7c87b7d1a
2020-07-28 08:38:25 +08:00
Stephane Bisson
2e8512c7d0 Remove temporary rcfilters variables
wgStructuredChangeFiltersShowPreference, wgStructuredChangeFiltersShowWatchlistPreference,
and wgStructuredChangeFiltersOnWatchlist were introduced for progressive rollout
of the RCFilters app on RC and WL.

These variables and their related conditional code is no longer needed.

Bug: T196033
Change-Id: Id3799fefd21cd9bea0e089a5e12576ee9ea1085e
2018-09-27 13:39:05 -04:00
Umherirrender
9b8fcb4331 Fix case of SpecialRecentChanges class
Test fails with $wgAutoloadAttemptLowercase = false

Change-Id: Ib8cd202d36d35a36e7513f81cea4a7f8346661bc
2017-09-20 22:12:22 +02:00
Umherirrender
43e8cd0579 Make phpcs pass
Reenable MediaWiki.WhiteSpace.SpaceBeforeClassBrace.NoSpaceBeforeBrace,
because the mentioned bug is fixed

Bug: T172933
Change-Id: I1593bdba2295ebed401b921f2beabed69dba7638
2017-08-11 16:22:42 +02:00
Roan Kattouw
9db2cc13e0 SpecialRecentchanges: Handle ?days= parameter more sanely
Allow fractional values (e.g ?days=0.25). Previously, fractional values
were rounded down (truncated) to integers.

When computing the cutoff timestamp, don't round down to midnight UTC.
This caused a strange phenomenon where ?days=1 would display between
24 and 48 hours' worth of changes depending on when you used it:
if the current time was 2017-07-24 23:59 UTC, the cutoff would be
set at 2017-07-23 00:00 UTC so you would see almost 48 hours' worth,
but if you refreshed two minutes later, the cutoff would be set at
2017-07-24 00:00 UTC and you should see just over 24 hours' worth.
In addition to this strangeness, it also made fractional values
somewhat meaningless and made a feature like "show only the last 3 hours"
impossible to implement.

Bug: T162784
Change-Id: I75b71324e29a4da09939c4b00feeb4cb556f797c
2017-07-24 16:49:05 -07:00
Matthew Flaschen
efe994d3c3 Change delimiter for multiple namespaces and tags
It's ; for namespaces (since that is generally what we're using,
e.g. for STRING_OPTIONS), and | for tags.  I would have
preferred them to all be consistent, but there is one revision
that has a ;, and this seems better than modifying the DB.

Comma is already used as a delimiter between separate parameters
(e.g. hideanons and namepsace).

Also, fix multiple namespaces for parseParameters and add test
cases.

Bug: T164132
Bug: T164133
Change-Id: Iad061e0bc17e3522a3f5d330ac2c8bf9cf0e614f
2017-05-08 23:03:46 -04:00
Stephane Bisson
5bd1b43e6a Fix contradictory RC filters and add back-compat
Some combinations of RC filters should never appear
together because they guarantee to return no data
and cannot be visually represented in the new RC
filters UI (ERI project).

Examples include:
* 'hidemyself' and 'hidebyothers'
* 'hideminor' and 'hidemajor'
* All of the filters in the changeType group (which
  is extended by extensions)

This also handles an old special case, but it now redirects
instead of doing it silently:

hideanons=1 & hideliu=1 & hidebots=1 -> hideliu=1 & hidebots=1
hideanons=1 & hideliu=1 & hidebots=0 -> hidehumans=1

Bug: T151873
Change-Id: Id08dccd07b262ce61c9d38563f19a0ab181e2341
2017-05-04 08:49:36 -04:00
Gergő Tisza
525bfbc8df Switch to librarized version of TestingAccessWrapper
Replaces \TestingAccessWrapper (defined in core) with
\Wikimedia\TestingAccessWrapper (defined in the composer package
wikimedia/testing-access-wrapper).

See https://gerrit.wikimedia.org/r/#/q/topic:librarize-testing-access-wrapper
for downstream patches.

The core version of the class is kept around for a while to avoid
circular dependency problems.

Bug: T163434
Change-Id: I52cc257e593da3d6c3b01a909e554a950225aec8
2017-04-20 14:15:57 +00:00
Matthew Flaschen
aa063f4c5a Back-end of new RecentChanges page, refactoring
Generate old RC, Related changes (it was already displayed and working
on 'Related changes' before this change), and Watchlist/etc. and data
for new UI from back-end.

This moves everything used for defining the old (unstructured) and new
(structured) filters into unified objects, ChangesListFilter and
ChangesListFilterGroup (and sub-classes).

This includes the query logic (see below) and logic for adding
CSS attribution classes.

This is a breaking change (for subclasses of ChangesListSpecialpage)
due to the signature (and name) change of buildMainQueryConds and
doMainQuery.  An alternative that I don't think is a breaking change
would be to put the filter->DB logic in runMainQueryHook, but then it's
doing more than just running a hook.

This is because it used to only build $conds here, but it's clear from
filterOnUserExperienceLevel filters need more than this.  I added all
the DB parameters from the hook, but this could be debated.

I have an checked and fixed the WMF-deployed extensions affected by
this.

Other than that, there should be full back-compat (including legacy
filters not using the new system).

* add hidepatrolled/hideunpatrolled to new UI.

* Move userExpLevel from RC to ChangesListSpecialPage.  Although for
now the structured UI only displays on RC anyway, when it displays on
watchlist, it seems we'll want userExpLevel there.

  Change this to make 'all' exclude unregistered users.

* Don't have front-end convert none-selected to 'all' on string_options.

* Needs the hideanons/hideliu special redirect to be done before this
is merged (T151873)

Bug: T152754
Bug: T152797
Change-Id: Iec2d82f6a830403d1c948a280efa58992e0cdee7
2017-03-11 01:42:01 +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
Stephane Bisson
a795d54810 Special:RC filter: userExpLevel
Allows filtering changes based on user
experience level. Supports the following
levels: 'newcomer', 'learner', 'experienced'

Will be used by the ERI project.

Bug: T149637
Change-Id: Ib2ac92925836ce2f3706d898968538aa18d14d5d
2016-12-21 11:24:15 -05:00
Stephane Bisson
afaab18b08 Special:RC 'hidemajor' filter
'hidemajor', along with the existing 'hideminor'
RC filter, allow showing just the minor edits,
just the major edits, or both.

This will be used by the ERI project.

Bug: T149863
Change-Id: I936a4a1b13d8c4a15c745012cd0f82207d9e57ca
2016-12-07 07:06:26 -05:00
Stephane Bisson
efb4b8a696 Special:RC filter: hideunpatrolled
Allows hiding edits that have not been patrolled.
In other words, showing only edits that have been patrolled.

Will be used by the new Special:RC filters (ERI project).

Bug: T152061
Change-Id: I3cd896812c5af87bc4be53d493055c37298c712f
2016-12-06 18:18:31 -08:00
Stephane Bisson
b33a9844b0 Special:RC filter: hidehumans
Allows showing only bot edits

Will be used by the ERI project.

Bug: T149862
Change-Id: I748eb3c614abd7b8b228efe3da5e9cb569a8618f
2016-12-06 17:55:26 -08:00
Stephane Bisson
9cd114f380 Special:RC filters: hide page edits, new pages, log entries
New RC filters for ERI project:
  hidepageedits
  hidenewpages
  hidelog

Bug: T150060
Change-Id: I6fe852fb0f5386c3385ada5189ceaf0d9bbc979d
2016-12-06 17:54:07 -08:00
Stephane Bisson
a1ab582754 Special:RC tests: ignore order when asserting conditions
Normalize condition object to ignore order and ignore the
following equivalent formats:

  $conds['column'] = 'value';
  $conds[] = "column = 'value'";

This makes the tests more resilient to minor refactoring
that doesn't affect functionality.

Change-Id: I440f230c81182694a952de801cb37b9ddbad5599
2016-11-24 11:50:09 +00:00
Stephane Bisson
fabe7d12a3 RC filter: hidebyothers
Allows hiding edits by other users on
Special:RecentChanges.

It is not available in the current UI but
will be used by the ERI project.

Bug: T149859
Change-Id: I8c1e2238a41d6f5e5ac44cc12cb02a6b4271c237
2016-11-14 10:40:02 -05: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
addshore
d40cd42b9f Enable users to watch category membership changes #2
This is part of a chain that reverts:
e412ff5ecc.

NOTE:
- The feature is disabled by default
- User settings default to hiding changes
- T109707 Touching a file on wikisource adds and
      removes it from a category... Even when page
      has no changes.... WTF? See linked issue,
      marked as stalled with a possible way forward
      for this patch.
      @see https://gerrit.wikimedia.org/r/#/c/235467/

Changes since version 1:
- T109604 - Page names in comment are no longer
      url encoded / have _'s
- T109638 & T110338 - Reserved username now used
      when we can't determine a username for the change
      (we could perhaps set the user and id to be blank
      in the RC table, but who knows what this might do)
- T109688 - History links are now disabled in RC....
      (could be fine for the introduction and worked
      on more in the future)
- Categorization changes are now always patrolled
- Touching on T109672 in this change emails will never
      be sent regarding categorization changes. (this
      can of course be changed in a followup)
- Added $wgRCWatchCategoryMembership defaulting to true
      for enabling / disabling the feature
- T109700 - for cases when no revision was retrieved
      for a category change set the bot flag to true.
      This means all changes caused by parser functions
      & Lua will be marked as bot, as will changes that
      cant find their revision due to slave lag..

Bug: T9148
Bug: T109604
Bug: T109638
Bug: T109688
Bug: T109700
Bug: T110338
Bug: T110340
Change-Id: I51c2c1254de862f24a26ef9dbbf027c6c83e9063
2015-10-20 14:23:48 -07:00
Vivek Ghaisas
c54766586a Fix issues identified by SpaceBeforeSingleLineComment sniff
Change-Id: I048ccb1fa260e4b7152ca5f09b053defdd72d8f9
2015-09-26 23:06:52 +00:00
Bartosz Dziewoński
973cd64489 ChangesListSpecialPage: Implement buildMainQueryConds()
This also involved adding some default options to getDefaultOptions()
and a new method getDB().

Change-Id: I7389a72bfcf176480bfc36f9d6efc467e1a5e76a
2014-01-27 18:32:41 +01:00
addshore
caec5f920a @covers tags for the rest of test files..
Change-Id: I0fafe80531325a412472ab7c9fc6d81c861b3751
2013-10-24 21:38:08 +01:00
Siebrand Mazeland
791d0b2a98 Update code formatting
Change-Id: I16a9b42651f1cfb1a70dffbb67b7b83dfeb90d03
2013-04-26 14:21:20 +00:00
Siebrand Mazeland
49dfbc59d0 Update formatting
6 of n.

Change-Id: I0ca3f1f72349623631ce1d7f3a4e2ed5edbdbdf4
2013-02-15 12:44:42 +00:00
Antoine Musso
0fd05285d7 pass codesniffer on tests/
Fix almost all occurences of the following sniffs:

Generic.CodeAnalysis.UselessOverridingMethod.Found
Generic.Formatting.NoSpaceAfterCast.SpaceFound
Generic.Functions.FunctionCallArgumentSpacing.SpaceBeforeComma
Generic.Functions.OpeningFunctionBraceKernighanRitchie.BraceOnNewLine
Generic.PHP.LowerCaseConstant.Found
PSR2.Classes.PropertyDeclaration.ScopeMissing
PSR2.Files.EndFileNewline.TooMany
PSR2.Methods.MethodDeclaration.StaticBeforeVisibility

Change-Id: I96aacef5bafe5a2bca659744fba1380999cfc37d
2013-01-28 12:14:26 +01:00
Antoine Musso
c6ea55bf54 tests: always call parent setUp
Some class extending MediaWikiTestCase did not call its setUp method. We
most probably always want to do it since MediaWikiTestCase::setUp() does
garbage collection and might do more in the future.

Change-Id: I68dde370a62c8f4a779836ca0c4ad06844fdc916
2012-10-23 19:04:40 +02:00
Timo Tijhof
181c7cdc8e Clean and repair many phpunit tests (+ fix implied configuration)
This commit depends on the introduction of
MediaWikiTestCase::setMwGlobals in change Iccf6ea81f4.

Various tests already set their globals, but forgot to restore
them afterwards, or forgot to call the parent setUp, tearDown...

Either way they won't have to anymore with setMwGlobals.

Consistent use of function characteristics:
* protected function setUp
* protected function tearDown
* public static function (provide..)

(Matching the function signature with PHPUnit/Framework/TestCase.php)

Replaces:
 * public function (setUp|tearDown)\(
 * protected function $1(

 * \tfunction (setUp|tearDown)\(
 * \tprotected function $1(

 * \tfunction (data|provide)\(
 * \tpublic static function $1\(

Also renamed a few "data#", "provider#" and "provides#" functions
to "provide#" for consistency. This also removes confusion where
the /media tests had a few private methods called dataFile(),
which were sometimes expected to be data providers.

Fixes:

TimestampTest often failed due to a previous test setting a
different language (it tests "1 hour ago" so need to make sure
it is set to English).

MWNamespaceTest became a lot cleaner now that it executes with
a known context. Though the now-redundant code that was removed
didn't work anyway because wgContentNamespaces isn't keyed by
namespace id, it had them was values...

FileBackendTest:
* Fixed: "PHP Fatal: Using $this when not in object context"

HttpTest
* Added comment about:
  "PHP Fatal: Call to protected MWHttpRequest::__construct()"
  (too much unrelated code to fix in this commit)

ExternalStoreTest
* Add an assertTrue as well, without it the test is useless
  because regardless of whether wgExternalStores is true or false
  it only uses it if it is an array.

Change-Id: I9d2b148e57bada64afeb7d5a99bec0e58f8e1561
2012-10-09 03:01:51 +02:00
Antoine Musso
c1f23144e1 using real identity for hashar
Converting my pseudonym to use my real identity instead:
Ashar Voultoiz -> Antoine Musso
2011-10-24 09:08:13 +00:00
Platonides
ac4b0129cb buildMainQueryConds() (called by assertConditions) uses a wfGetDB( DB_SLAVE )
Although no data is transmitted to/from the server (create a DB_NONE?)
2011-09-15 20:43:40 +00:00
Chad Horohoe
4998acf894 Partial revert r97035, followup r96930: make recentchanges tests pass again 2011-09-14 03:31:53 +00:00
Krinkle
5bd2898ab1 Renaming SpecialRecentchangesTest file to match conventions
* There should be no two files with the same name
* Test suite files should be named after the main file containing the code being tested followed by "Test"
2011-09-14 01:37:13 +00:00
Renamed from tests/phpunit/includes/specials/SpecialRecentchanges.php (Browse further)