aboutsummaryrefslogtreecommitdiffstats
path: root/includes/upload/UploadFromStash.php
Commit message (Collapse)AuthorAgeFilesLines
* Namespace all remaining files in includes/filerepoJames D. Forrester2025-03-191-0/+1
| | | | | Bug: T353458 Change-Id: I35864ad9bd48701703c51367d62f8ebde963c52d
* Use explicit nullable type on parameter argumentsUmherirrender2024-10-161-1/+1
| | | | | | | | | | | 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
* upload: Add missing documentation to class propertiesUmherirrender2024-09-041-0/+3
| | | | | | | | | | 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: I07ce1f37d1bfb18d6e73dd008a712b3ca60a80e9
* Make verifyPartialFile reuse SHA1 hash if we already knowBrian Wolff2024-03-021-2/+8
| | | | | | | | | | | | During a stashed upload, the SHA1 has already been calculated and is populated based on data saved in DB. Reuse that value in verifyPartialFile() instead of recalculating as SHA1 can take a long time to calculate for large files. This should improve the speed of PublishStashedFile jobs. Bug: T200820 Change-Id: Ie2967c636b2f942921a125ef62d1a466c6035ca0
* Reorg: Move WebRequest to includes\RequestAmir Sarabadani2023-09-111-0/+1
| | | | | | | This has been approved as part of RFC T166010 Bug: T321882 Change-Id: I6bbdbbe6ea48cc1f50bc568bb8780fc7c5361a6f
* Various doc fixes about false and null on method arguments/return typesUmherirrender2022-11-031-2/+2
| | | | | | Doc-only changes Change-Id: Ice974b3ba41708859dfe646e94b31c5ebbf26410
* Revert "Reorg: Move some of request related classes to MediaWiki/Request"Zabe2022-10-271-1/+0
| | | | | | | | | This reverts commit 2bdc0b2b7209441a42a784157633a8a01b321922. Reason for revert: T166010#8349431 Bug: T166010 Change-Id: Idcd3025647aec99532f5d69b9c1718c531761283
* Reorg: Move some of request related classes to MediaWiki/RequestAmir Sarabadani2022-10-261-0/+1
| | | | | | | | | | | | | Moving: - DerivativeRequest - FauxRequest - FauxRequestUpload - PathRouter - WebRequest - WebRequestUpload Bug: T166010 Change-Id: I5ea70120d745f2876ae31d039f3f8a51e49e9ad8
* build: Update mediawiki/mediawiki-phan-config to 0.12.0Daimona Eaytoy2022-10-081-1/+0
| | | | | | | | This patch only adds and removes suppressions, which must be done in the same patch as the version bump. Bug: T298571 Change-Id: I4044d4d9ce82b3dae7ba0af85bf04f22cb1dd347
* build: Update mediawiki/mediawiki-phan-config to 0.11.0Umherirrender2021-09-071-0/+1
| | | | | | | Addition and remove of suppression needs to be done with the version update. Change-Id: I3288b3cefa744b507eadebb67b8ab08c86517c1c
* UploadFromStash: convert default user from false to nullPetr Pchelko2021-05-191-2/+2
| | | | | Bug: T283196 Change-Id: I4096d60d5a6e5988794ced6a5607edafab20c116
* Upload: convert b/c cases to UserIdentityPetr Pchelko2021-05-131-1/+2
| | | | Change-Id: Ie36c4695c8a7f9986f3f25eaf0464afbe408d808
* Improve class property documentationUmherirrender2020-10-301-2/+2
| | | | | | Reformat existing documentation to match the format Change-Id: I190b54b5e962f17bab6502dd1b3c02f11dc926d2
* Remove terminating line breaks from debug messagesTim Starling2020-06-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | A terminating line break has not been required in wfDebug() since 2014, however no migration was done. Some of these line breaks found their way into LoggerInterface::debug() calls, where they mess up the formatting of the debug log. So, remove terminating line breaks from wfDebug() and LoggerInterface::debug() calls. Also: * Fix the stripping of leading line breaks from the log header emitted by Setup.php. This feature, accidentally broken in 2014, allows requests to be distinguished in the log file. * Avoid using the global variable $self. * Move the logging of the client IP back to Setup.php. It was moved to WebRequest in the hopes that it would not always be needed, however $wgRequest->getIP() is now called unconditionally a few lines up in Setup.php. This means that it is put in its proper place after the "start request" message. * Wrap the log header code in a closure so that variables like $name do not leak into global scope. * In Linker.php, remove a few instances of an unnecessary second parameter to wfDebug(). Change-Id: I96651d3044a95b9d210b51cb8368edc76bebbb9e
* Use MediaWikiServices::getRepoGroup in file related classesUmherirrender2020-03-141-1/+3
| | | | Change-Id: Iceec961de4f0cc689f7d3b981afac923b46c98f6
* Simplify some code by changing single-scope properties to local variablesDaimona Eaytoy2019-09-071-5/+2
| | | | | | When they're not used outside of the scope where they're defined. Change-Id: I5ca1de8420c1180bf7f5d9f28f2a7402a256adf8
* Add missing & to @param documentation to match functon callUmherirrender2017-08-111-1/+1
| | | | Change-Id: I81e68310abcbc59964b22e0e74842d509f6b1fb9
* Remove pointless override of doStashFile in UploadFromStashAaron Schulz2016-08-171-18/+0
| | | | Change-Id: If6bc31d7398c68320a6633b045c33279bf6f8dbd
* Introduce UploadStashFile hook, improve API handling of stash errorsBartosz Dziewoński2016-08-091-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | UploadBase: * Introduce a new method, tryStashFile(), as a replacement for the now-soft-deprecated stashFile(). The method runs the new hook and returns a Status object, with an error (if the hook returned an error) or a value (if it didn't). * Introduce a new hook, UploadStashFile, allowing extensions to prevent a file from being stashed. Note that code in extensions which has not been updated for MediaWiki 1.28 may still call stashFile() directly, and therefore not call this hook. For important checks (not just for UI), extension authors should use UploadVerifyFile or UploadVerifyUpload hooks. * Extract common code of tryStashFile() and stashFile() to a new protected method doStashFile(). SpecialUpload: * Use tryStashFile() when stashing a file after a warning or "recoverable error" was encountered. ApiUpload: * Refactor stashing code so that error handling only happens in one place, not four different ones. Use Status objects rather than exception throwing/catching for control flow. * Simplify the error messages slightly (error codes are unchanged). Produce better ones by always using handleStashException(). 'stashfailed' is now always at root (not nested inside 'warnings'), behaving the same as 'filekey' does on success. * Use tryStashFile() when stashing. Handle errors so as to allow custom API results passed via ApiMessage to be preserved. Some API result changes for different requests are shown below. api.php?action=upload&format=json&filename=good.png&file=...&stash=1 Before: { "error": { "code": "stashfilestorage", "info": "Could not store upload in the stash: Stashing temporary file failed: UploadStashFileException Error storing file in '/tmp/phpB32SRT': Could not create directory \"mwstore://local-backend/local-temp/3/3a\".", "*": "See http://localhost:3080/w/api.php for API usage" } } After: { "error": { "code": "stashfilestorage", "info": "Could not store upload in the stash: Error storing file in '/tmp/phpB32SRT': Could not create directory \"mwstore://local-backend/local-temp/3/3a\".", "*": "See http://localhost:3080/w/api.php for API usage" } } api.php?action=upload&format=json&filename=[bad].png&file=... Before: { "upload": { "result": "Warning", "warnings": { "badfilename": "-bad-.png", "stashfailed": "Stashing temporary file failed: UploadStashFileException Error storing file in '/tmp/phpB32SRT': Could not create directory \"mwstore://local-backend/local-temp/3/3a\"." } } } After: { "upload": { "result": "Warning", "stashfailed": "Could not store upload in the stash: Error storing file in '/tmp/phpB32SRT': Could not create directory \"mwstore://local-backend/local-temp/3/3a\"." "warnings": { "badfilename": "-bad-.png", } } } Bug: T140521 Change-Id: I2f574b355cd33b2e9fa7ff8e1793503b257cce65
* UploadBase: Formally deprecate old methods for stashing filesBartosz Dziewoński2016-08-031-8/+0
| | | | Change-Id: I4c60083a4e773e401aae8c90b99a051cbca4c961
* UploadFromStash: Only remove stashed file on successful uploadsBartosz Dziewoński2016-01-211-10/+3
| | | | | | Also, makes code shorter! Change-Id: I144d8a207c753bd9e38ac847a0fc61257f11e54d
* Fix issues identified by SpaceBeforeSingleLineComment sniffVivek Ghaisas2015-09-261-1/+1
| | | | Change-Id: I048ccb1fa260e4b7152ca5f09b053defdd72d8f9
* Update formatting of includes/upload/Siebrand Mazeland2014-05-091-0/+2
| | | | Change-Id: I8cf59cd3bb6dd8de2ed6509b7bc2ef9ff7c5caf1
* Update docs and declare visibility on class propsSiebrand Mazeland2013-11-011-19/+25
| | | | Change-Id: Ib0f02202d075d4a56dc4e37b08d7ac9399e8c86c
* SECURITY: Do checks on all upload typescsteipp2013-05-211-7/+2
| | | | | | Also, verify file before stashing it Change-Id: Ib2474cb778d53959a4f479e53d0392f916b18d83
* Fixed spacing in context/installer/media/templates/upload folderumherirrender2013-04-211-3/+3
| | | | | | | Added spaces before if, foreach Added some braces for one line statements Change-Id: I9761be9fa47adc3554852a97b19792b4648466ad
* Make UploadBase::getTempFileSha1Base36 publicMarius Hoch2013-02-281-1/+1
| | | | | | | There's no obvious reason for this method to be private while it's pretty handy to have it in hooks. Change-Id: If716665a939e8fe84288354ee8c16369604b67fb
* Added async upload-from-stash support.Aaron Schulz2013-01-091-2/+10
| | | | | | * This works similarly to the async concatenation code. Change-Id: Iae38b93d65182158561b92168af51a1e9f50374c
* Fix method declaration in UploadFromStashumherirrender2012-12-071-2/+3
| | | | | | | | 1) UploadStashTest::testValidRequest Declaration of UploadFromStash::stashFile() should be compatible with that of UploadBase::stashFile() Change-Id: If94ab8b718e23b50a1b67ba0fac3ea24926d5950
* [Upload] [Schema] Added us_props column to avoid expensive GETs.Aaron Schulz2012-12-031-1/+1
| | | | | | | * We already compute the props when stashing, so including that in a column lets us reuse it later when the stashed file is to be published. Change-Id: I3d6adb6528f1e992d8986058806e745c4e1c0300
* Minor bits of documentation updates to upload codeReedy2012-08-091-2/+0
| | | | | | Including hint for bug 39195 Change-Id: I4cdab97011330c12a943112f6c05134362d26a82
* Big oops - merged to wrong branch.awjrichards2012-06-051-0/+22
| | | | | Revert "Revert to arbitrarily old point before initial remote branch creation to help clean up" This reverts commit ee0d3d330f76b97c451c168dc9b052ee84609b5b
* Revert to arbitrarily old point before initial remote branch creation to ↵awjrichards2012-06-021-22/+0
| | | | | | help clean up Change-Id: I41a3d1e55d3ea9dffa42451237fe065f9334361d
* Added missing GPLv2 headers in some places.Alexandre Emsenhuber2012-05-291-0/+22
| | | | | | Also made file/class documentation more consistent. Change-Id: Ia1a7230adc92079b505362317d2e03b36130cc8b
* Can't return values from functions that don't return anythingReedy2012-04-191-1/+1
| | | | Change-Id: If964ce2f39904f1e9e3101e7cafaa6a96d58adfc
* Fixing some of the "@return true" or "@return false", need to be "@return ↵Sam Reed2012-02-091-1/+1
| | | | | | | | | bool" and then the metadata can say true if foo, false if bar Other documentation improvements Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/111072
* Fix doc for includes/uploadAntoine Musso2012-02-081-3/+1
| | | | Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/110943
* Use database to track uploaded chunks and concatenate at the end.Jan Gerber2011-11-301-36/+0
| | | | | | | | | | with i18n documentation dont break phpunit follow up r93720 Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/104687
* Revert r104659 and its followup r104665: break the unit tests with a fatal ↵Roan Kattouw2011-11-301-0/+36
| | | | | | | error. This cripples our CI system, we can't detect new failures this way. Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/104680
* Use database to track uploaded chunks and concatenate at the end.Jan Gerber2011-11-301-36/+0
| | | | | | | | follow up r93720 Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/104659
* Few bits of documentationSam Reed2011-10-161-1/+5
| | | | Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/99975
* Update some deprecated codeSam Reed2011-10-141-9/+32
| | | | | | | | | | | Documentation Fix "/*" comments to "/**" Flesh out some missing returns, change some return types Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/99808
* UploadFromStash::stashSession returned an object instead of a file key, ↵Ian Baker2011-08-261-2/+2
| | | | | | | | | which broke stashing in SpecialUpload in some cases. Fixes bug 30505 Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/95581
* Two bugs:Ian Baker2011-08-181-6/+11
| | | | | | | | 1. When the user isn't passed to UploadFromStash::__construct(), it would break when it shouldn't. 2. When stashing files, sometimes an instance of UnregisteredLocalFile would be returned instead of UploadStashFile Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/94966
* Cleaning up little things, updates to code clarity, documentation fixes per ↵Ian Baker2011-08-161-1/+1
| | | | | | | | | Catrope's suggestions. followup to r94536, r94592, r94594 Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/94670
* Removed the ability to pass a key into stashFile(), which simplifies the ↵Ian Baker2011-08-151-4/+4
| | | | | | | | | | stash row creation a great deal. Updated UploadFromUrlJob to properly use the database stash followup to r92200 Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/94594
* checking for existence of mLocalFile in stashFile() was invertedIan Baker2011-08-151-1/+1
| | | | | | | followup to r94536 Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/94540
* Fixed incorrect usage of || operator, added testIan Baker2011-08-151-8/+11
| | | | | | | | | removed spurious use of empty() listFiles() was broken, now works followup to r92009 Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/94536
* Extend upload api adding an option to upload files in chunks,Jan Gerber2011-08-021-1/+33
| | | | | | | | using UploadStash to track the unfinished upload. Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/93720
* properly handle the case where a file disappears during the uploadwizard processIan Baker2011-07-141-4/+13
| | | | | | | remove database records for files that move out of the stash Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/92213