aboutsummaryrefslogtreecommitdiffstats
path: root/includes/libs/filebackend
Commit message (Collapse)AuthorAgeFilesLines
...
* Merge "filebackend: Turn protected properties into actual constants"jenkins-bot2023-10-194-66/+66
|\
| * filebackend: Turn protected properties into actual constantsthiemowmde2023-10-164-66/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | This is a direct follow up to Id0e4b0d from 2019 where these "constants" have been introduced. I believe the reason for using protected properties was that we still had to support PHP 7.0 back then, but class constants can only be marked as protected since PHP 7.1. According to codesearch these are apparently meant to be internal to the filebackend classes in core and not used anywhere else. Change-Id: I55683e3540f8d76324370efecb98d08e07547c28
* | Merge "filebackend: Fix incomplete callable|null type hints"jenkins-bot2023-10-193-5/+5
|\ \
| * | filebackend: Fix incomplete callable|null type hintsthiemowmde2023-10-163-5/+5
| |/ | | | | | | | | | | | | … and make a few generic array type hints more specific, where possible. Change-Id: I1d0a89a9f10f0438f3bdd21d4067b0de69881c56
* | Merge "filebackend: Fix and add missing @return documentation"jenkins-bot2023-10-181-3/+5
|\ \
| * | filebackend: Fix and add missing @return documentationthiemowmde2023-10-161-3/+5
| |/ | | | | | | | | | | | | | | | | | | | | | | | | array[]|bool[]|null[] means: It's either an array of arrays, an array that contains only bools, or an array where all values are null. But this is not what's happening here, as far as I can tell. This minor fixup is motivated by T348688, but doesn't solve it. However, now it's more obvious that the values that trigger the reported error are "null", i.e. some instance of self::$RES_ERROR. Bug: T348688 Change-Id: Ia9debe97d21a3abff7bff75f16a94bec8be6ddc5
* / FSFileOpHandle: add missing @ in @varDannyS7122023-10-171-1/+1
|/ | | | Change-Id: I2771157a31aa6ee2b24fbd957c2c1ec0a0d9bdfc
* filebackend: Log cache set failure in FileBackendStoreUmherirrender2023-09-031-2/+10
| | | | | | Similiar to what happen on cache delete failure Change-Id: I9a29b73850ca99f3e333f7b733dcafedf7a2773b
* Merge "filebackend: Include truncated http body for 502 on SwiftFileBackend"jenkins-bot2023-08-221-31/+35
|\
| * filebackend: Include truncated http body for 502 on SwiftFileBackendUmherirrender2023-08-011-31/+35
| | | | | | | | | | | | | | | | | | | | Put 100 bytes of the body into the log message to possible see more information about the gateway error message See T328872#8757648 Bug: T328872 Change-Id: I8b2df6d318d8de912eb9b992051b209bab236f37
* | Reorg: Move MWTimestamp to MediaWiki\UtilsAmir Sarabadani2023-08-191-0/+1
|/ | | | | Bug: T321882 Change-Id: I48c10343295c4eb3d9ef8037343b0070e928f040
* filebackend: improve SwiftFileBackendList field names and nullity checksAaron Schulz2023-06-234-33/+48
| | | | | | | | | Avoid calling next() or count() when the buffer is null. This avoids the risk of type errors. Also improve some comments. Change-Id: Ida422f4b7f185ac8bffc479ab5c82711e5621c89
* Merge "Replace substr with cleaner string methods"jenkins-bot2023-06-061-1/+1
|\
| * Replace substr with cleaner string methodsMatěj Suchánek2023-05-201-1/+1
| | | | | | | | | | | | | | | | | | | | Use str_starts_with, str_ends_with or string offset where appropriate. This fixes a bug in MimeAnalyzer where the "UTF-16LE" header could not be identified because of wrong constant. This is the exact type of bug that the new functions can avoid. Change-Id: I9f30881e7e895f011db29cf5dcbe43bc4f341062
* | filebackend: Remove unneeded array_filterUmherirrender2023-06-031-2/+0
|/ | | | | | Since 208ebda there are never nulls in the array Change-Id: I8299777689a6fb16c719ebf3c2bbc454255c0a37
* filebackend: Use SwiftFileBackend::$RES_ABSENT for self-documentationUmherirrender2023-05-111-18/+10
| | | | | | Collapse conditions when other types of the return value already checked Change-Id: Iff7273495a58c8505b5f3aaf132964bdde2a63bb
* filebackend: Split missing file and error on getLocalReference/CopyUmherirrender2023-04-292-17/+14
| | | | | | | | | | | FileBackend::getLocalReference and FileBackend::getLocalCopy should report failure and missing with different values to make error reporting for the caller easier (FileBackendStore::doConcatenate in this case). The existing subclass implementation for FileBackendStore::doGetLocalCopyMulti already doing that. Change-Id: Ie29aed48dc33bcd9fe1ed1e91685596044dfd988
* filebackend: Find thumbnails from all backends in FileBackendMultiWriteAmir Sarabadani2023-04-172-1/+24
| | | | | | | | When trying to purge thumbnails, currently it tries to purge from the main backend only leading to unhappiness Bug: T331138 Change-Id: I2b13912296df68b2833b8c7c0bfe17d4ba362fce
* TempFSFile: Keep the WeakMap aliveTim Starling2023-03-181-11/+9
| | | | | | | | | | | | | | | | If you store a WeakMap in the object, containing only circular references in the values, then nothing is keeping the WeakMap alive and it can be deleted along with its parent TempFSFile by the garbage collector. A WeakMap contains normal references to its values, so those normal references can be marked by the GC like any other references. Instead, store the WeakMap as a static property. Bug: T332461 Bug: T332397 Change-Id: Idbaa1019c2bac3d1dd9b001753c2f4c0aaf66e98
* TempFSFile: Use a WeakMap for reference tracking if availableMáté Szabó2023-02-121-4/+23
| | | | | | | | | | | | | Use a WeakMap to track references to TempFSFile instances if available to avoid deprecation warnings for dynamic property creation on PHP 8.2. Use an anonymous class rather than an stdClass to test the behavior in TempFSFileTestTrait to verify that bind() does not trigger dynamic property creation on PHP 8.2. Also add a Phan stub for WeakMap for PHP 7.4. Bug: T324894 Change-Id: Ic413c115e9ed1c750e175152094f3309628e777a
* Remove unused local variable assignmentUmherirrender2023-02-041-1/+1
| | | | | | Dead code found by phan Change-Id: I9fc404d546a4fb1c61394cb6359eb774fd94383a
* Merge "File backend: Fix "Notice: Undefined index: latest""jenkins-bot2023-01-181-1/+1
|\
| * File backend: Fix "Notice: Undefined index: latest"Paladox2023-01-171-1/+1
| | | | | | | | | | | | | | | | | | | | When using the copyFileBackend script to copy from an fs based backend to a swift backend, I'm getting "Undefined index: latest". Fix this by using `!empty( $stat['latest'] )`, which checks if the index is set. Change-Id: I7b8331b9537483f7674030985a217210b39626c5
* | Make use of ??= in more placesDannyS7122022-12-171-6/+4
| | | | | | | | | | | | New feature from PHP 7.4 Change-Id: Ifa7a9bc7b2ec415ad7ecb23f4c1776f51f58fd6b
* | Remove unused variable from unpacking arraysUmherirrender2022-11-221-15/+15
| | | | | | | | Change-Id: Iac27cb4aa936cb494b3e491ce22c88c7fad375a1
* | Fix the remaining Phan failures on PHP 8.1Tim Starling2022-11-091-1/+3
|/ | | | | | | | * Use @phan-var to suppress issues with version independence. * In Parser strictly compare to false. I still think this is a Phan bug. Bug: T322278 Change-Id: I654b73e5ed843474ed35c3780d95b04dce388bea
* Merge "Use short array destructuring instead of list()"jenkins-bot2022-10-219-72/+72
|\
| * Use short array destructuring instead of list()Tim Starling2022-10-219-72/+72
| | | | | | | | | | | | | | | | Introduced in PHP 7.1. Because it's shorter and looks nice. I used regex replacement. Change-Id: I0555e199d126cd44501f859cb4589f8bd49694da
* | Use the null coalescing assignment operatorTim Starling2022-10-212-8/+8
|/ | | | | | | | Available since PHP 7.4. Automated search, manual replacement. Change-Id: Ibb163141526e799bff08cfeb4037b52144bb39fa
* Fix MediaWiki.WhiteSpace.EmptyLinesBetweenUse.FoundReedy2022-10-081-2/+1
| | | | Change-Id: I8d4f6f0580748391abadcf096e6d0da45a1c390e
* Remove unused local variablesUmherirrender2022-09-191-1/+0
| | | | | | | Various variables are left from ealier refactor are now unused and can be removed to make the code easier to read Change-Id: Id51770af1f08e85c7e7a02234a2cd2ab5b47ee7a
* tests: Minor follow-up to MySQLPlatformTest/FileBackendTest php8.1 fixesTimo Tijhof2022-07-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Follows I3ea6fb26296f (MySQLPlatformTest): * Avoid uncertainty and make the code improvable/removable by explaining what the suppression is for. * Remove use of outdated AtEase, which hasn't been used in core tests for several months (ref phpcs.xml), and more generally not in new code in core or extensions (ref T253461). Follows I12c17e327628 (FileBackendTest): * I was going to similarly explain the reason by stating from the linked task that it is for preg_match, and I was goingn to move the wholesale suppression to just the getMockForAbstractClass() call that constructs the FileBackend and thus triggers the issue. * Instead, I've fixed the constructor to not pass a string there in the first place as all non-string values are naturally invalid. Even if there is a way to satisfy the regex with a non-string value that casts to a valid string, that'd be an invalid value for a FileBackend name as it pubicly documented as requiring a string, and internally also stored and typed as assumed to be (after validation) a string. * Change the valid test cases to be more representative of actually intended-to-be-valid input, and actually-likely-attempted-but-invalid input. The regex permits `[a-zA-Z0-9-_]` yet no numbers, capitals or dashes were validated by the test, and no special characters rejected by the test. This follows If29780653 (c250d07bac) from 2019 which added these test cases to improve code coverage without input from any (admitedly, non-existent) active maintainers. Bug: T313663 Change-Id: Ia326e17231a53c7102dcb116817a0c3830c510e4
* filebackend,jobqueue: Add signature for FilterIterator::accept()Mark A. Hershberger2022-07-061-1/+1
| | | | | | | | MappedIterator is primarily used by JobQueue. Bug: T307304 Bug: T289879 Change-Id: Idf8ea28d4b6dc4b9d16cf86d3e5f236ad5ee64ae
* FileBackend::isStoragePath() Handle being passed nullReedy2022-06-291-2/+2
| | | | | Bug: T311569 Change-Id: Iece1f1d6cc0671f6fa44e1c996b747406b6f6038
* Get rid of warnings on PHP 8.1Aryeh Gregor2022-06-135-9/+12
| | | | | | | | | | | This is mostly about adding return types to methods that implement PHP interfaces, and not passing null to core functions that want a string. After this patch, and an update to return types in RemexHtml, tests/phpunit/integration/ has no more errors than in PHP 8.0. Bug: T289879 Bug: T289926 Change-Id: Ia424f5cc897070f4188ae126b5bf6a1f552db0e1
* Fix many typos in commentsMatěj Suchánek2022-05-102-4/+4
| | | | | | Found using IntelliJ's "Typo" code inspection. Change-Id: I746220ebe6e1e39f6cb503390ec9053e6518cf16
* phan: Disable null_casts_as_any_type settingUmherirrender2022-03-211-1/+1
| | | | | | | | | | | Make phan stricter about null types by setting null_casts_as_any_type to false (the default in mediawiki-phan-config) Remaining false positive issues are suppressed. The suppression and the setting change can only be done together Bug: T242536 Bug: T301991 Change-Id: I0f295382b96fb3be8037a01c10487d9d591e7e01
* phan: Disable scalar_implicit_cast settingUmherirrender2022-03-181-0/+1
| | | | | | | | | Make phan stricter about scalar types by setting scalar_implicit_cast to false (the default in mediawiki-phan-config) Bug: T242536 Bug: T301991 Change-Id: Ia2fe30b17804186571722e728578121c8b75d455
* Merge "Fix various documentation related to null types (part II)"jenkins-bot2022-03-091-2/+2
|\
| * Fix various documentation related to null types (part II)Umherirrender2022-03-081-2/+2
| | | | | | | | | | | | | | | | | | The functions returning null or the class property is set explict null. Some function should not accept null or return null. Found by phan strict checks Change-Id: Ie50f23249282cdb18caa332f562a3945a58d86ff
* | Fix various documentation related to scalar typesUmherirrender2022-03-092-2/+2
| | | | | | | | | | | | Found by phan strict checks Change-Id: If41d16b473baddd92cc4261cdc2bfbe65fedcb19
* | filebackend: Check return value of FileBackend::normalizeStoragePathUmherirrender2022-03-051-1/+4
| | | | | | | | | | | | | | | | Avoid leaking a null value in the list of paths Found by phan strict checks Change-Id: Iffbd0a1d2cd05c9453fc7bca698095787f733f6c
* | Fix various documentation related to falseUmherirrender2022-03-031-1/+1
|/ | | | | | | | | Some function already document "False on failure", but does not document it on the used type Found by phan strict checks Change-Id: I12eb8bbc99179833ee3e42c1a7d1dc1443682ca6
* Add explicit casts between scalar typesUmherirrender2022-03-014-7/+7
| | | | | | | | | | | | | | | * Some functions accept only string, cast ints and floats to string * After preg_matches or explode() casts numbers to int to do maths * Cast unix timestamps to int to do maths * Cast return values from timestamp format function to int * Cast bitwise operator to bool when needed as bool * php internal functions like floor/round/ceil documented to return float, most cases the result is used as int, added casts Found by phan strict checks Change-Id: Icb2de32107f43817acc45fe296fb77acf65c1786
* Fix various documentation related to null typesUmherirrender2022-02-262-2/+2
| | | | | | | | The functions returning null or the class property is set explict null Found by phan strict checks Change-Id: I4a271093fb6526564d8083a08249c64cb21f2453
* Replace some more usages of Wikimedia\(suppress|restore)Warnings()Reedy2022-02-241-2/+3
| | | | Change-Id: I2eb133a9e32116cd155f59086245bc4d15ecbfcc
* Try not to discard Excimer timeout exceptionsTim Starling2022-02-022-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | Don't catch and discard exceptions from the RequestTimeout library, except when the exception is properly handled and the code seems to be trying to wrap things up. In most cases the exception is rethrown. Ideally it should instead be done by narrowing the catch, and this was feasible in a few cases. But sometimes the exception being caught is an instance of the base class (notably DateTime::__construct()). Often Exception is the root of the hierarchy of exceptions being thrown and so is the obvious catch-all. Notes on specific callers: * In the case of ResourceLoader::respond(), exceptions were caught for API correctness, but processing continued. I added an outer try block for timeout handling so that termination would be more prompt. * In LCStoreCDB the Exception being caught was Cdb\Exception not \Exception. I added an alias to avoid confusion. * In ImageGallery I added a special exception class. * In Message::__toString() the rationale for catching disappears in PHP 7.4.0+, so I added a PHP version check. * In PoolCounterRedis, let the shutdown function do its thing, but rethrow the exception for logging. Change-Id: I4c3770b9efc76a1ce42ed9f59329c36de04d657c
* Explicit cast TS_UNIX to int for arithmetic operations and int argsUmherirrender2022-01-111-1/+1
| | | | | | | | When the called function has a doc of int, it should be cast to be explicit here. Also cast for arithmetic operations to be explicit about the number Change-Id: I905b78dfb66e66443e0e3203488bab5b548db543
* Fix typos in comments (S)Siddharth VP2022-01-091-1/+1
| | | | Change-Id: Id86769ca81ff65707edde520585aa9ea117123e1
* Fix typos in comments (E-H)Siddharth VP2021-12-303-4/+4
| | | | Change-Id: I0748e0d5962fa909fdd6b7fcae4ab259bde4cdf1