Commit graph

253 commits

Author SHA1 Message Date
Umherirrender
4ed3a3b051 filerepo: No exception on redirect without width in ThumbnailEntryPoint
Catch the exception and return Http Code 400 as already done in the
class for the non-redirect code path.

To get the exception, visit /thumb.php?f=Redirect.jpg

Bug: T387684
Change-Id: I45202572dfce8b60a8aed9343f7d99e2eee12415
(cherry picked from commit b43c89b297e895cb77fbf0f9efd987c6dbf7f50e)
2025-04-29 20:01:15 +00:00
Umherirrender
839613ff77 tests: Use namespaced classes
Changes to the use statements and some additions
are done automatically via script
This also updates @covers tag for the namespaced classes

Change-Id: I859ba6d05018c99710b744e2becab432410d3bca
2024-10-21 18:53:02 +02:00
Umherirrender
e662614f95 Use explicit nullable type on parameter arguments
Implicitly marking parameter $... as nullable is deprecated in php8.4,
the explicit nullable type must be used instead

Created with autofix from Ide15839e98a6229c22584d1c1c88c690982e1d7a

Break one long line in SpecialPage.php

Bug: T376276
Change-Id: I807257b2ba1ab2744ab74d9572c9c3d3ac2a968e
2024-10-16 20:58:33 +02:00
James D. Forrester
53b67ae0a6 Add namespace to remaining parts of Wikimedia\ObjectCache
Bug: T353458
Change-Id: I3b736346550953e3b2977c14dc3eb10edc07cf97
2024-09-27 16:19:10 -04:00
Umherirrender
0a69e0bc53 tests: Use const for some static data in test files
Change-Id: Id7ccd48e3bf626095e2d3929831b5d87ed0be948
2024-09-01 23:24:11 +02:00
Umherirrender
20dadba5be filerepo: Add missing documentation to class properties
Add doc-typehints to class properties found by the PropertyDocumentation
sniff to improve the documentation.

Once the sniff is enabled it avoids that new code is missing type
declarations. This is focused on documentation and does not change code.

Change-Id: Ifbc2ce0c68865c5d32689e56c6215a5099f7478b
2024-09-01 12:09:37 +00:00
Fomafix
e30bfd1484 Use $this->setRequest and $this->setGroupPermissions in PHPUnit tests
Change-Id: I3d28431029ba0569950ffea68f18f24daaf59079
2024-07-11 18:38:00 +00:00
jenkins-bot
82d91ed739 Merge "Use MainConfigNames constants in tests where possible" 2024-07-11 12:46:04 +00:00
thiemowmde
4bd95cd96b Use MainConfigNames constants in tests where possible
I believe this makes the code less brittle, and also makes it a bit
more obvious what these strings are meant to represent.

Change-Id: Ia39b5c80af4b495931d0a68fd091b783645dd709
2024-07-10 10:11:22 +00:00
Ebrahim Byagowi
fab78547ad Add namespace to the root classes of ObjectCache
And deprecated aliases for the the no namespaced classes.

ReplicatedBagOStuff that already is deprecated isn't moved.

Bug: T353458
Change-Id: Ie01962517e5b53e59b9721e9996d4f1ea95abb51
2024-07-10 00:14:54 +03:30
jenkins-bot
cbec790af9 Merge "ThumbnailEntryPointTest: Set named user in context" 2024-06-27 10:17:04 +00:00
jenkins-bot
e8afd7eb4f Merge "Thumbnail404EntryPointTest: Set named user in context" 2024-06-27 10:14:41 +00:00
jenkins-bot
78ff1555ab Merge "AuthenticatedFileEntryPointTest: Set named user in context" 2024-06-27 10:11:10 +00:00
Kosta Harlan
205622af1b
LocalFileTest: Update to pass with temp accounts enabled
Why:

- These tests currently fail when temp accounts are enabled because they
  involve making edits that use anonymous users

What:

- Use mock registered authority instead of mock anon authority
- Set a named user in File#upload

Bug: T365669
Change-Id: I3f8a171a23ed7f7e326e88996cea503807e03b52
2024-06-27 08:59:35 +02:00
Kosta Harlan
76f5010f0a
ThumbnailEntryPointTest: Set named user in context
Why:

- The default uploader is the context user, which defaults to an
  anonymous user, and that will fail with temp accounts enabled

What:

- Set a default context user as a named test user account

Bug: T365669
Change-Id: I75eb63e359cd4db01a89ab6c952cc221b54c6dba
2024-06-27 08:53:07 +02:00
Kosta Harlan
e71c2ced1f
Thumbnail404EntryPointTest: Set named user in context
Why:

- The default uploader is the context user, which defaults to an
  anonymous user, and that will fail with temp accounts enabled

What:

- Set a default context user as a named test user account

Bug: T365669
Change-Id: I736267940167f0fdd417a0b3d37f4017f3d58ed0
2024-06-27 08:51:30 +02:00
Kosta Harlan
c9906b28cb
AuthenticatedFileEntryPointTest: Set named user in context
Why:

- The default uploader is the context user, which defaults to an
  anonymous user, and that will fail with temp accounts enabled

What:

- Set a default context user as a named test user account

Bug: T365669
Change-Id: Idfd6d8bc1f4726f5330329c0581f63f9b65dfa23
2024-06-27 08:47:40 +02:00
Wandji69
c257e2276c Replace db with getDb for Tests
Bug: T316841
Change-Id: I29e535e8ee9b5641a4546d53b98cd5060d39681d
2024-06-23 23:47:56 +01:00
Umherirrender
6c41df61e9 tests: Use namespaced classes (1)
Changes to the use statements done automatically via script
Addition of missing use statement done manually

Change-Id: Iae45fa269363be8ee05c598ea6926514ce817762
2024-06-14 17:19:36 +00:00
jenkins-bot
600e7aca09 Merge "filerepo: extract AuthenticatedFileEntryPoint from img_auth.php" 2024-05-16 15:26:34 +00:00
daniel
12aa2374ab filerepo: extract AuthenticatedFileEntryPoint from img_auth.php
The idea is that all entry points should share the code in the
MediaWikiEntryPoint base class. This change just moves code from
the file scope into a class, without any structural changes.

Bug: T354216
Change-Id: Ie2e827d30a070bcc63bdce56891c3aa0a4dacddd
2024-05-16 13:22:00 +02:00
Bartosz Dziewoński
03b9490fe2 ThumbnailEntryPointTest: Fix PHP notice in data provider
Follow-up to 4b35d1e3ed.

Bug: T364879
Change-Id: Ic6d4ffd1f4ea36701407107981a7ca11e45affca
2024-05-14 16:32:05 +00:00
jenkins-bot
e782b3edcb Merge "Break streamThumb() into private methods" 2024-05-10 18:27:40 +00:00
daniel
4b35d1e3ed Break streamThumb() into private methods
Refactor thumbnail streaming code for readability.

Change-Id: I112f6d3998a871108dd937d57217a2d00882db73
2024-05-08 11:15:56 +02:00
jenkins-bot
af9b10ae24 Merge "Make HTTPFileStreamer testable" 2024-04-27 02:01:23 +00:00
daniel
9672a6e5e4 Make HTTPFileStreamer testable
This also improves ThumbnailEntryPointTest by allowing it
to assert which headers got sent.

Change-Id: I33911775bce1b3cc7a53a03c2be50d53a28fabd1
2024-04-26 13:22:55 +02:00
Taavi Väänänen
ed7e787f32
Ignore/fix MediaWiki.Commenting.PropertyDocumentation.WrongStyle
Fix the real issues found by this sniff, and convert the remaining
false positive ignores to per-line ignores so that any more real issues
won't be added.

Change-Id: I18e75d59df327e2d93a3a487c115e92b9f268722
2024-04-22 18:26:14 +03:00
Umherirrender
a89a00ffb8 tests: Migrate to IDatabase::newInsertQueryBuilder
Changed some inserts to use multi-row insert for small performance
benefit where possible and not already used.
InsertQueryBuilder does not return a value, deprecated since 1.33

Bug: T353219
Change-Id: I2380ebc8ec8db178dd790247aefbdd798b6d62ff
2024-04-14 21:56:07 +02:00
daniel
9638fa314a Introduce entry point classes for media files.
This moves a code out of file scope into classes to make it
testable. The code is left in the same structure as it was before,
global functions have been converted into methods on the new
ThumbnailEntryPoint and Thumbnail404EntryPoint classes.

This test introduces comprehensive phpunit tests covering all functional
code paths in ThumbnailEntryPoint. This is intended to support
refactoring of this code.

Change-Id: I459abc7b11d0ab4ee682a863c9525a945048296f
2024-03-30 21:14:05 +01:00
Reedy
85396a9c99 tests: Fix @covers and @coversDefaultClass to have leading \
Change-Id: I5629f91387f2ac453ee4341bfe4bba310bd52f03
2024-02-16 22:43:56 +00:00
Daimona Eaytoy
7acfa6a0a5 Replace more instances of unchecked MWException
Most (all?) of the remaining usages are caught somewhere and will be
migrated later.

Bug: T328220
Change-Id: I5c36693a5361dd75b4f1e7a0bab5ad48626ed75c
2024-01-23 16:20:53 +00:00
Daimona Eaytoy
175c0c4abf Replace more instances of deprecated MWException
Bug: T328220
Change-Id: Iba90f7f9b5766bccc05380d040138d74d5e9558a
2024-01-19 23:11:59 +00:00
Daimona Eaytoy
605d12b9b3 Update tests for PHPUnit 9.6 (part 1)
- Avoid defining abstract test classes (ending in "Test")
- Avoid withConsecutive()
- Avoid getMockClass()

Bug: T342110
Change-Id: I131e0d85bd14e75aaebd6f212b2e64a45d4c73a2
2024-01-16 23:36:15 +01:00
James D. Forrester
4ed5ca48b1 Follow-up 71ff05267: Stop writing to tablesUsed in tests, now unnecessary
Bug: T342301
Change-Id: I5ea01f7ee103570165261bde0965c5b65e04c369
2023-11-21 09:02:48 -05:00
thiemowmde
3790383134 Simplify/remove duplicate assertStatusOK and such
For example:
* assertStatusGood = ok without any errors or warnings
* assertStatusWarning = ok, but not good, i.e. there is a warning

Change-Id: I4b3ec7a3c5b028c0505e1371c297a9c47e448b42
2023-10-19 20:04:36 +00:00
Amir Sarabadani
f5abfb8d58 Bump codesniffer to 42.0.0
Most noisily, this enables MediaWiki.Arrays.OneSpaceInlineArray.

Change-Id: I8ab11399c67ce7e3ab1b6249b591452774393428
2023-09-27 15:06:32 -04:00
Amir Sarabadani
cd2e19c050 tests: Use $this->getDb() instead of wfGetDB() in integration tests
Deprecated long time ago.

Bug: T330641
Change-Id: Ia57f12d350c3346029aafae25534c9ed262a7e98
2023-09-25 21:08:09 +02:00
Amir Sarabadani
abbb4281cb tests: Migrate more cases to SQB
Bug: T344971
Change-Id: Ia69d82d6a6e623b9032240dc910fb47ff5887661
2023-09-21 18:30:37 +00:00
Amir Sarabadani
eaedb7da16 maintenance: Migrate another batch to SelectQueryBuilder
Around fifty-ish. Found becuase of fixed MigrateSelect.

Bug: T344971
Change-Id: If85428d5a033822bfd8ee1f6ab730863bfad55bd
2023-09-21 14:15:42 +02:00
James D. Forrester
94ece673b2 Namespace TitleValue under \MediaWiki\Title
One of the big ones, so doing this alone.

Bug: T166010
Change-Id: I4c901d5c32696d8334ec30cede7d9b6f3d8d645e
2023-09-18 18:24:39 +01:00
Tim Starling
95bd40b25c In query builders, use insertInto() and deleteFrom() instead of insert() and delete()
The design principle for SelectQueryBuilder was to make the chained
builder calls look as much like SQL as possible, so that developers
could leverage their knowledge of SQL to understand what the query
builder is doing.

That's why SelectQueryBuilder::select() takes a list of fields, and by
the same principle, it makes sense for UpdateQueryBuilder::update() to
take a table. However with "insert" and "delete", the SQL designers
chose to add prepositions "into" and "from", and I think it makes sense
to follow that here.

In terms of natural language, we update a table, but we don't delete a
table, or insert a table. We delete rows from a table, or insert rows
into a table. The table is not the object of the verb.

So, add insertInto() as an alias for insert(), and add deleteFrom() as
an alias for delete(). Use the new methods in MW core callers where
PHPStorm knows the type.

Change-Id: Idb327a54a57a0fb2288ea067472c1e9727016000
2023-09-08 10:16:08 +10:00
jenkins-bot
f071c22a9a Merge "rdbms: Drop old class aliases" 2023-08-29 10:47:27 +00:00
Amir Sarabadani
f4e68e055f Reorg: Move Status to MediaWiki\Status\
This class is used heavily basically everywhere, moving it to Utils
wouldn't make much sense. Also with this change, we can move
StatusValue to MediaWiki\Status as well.

Bug: T321882
Depends-On: I5f89ecf27ce1471a74f31c6018806461781213c3
Change-Id: I04c1dcf5129df437589149f0f3e284974d7c98fa
2023-08-25 15:44:17 +02:00
James D. Forrester
447400b423 rdbms: Drop old class aliases
Bug: T344536
Depends-On: I565541d781caaf564ae0c1877f5cb086e3650f22
Depends-On: Ia5fdf3242f9510e4f21670f3746d9364ae2935c6
Depends-On: I6f4b158bdc3ef20a1660e66accca0ffc17104f49
Change-Id: Ia87f1be7e0e68eb7cf792cb1f5ae64ecdfa2c015
2023-08-24 15:18:13 -04:00
Reedy
a1144dc7c5 mark various anonymous functions as static
Change-Id: Iefe896769359f0d32e52bf20aa03e1c3715d5074
2023-08-22 19:38:38 +00:00
Umherirrender
d7f959e528 tests: Use namespaced Wikimedia\Rdbms\IDatabase
Bug: T344536
Change-Id: I29c80fe2ac3effd5e9df4402c598dc33c1b23d5e
2023-08-20 15:18:57 +02:00
Daimona Eaytoy
59b93e9e4f Avoid DB access in non-database tests
Mock the needed dependencies to avoid database access when possible, and
add the test to the Database group otherwise.

Bug: T155147
Change-Id: Ic5c39ab35ab4d993721713285180f072497a5a40
2023-08-06 22:57:48 +00:00
Amir Sarabadani
7432b21816 Migrate more calls of Database::select* to SelectQueryBuilder
Using a php parser written on top of ANTLR4, done semi-automatically.

I checked everything and made adjustments.

Bug: T311866
Change-Id: I6150c6909bce8f3dbd745a26380cc0af9d9c547f
2023-07-26 13:01:28 +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
Amir Sarabadani
614cd41507 tests: Migrate Database::delete calls to DeleteQueryBuilder
Bug: T340065
Change-Id: I92e85efd5d23d100a5df38aedb8edaecc5cbfc65
2023-07-14 14:48:42 +02:00