Commit graph

2085 commits

Author SHA1 Message Date
Gergő Tisza
9bd9289c6c filerepo: Improve identification of ForeignAPIRepo requests
These requests are usually sent to a wiki operated by a different
organization so UA etiquette is important.
* Add the site's URL (the URL of the main page, more specifically)
  as a contact address.
* Add the site's URL as a referer as well.

Considered but not done:
* Use $wgEmergencyContact as the contact part of the UA. It's not
  guaranteed to be set correctly, while the main page URL always
  exists and will usually be enough to pinpoint the wiki (except
  maybe in some intranet scenarios).
* Include information about the user making the request. Would
  be a privacy risk + probably useless due to caching.
* Include information about the page the request is for. Would
  require lots of refactoring (making the patch harder to
  backport) or relying on the context title (which might be
  fragile), and in any case probably unreliable due to caching,
  and doesn't seem very relevant to the operator of the foreign
  site.

Bug: T400881
Change-Id: I968fac6ee0ebbc5a2bd3244f57851eb64125c93d
2025-08-18 21:02:23 +00:00
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
Gergő Tisza
786e87c75c Fix img_auth message logic
Do not pass arbitrary parameters to the generic message whose
purpose is to hide details; parameters can be revealed with
uselang=qqx.

Change-Id: I6e239bc91db9089aea36e91908fe50b5a5a429d8
(cherry picked from commit c5a62853cc2ebc85cbcfcc932f78bc87657a5dc1)
2024-11-14 01:05:30 +00:00
Reedy
7a43ed4759 Updated wikimedia/scoped-callback from 4.0.0 to 5.0.0
Bug: T378300
Change-Id: I9c4306842ae6a21000f14e2ac36052560f5423cb
Depends-On: Ic224f2c33d76b1430c5faef6af341b256c3f4855
(cherry picked from commit 2b853b863b875678ca538a176c5f0bef794887ac)
2024-11-10 00:30:11 +00:00
Fomafix
83e1735d79 img_auth: Output lang and dir in HTTP and HTML on error message
The messages in the output are in user interface language:

curl -i -H 'Accept-Language: nl' http://localhost/mediawiki/img_auth.php

Change-Id: Ie42af75b1adb1c77968d0f9b8be24c47cdbf05df
(cherry picked from commit 180763bdfa3906539c752686fb4a5101593bdac8)
2024-10-29 15:18:52 +00:00
Tim Starling
0be1887f2d FileRepo: Add support for the new Shellbox large file feature
* Add FileBackend::addShellboxInputFile(), allowing Shellbox to read
  directly from a FileBackend. Add generic, FS and Swift
  implementations.
* Add FileRepo wrapper, which takes a FileRepo virtual URL.
* Add File::addToShellboxCommand(), which allows a File to be used as
  input in a Shellbox command.
* Add configuration.
* Extend FileBackend::getFileHttpUrl(), adding method and ipRange
  parameters. Unindent existing code.

I was going to add support for PUT requests, but I reverted it due to
the impossibility of supporting FileBackendMultiWrite. I left the method
parameter in getFileHttpUrl().

Bug: T292322
Change-Id: If9487a0c9586065bf044b69ac04cc7a06b6e8856
(cherry picked from commit 8cdde9dcb03e33332e49aed06aa71b60ae2c9b33)
2024-10-29 02:50:07 +00:00
Umherirrender
1b29f07440 Use namespaced classes
Changes to the use statements done automatically via script
Addition of missing use statement done manually

Change-Id: I73fb416573f5af600e529d224b5beb5d2e3d27d3
2024-10-21 20:41:20 +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
9203493606 Add namespace to remaining parts of Wikimedia\FileBackend
Bug: T353458
Change-Id: I49c843c9d8f6459c0fbf774afeea7a82fa564b59
2024-10-03 16:21:22 +00:00
James D. Forrester
cc28acc455 Add namespace to remaining parts of Wikimedia\Mime and Wikimedia\Stats
Bug: T353458
Change-Id: If0137003ab625017d322d57870448a02569668c3
2024-09-27 16:19:10 -04: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
James D. Forrester
9e5c1e8ac7 Add namespace to IDBAccessObject and DBAccessObjectUtils
Bug: T353458
Change-Id: I23cf7991f8792d4d000d1780463d8ce76dc0aee0
2024-09-27 16:19:10 -04:00
jenkins-bot
18eb434cf5 Merge "Pass function name to IDatabase functions" 2024-09-20 01:25:26 +00:00
Umherirrender
fdac97eaf3 Pass function name to IDatabase functions
Change-Id: Ie2a1e5052e5b61bbb5b89905de942f47d3f1413d
2024-09-19 21:02:52 +02:00
Umherirrender
63d2f5571a Pass function name to HttpRequestFactory::create
Change-Id: Iaed5489a85a5a6e685829e151436afc94310fbd0
2024-09-19 19:59:46 +02:00
Ebrahim Byagowi
aa16b5e7e6 Avoid use of deprecated wfExpandUrl in various places
Bug: T319340
Change-Id: I98e8e3a8fd135a554a85f6399033756c88ea415f
2024-09-09 20:55:52 +00:00
jenkins-bot
45ee8e263f Merge "filerepo: Avoid assignment in condition in File::getThumbnailSource" 2024-09-04 11:07:33 +00:00
jenkins-bot
451ac0891b Merge "filerepo: Remove unused LocalFileMoveBatch::$archive" 2024-09-01 17:07:13 +00: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
Umherirrender
c9a4f4c9c5 filerepo: Remove unused LocalFileMoveBatch::$archive
Unused since the addition in 8d85629c58 (r34169)

Change-Id: Id08ee260e320d8c97c2c3576d998af1b70952f27
2024-09-01 14:00:13 +02:00
Umherirrender
9206a2599f filerepo: Avoid assignment in condition in File::getThumbnailSource
Change-Id: If20eddd8376ae2e8e29c4e56cd51f7b8eb6642b0
2024-09-01 00:09:20 +02:00
Bartosz Dziewoński
df4cbf5ac6 Replace gettype() with get_debug_type() in debug/log/test output
get_debug_type() does the same thing but better (spelling type names
in the same way as in type declarations, and including names of
object classes and resource types). It was added in PHP 8, but the
symfony/polyfill-php80 package provides it while we still support 7.4.

Also remove uses of get_class() and get_resource_type() where the new
method already provides the same information.

For reference:
https://www.php.net/manual/en/function.get-debug-type.php
https://www.php.net/manual/en/function.gettype.php

In this commit I'm only changing code where it looks like the result
is used only for some king of debug, log, or test output. This
probably won't break anything important, but I'm not sure whether
anything might depend on the exact values.

Change-Id: I7c1f0a8f669228643e86f8e511c0e26a2edb2948
2024-07-31 19:33:57 +02:00
Umherirrender
07db7102cc Replace deprecated LogFormatter::newFromRow/newFromEntry
Change-Id: I453ce3148a46fcb9cc5c685cee92274e0cb4f98a
2024-07-29 22:26:41 +02:00
Bartosz Dziewoński
c9f73efd5a Namespace MessageSpecifier under Wikimedia\Message\
In change I625a48a6ecd3fad5c2ed76b23343a0fef91e1b83 I am planning to
make Wikimedia\Message\MessageValue use it, and we try to pretend that
it is a library separate from MediaWiki, so it makes sense to move
MessageSpecifier to the same namespace under Wikimedia\.

Bug: T353458
Change-Id: I9ff4ff7beb098b60c92f564591937c7d789c6684
2024-07-28 14:21:32 +02:00
Umherirrender
fc9e42823b rdbms: Create IReadableDatabase::andExpr() / ::orExpr()
Avoid the call to internal constructor of AndExpressionGroup and
OrExpressionGroup by creating a factory function similiar as the
IReadableDatabase::expr function for Expression objects.

This is also a replacement for calls to ISQLPlatform::makeList with
LIST_AND or LIST_OR argument to reduce passing sql as string to the
query builders.

Created two functions to allow the return type to be set for both
expression group to allow further calls of ->and() or ->or() on the
returned object.
Depending on the length of the array argument to makeList() it is
sometimes hard to see if the list gets converted to AND or OR, having
the operator in the function name makes it easier to read, so two
functions are helpful in this case as well.

Bug: T358961
Change-Id: Ica29689cbd0b111b099bb09b20845f85ae4c3376
2024-07-11 15:29:20 +00:00
thiemowmde
32740d993c filerepo: Document guaranteed sort order for File::getHistory
This is currently guaranteed, and a lot of code already relies on
it, e.g. in the FileImporter extension. It's de-facto part of the
stable interface already, just not well documented.

The original @stable was added in 2020 via I635f0fd.

Change-Id: Ia6096a1a0934bc4301fff6baf96c5952dac8809c
2024-07-07 16:48:31 +02:00
Cole White
1d22bf1350 File: handle stats for recursive transformation calls
TimingMetric->start() and stop() cannot handle recursion due to statefulness.

To fix, we'll measure the metric manually so that the sample will be
captured in a single operation.

Bug: T367110
Bug: T367928
Change-Id: I663d32e0211df35d5295bf2a09175e6fdcb4c5ed
2024-06-20 18:47:38 +00:00
Umherirrender
9879723ef3 Use namespaced classes (1)
Changes to the use statements done automatically via script
Addition of missing use statement done manually

Change-Id: Ic4d4dd61de5ab896fb6173eb579c81f164a1e4a3
2024-06-16 20:18:23 +02:00
jenkins-bot
0d29a60676 Merge "User objectCacheFactory methods not deprecated ObjectCache methods" 2024-06-12 12:42:05 +00:00
jenkins-bot
2ec0f7d9ec Merge "Add dark mode support to plain html outputs" 2024-06-11 11:19:09 +00:00
Ebrahim Byagowi
ede4d6ec12 Add dark mode support to plain html outputs
Nowadays files transferred to browser via text/* MIME are also getting
automatic dark mode by the browsers so this makes these simple pages
compatible with those features of the browsers.

Change-Id: Id8360ff3ca6dbe7b78e30194fde292763479cb21
2024-06-09 15:03:14 +03:30
Wandji69
1665ea876f User objectCacheFactory methods not deprecated ObjectCache methods
Bug: T363770
Change-Id: I2335b315bec6a540409492df4891c518640966d5
2024-06-06 09:59:24 +01:00
Func
f872ea9061 File: Remove the unused migrateThumbFile() stub function
Follow-up to commit 250b23aa, which removed the override in LocalFile
and the call to it, but left this stub.

Change-Id: Ie269e2f78010f016962f82b5bab3ed7d9b03b365
2024-06-02 03:04:30 +08:00
jenkins-bot
90ababa4da Merge "Migrate File to statslib" 2024-05-31 22:25:45 +00:00
Thomas Arrow
e6b5823b46 Migrate File to statslib
Updates:
 * media.thumbnail.generate.bucket
 * media.thumbnail.generate.fetchoriginal
 * media.thumbnail.generate.store
 * media.thumbnail.generate.transform

This doesn't attempt to label the multiple generate methods
becuase they appear to me to have very heterogeneous
functionality

Patches squashed into this commit:
 * I652f31fd8a553b8f197fb51ffd2cca34199c7394
 * I8edc96668b4e5968b8b44dc92fe4fdc3f29fcbab
 * I8edc96668b4e5968b8b44dc92fe4fdc3f29fcbab

Bug: T359344
Change-Id: Icec6600b4751568ef93f9fbe9e2063770d405bcb
2024-05-31 21:37:00 +00:00
Umherirrender
a9adc61d35 Use RawSQLValue for some SET clauses in update/upsert
Change-Id: I03c068c4bf098ab073989a0ea32a0f87fe878727
2024-05-29 19:48:09 +00:00
jenkins-bot
0f11f80b45 Merge "Change some type hints from IDatabase to IReadableDatabase" 2024-05-24 16:54:54 +00:00
Umherirrender
57d623f530 Change some type hints from IDatabase to IReadableDatabase
Use narrow interface if no writes are done

Change-Id: I55148c8b6fda8830a29a235c63fc118f636ab3e6
2024-05-24 16:11:12 +00:00
Func
3bbb046d83 ImageHistoryList: Link to interwiki user if the prefix is valid
Linker already has logics to detect interwiki prefix for external users.

Change-Id: Icbe5274656ab66effd6734d8b18b9c53dcfe2d7e
2024-05-23 19:43:30 +00:00
Ebrahim Byagowi
d21cc67450 Add namespace and deprecation alias to FileBackend
This patch introduces a namespace declaration for the
Wikimedia\FileBackend to FileBackend and establishes a class
alias marked as deprecated since version 1.43.

Bug: T353458
Change-Id: Id897687b1d679fd7d179e3a32e617aae10ebff33
2024-05-19 22:35:58 +03:30
Thomas Arrow
aef7c222b7 Migrate media.thumbnail.stream to statslib
Bug: T359344
Change-Id: Iec6b956f2efb9e7185114c3c1f2b95c54226290b
2024-05-16 23:30:26 +00:00
jenkins-bot
600e7aca09 Merge "filerepo: extract AuthenticatedFileEntryPoint from img_auth.php" 2024-05-16 15:26:34 +00:00
Ebrahim Byagowi
a717db8e60 Add namespace and deprecation alias to FormatJson
This patch introduces a namespace declaration for the
MediaWiki\Json to FormatJson and establishes a class
alias marked as deprecated since version 1.43.

Bug: T353458
Change-Id: I5e1311e4eb7a878a7db319b725ae262f40671c32
2024-05-16 16:28:01 +03:30
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
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
Umherirrender
33dd935478 Migrate to IReadableDatabase::newSelectQueryBuilder
This cases cannot benefit from the SelectQueryBuilder as each argument
get processed by hooks with fix signature or coming from abstract
functions providing the arguments separate.

Bug: T344971
Change-Id: I6490caae3984efaae81bd2583220a7dd1c3b371d
2024-05-05 17:29:51 +02:00
Umherirrender
195288a897 filerepo: Use IDatabase for type-hinting instead of DBConnRef
DBConnRef is internal, use of IDatabase interface is more common

Change-Id: Id389a6d85741ae26243319704b4edd41df586d88
2024-05-03 15:53:52 +00:00
Amir Sarabadani
856fda6f94 Migrate several more raw SQL building to expression builders
Also removing a test from WatchedItemQueryServiceUnitTest. These tests
have been written extremely poorly and have caused issue many times over
the years not allowing us to do any refactors. There are still pretty
good integration tests in place.

Bug: T361023
Change-Id: I400294fbbe70ac98508f254a4ed72be14e018975
2024-04-26 21:24:20 +02:00
Bartosz Dziewoński
4f837c9932 Remove again use of MWException in ThumbnailEntryPoint
This code was previously removed from thumb.php
in 7acfa6a0a5,
accidentally reintroduced in ThumbnailEntryPoint
in 9638fa314a.

Change-Id: I1afaf98d87e0b8372f5a9b776883eb4d3d1da683
2024-04-23 23:53:33 +02:00