aboutsummaryrefslogtreecommitdiffstats
path: root/includes/filerepo/file/LocalFileDeleteBatch.php
Commit message (Collapse)AuthorAgeFilesLines
* filerepo: Allow deletion of files with invalid img_major_mimeapasternak2024-02-061-1/+2
| | | | | | | Allow deletion of files where img_major_mime has a value not allowed by enum (0, ''). Bug: T355530 Change-Id: Ia731af30c32fd14adaf7571210c7703d6097aa54
* Migrate two simple cases to SQBAmir Sarabadani2023-11-131-7/+8
| | | | | Bug: T344971 Change-Id: Id3d1f354d5ae89c2daaa9dfcbef7803c5cf38c82
* Migrate another major batch to SelectQueryBuilderAmir Sarabadani2023-09-201-5/+5
| | | | | | | | I fixed some edge cases in the script that migrates to SQB and it managed to fix these now. Bug: T344971 Change-Id: I00cc9a6660d9bd4c64c976121b2121ccd7aae1f0
* In query builders, use insertInto() and deleteFrom() instead of insert() and ↵Tim Starling2023-09-081-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Merge "file: Check for old image existence in LocalFileDeleteBatch"jenkins-bot2023-08-281-0/+5
|\
| * file: Check for old image existence in LocalFileDeleteBatchUmherirrender2023-08-241-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some old files are lost and have oi_archive_name = '' in the database. In LocalFileDeleteBatch::removeNonexistentFiles a virtual url is created with the empty string at the end. That url points to a directory and not a file. The file backend response with a I/O error and the message backend-fail-internal is shown, there is no way to delete the whole file. Skip the lost files when collecting the hash as that results in ignore Preserve the empty archive_name on deletion/undeletion by distinct between NULL for current file and empty string for lost old files. Adjust api and special page a bit to not link broken file Bug: T244567 Change-Id: I40a0e80d4be5c5c76e7685ccf86bcb3aed3e114d
* | Reorg: Move Status to MediaWiki\Status\Amir Sarabadani2023-08-251-0/+1
| | | | | | | | | | | | | | | | | | | | 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
* | Merge "Mass migrate Database::insert calls to InsertQueryBuilder"jenkins-bot2023-08-081-1/+4
|\ \
| * | Mass migrate Database::insert calls to InsertQueryBuilderAmir Sarabadani2023-08-071-1/+4
| |/ | | | | | | | | | | | | Done automatically based on a php parser written on top of ANTLR4 Bug: T335377 Change-Id: Ie8fabc594edab18e55cb1d5bbf573762106e3d71
* / Introduce FileSelectQueryBuilderAmir Sarabadani2023-08-071-12/+7
|/ | | | | | | So much can be cleaned up with this Bug: T311866 Change-Id: Ia4d46679c540c731b2ae8da2f8022fd6f5b931a4
* Replace IDatabase::delete with DeleteQueryBuilderUmherirrender2023-06-211-4/+9
| | | | Change-Id: Ie0c1c955ca1a7028f75f24563fdeb9f94285af30
* Migrate Database::update() to UpdateQueryBuilderAmir Sarabadani2023-06-081-4/+8
| | | | | | | | I did this using a script written on top of antlr4 parser so it doesn't have some clean ups a human would do but it's pretty nice already. Bug: T330640 Change-Id: I608566700c6d737ee986bf47dda87effc69614d6
* Use short array destructuring instead of list()Tim Starling2022-10-211-3/+3
| | | | | | | | Introduced in PHP 7.1. Because it's shorter and looks nice. I used regex replacement. Change-Id: I0555e199d126cd44501f859cb4589f8bd49694da
* filerepo: Clean up file and class doc commentsTimo Tijhof2022-04-071-3/+2
| | | | | | | | | | | | | | | | * Remove copy-paste descriptions that are unrelated to the file. * Move any useful information from file block to class block. * Ensure any relevant `ingroup` is set on the class block. * Remove left-over ingroup and class description from file block, which pollutes the doc index for no gain. * Mark some obscure classes that have no references outside core in Codesearch Everywhere as internal. Change-Id: If2360596b4a7511db7439b4b9867b0600ce2d5f8
* Remove unused User::newFromAnyId from LocalFileDeleteBatchUmherirrender2021-12-071-1/+0
| | | | Change-Id: Ibb6a8b7ac0f14bceab52c37ad1de327c2e48bf94
* Revert "Remove last User dependencies from File"Majavah2021-11-261-0/+1
| | | | | | | | | This reverts commit 73a25838b461a952914190cb48eaaefee11d7659. Reason for revert: T296508 Bug: T296508 Change-Id: I8af37665eeb284b85157a72459d43261ec4829ed
* Remove last User dependencies from FilePetr Pchelko2021-11-261-1/+0
| | | | Change-Id: I953fcc66b5cde1ef481178b08e16c50b8a118702
* Use DeletePage in FileDeleteForm and fix output of ApiDeleteDaimona Eaytoy2021-11-181-19/+18
| | | | | | | | | | | | | | | | | | | | | | | | | - Use DeletePage in FileDeleteForm instead of WikiPage::doDeleteArticleReal - Properly handle scheduled deletions in FileDeleteForm: previously, a null status value could indicate a missing page OR a scheduled deletion, but the code always assumed the first, and it would generate a duplicated log entry. The API response would also not contain the "delete-scheduled" message. This has been broken since the introduction of scheduled deletion. - In ApiDelete, for file deletions, check whether the status is OK not good. The two might be equivalent, but this way it's more consistent. - Add some documentation for the Status objects returned by file-related methods. This is still incomplete, as there are many methods using Status and none of them says what the status could be. In particular, this means that for now we keep checking whether the status is OK instead of good, even though it's unclear what could produce a non-fatal error. - In LocalFileDeleteBatch, avoid using a class property for the returned status, as that's hard to follow. Instead, use a local variable and pass it around when needed. Bug: T288758 Change-Id: I22d60c05bdd4a3ea531e63dbb9e49efc36935137
* Stop using LocalFile::lock()Tim Starling2021-11-151-4/+17
| | | | | | | | | | | | | | | | | | | | LocalFile::lock() held an explicit DB transaction open while a potentially slow file backend operation was in progress, causing production errors. Instead, protect write operations with non-blocking locks. If a file is locked, report the failure to the user. Like an edit conflict, informing the user is appropriate in most cases. For example, if two admins try to delete the same file at the same time, only one should succeed, and the second does not need to wait for the first. In upgradeRow(), locks were used to protect operations which read from a file and write the result back to the database. The lock was supposed to prevent overwriting of fresh data with stale data. Use a timestamp check instead. Bug: T283045 Change-Id: Iaf9c9eef617044656b5b0d91a9632eacd84a5a78
* Replace getMasterDB methods with getPrimaryDBJames D. Forrester2021-07-141-4/+4
| | | | | Bug: T254646 Change-Id: I68198bc39b174ea1920b4acc2617cb6c6ce406e9
* Stop using legacy ActorMigration fields img_user/oi_user/fa_userTim Starling2021-04-261-3/+2
| | | | | Bug: T278917 Change-Id: If7dd7d2198bd79636fdfb8b5644fb7cd8ae2901f
* Replace some usages of User with Authority/UserIdentityPetr Pchelko2021-03-041-3/+4
| | | | Change-Id: I7dfbf9bbd1709f5e67de7f6680a5a5ad156994fa
* Make use of array deconstruction directly in foreach, if possibleThiemo Kreuz2020-11-121-3/+2
| | | | | | | | | | | Deconstructing non-sparse, numerically indexed arrays directly in foreach (a.k.a. using the list() syntax in foreach) is possible since PHP 5.5. The possibility to use string array keys as well as non-sequential numeric keys in array deconstruction was added in PHP 7.1. Change-Id: I56a48552a45f61cedc291b306cad8548fc70d485
* Remove support for LocalFileDeleteBatch creation without UserDannyS7122020-08-281-40/+7
| | | | | | | | Class isn't safe to create (@newable) and not providing a User is also explicitly hard deprecated. Bug: T247888 Change-Id: I9148c6af6a022c1c5192e971855a2b4120a110c3
* Introduce wfDeprecatedMsg()Tim Starling2020-06-221-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | Deprecating something means to say something nasty about it, or to draw its character into question. For example, "this function is lazy and good for nothing". Deprecatory remarks by a developer are generally taken as a warning that violence will soon be done against the function in question. Other developers are thus warned to avoid associating with the deprecated function. However, since wfDeprecated() was introduced, it has become obvious that the targets of deprecation are not limited to functions. Developers can deprecate literally anything: a parameter, a return value, a file format, Mondays, the concept of being, etc. wfDeprecated() requires every deprecatory statement to begin with "use of", leading to some awkward sentences. For example, one might say: "Use of your mouth to cough without it being covered by your arm is deprecated since 2020." So, introduce wfDeprecatedMsg(), which allows deprecation messages to be specified in plain text, with the caller description being optionally appended. Migrate incorrect or gramatically awkward uses of wfDeprecated() to wfDeprecatedMsg(). Change-Id: Ib3dd2fe37677d98425d0f3692db5c9e988943ae8
* Fix more Squiz.Scope.MethodScope.MissingReedy2020-05-181-1/+1
| | | | Change-Id: I44cd7ba39a898a27f0f66cf34238ab95370d2279
* LocalFileDeleteBatch: Migrate to new signature requiring a userDannyS7122020-03-171-6/+43
| | | | | | | | | | | | | | | | | Move the user parameter to be before the other optional parameters, and hard deprecate not passing a user. Interim signature is fully backwards compatible, emitting deprecation noticed when a user is not passed but otherwise accepting parameters in the old order as well as the old order, including handling of defaults. File::delete is a soft deprecated wrapper for the new File::deleteFile, and File::deleteOld is a hard deprecated wrapper for the new File::deleteOldFile. Both of the former methods accepted optional user parameters; both of the new methods require a user, so that the call to construct a LocalFileDeleteBatch can pass a user. Bug: T245710 Change-Id: I9cde7831e16a719c22f093f95248b8055d9ac6fd
* Add string casts when using array_keys() with SQL query conditionsBrad Jorsch2019-12-161-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | Until I70473280, integer literals were always quoted as strings, because the databases we support all have no problem with casting string-literals for comparisons and such. But it turned out that gave MySQL/MariaDB's planner problems in some queries, so we changed it to not quote actual PHP integers. But then we run into the fact that PHP associative arrays don't preserve the types of keys, it converts integer-like strings into actual integers. And when those are passed to the DB unquoted for comparison with a string-typed column, MySQL/MariaDB screws up the comparison while PostgreSQL simply throws an error. Sigh. This patch adds string casting to direct uses of array_keys() to supply values for such query conditions. It doesn't change uses where the field being compared is a numeric field. If anyone knows of a good way to find indirect uses of array_keys() for passing as $conds to IDatabase methods, please do so! Change-Id: Ie72ee33437d492904e1495b3f4ebb1fcf0118f49
* Set method visibility for various constructorsUmherirrender2019-12-031-1/+1
| | | | Change-Id: Id3c88257e866923b06e878ccdeddded7f08f2c98
* Fix new phan errors, part 2Daimona Eaytoy2019-10-121-1/+1
| | | | | | | Still mostly doc-only. Bug: T231636 Change-Id: I65cec6c716ce6859e14da00a12ef71e03603e59a
* phan: Disable enable_class_alias_supportUmherirrender2019-09-151-1/+1
| | | | | | It is enabled for b/c in extensions, but not needed in core Change-Id: I51dca12be9c77049f77563d9bf0edd07928c2300
* Mostly drop old pre-actor user schemasBrad Jorsch2019-09-091-34/+2
| | | | | | | | | | | | | | | | | | | | This removes most of the pre-actor user and user_text columns, and the $wgActorTableSchemaMigrationStage setting that used to determine whether the columns were used. rev_user and rev_user_text remain in the code, as on Wikimedia wikis the revision table is too large to alter at this time. A future change will combine that with the removal of rev_comment, rev_content_model, and rev_content_format (and the addition of rev_comment_id and rev_actor). ActorMigration's constructor continues to take a $stage parameter, and continues to have the logic for handling it, for the benefit of extensions that might need their own migration process. Code using ActorMigration for accessing the core fields should be updated to use the new actor fields directly. That will be done for in a followup. Bug: T188327 Change-Id: Id35544b879af1cd708f3efd303fce8d9a1b9eb02
* Avoid usage of deprecated Revision::* constants, use RevisionRecordDerick Alangi2019-07-211-1/+2
| | | | Change-Id: I872fc89e5c02dd6a3ae9cd7e76640b95dc33f514
* Simplify by using ?: operatorFomafix2019-04-151-6/+2
| | | | Change-Id: I2851cc51c9e05dd0599733be5af39e19f12b52e2
* Split LocalFile.php to have one class in one fileUmherirrender2019-04-141-0/+429
Change-Id: Ic8e5220f2a1832dfc39f00720001235429ed2cab