Commit graph

110 commits

Author SHA1 Message Date
Edward Chernenko
d88e924b6e Fix PHP warnings "preg_replace(): [...] invalid range in character class"
This was spotted when running tests on Travis (PHP 7.3 nighly, trusty).

Two expressions inside preg_replace() contained non-escaped "-" inside [],
where this "-" meant an actual "-" character.
The warning is because "-" has special meaning inside [] ("a-z" for range),
and things like [\w-.] are considered "invalid range".

Solution is to escape "-" like this: [\w\-.]

Change-Id: I41cc217081f00f54d957b6d8052ee209412f5ff6
2018-06-19 00:11:33 +00:00
Tim Starling
dc2948d76d A few doc comment fixups
* Remove some creation dates, they are not protected by GPL
* Remove duplicate @defgroup API
* Remove @ingroup from some @file doc comments on class files. It is not
  useful to list class files alongside classes in the doxygen module menu.
  Add @ingroup to some more class files that had @ingroup on their file,
  that was probably the author's intent.
* In PackedOverlayImageGallery, use the file comment as a class comment
* Don't put @defgroup and @file in the same comment. @defgroup makes the
  whole doc comment describe the group.
* Instead of putting AnsiTermColorer in two groups, use hierarchical
  groups.

Change-Id: If54f6e0b2bc1ea6de42045885cf836ee67b8e961
2017-12-04 11:11:52 +11:00
Reedy
c16af68fb6 Replace MimeMagic::singleton() calls
Change-Id: Ieed41b5d6b0f568fe2872e7754f2feae7868fe7a
2017-11-27 02:13:51 +00:00
Matthias Mullie
d33b721c4e i18n UploadStash exception messages
In some cases, the error messages have changed slightly, mostly because
of capitalisation & punctuation.
In a few other cases (mainly UploadStashNotLoggedInException), the content
has also slightly changed (removed mention of the __METHOD__ it occurred in)

Bug: T178291
Change-Id: I184067f2d7fe0a0a2df1114d2525fd9ab95b6c86
2017-11-06 12:55:00 +00:00
Cormac Parle
df1dd9b697 Rework Upload*Exception classes to implement ILocalizedException
Bug: T154781
Change-Id: Ia64295d7ea502014586b8b8e3e3f34272b72443c
2017-11-06 12:39:11 +00:00
Brad Jorsch
fa4a909def Replace more uses of "SELECT *"
With the introduction of CommentStore, selects from various table
require certain joins or column aliases for proper operation. The
upcoming actor table change, and the suggested title table change, will
add more such requirements.

Change-Id: Ic8213bff74b8350b15cd271d0ef252e63e7e79bd
2017-10-13 19:02:56 +00:00
Brad Jorsch
01a10dba5a Remove reference to deprecated IDatabase->nextSequenceValue()
The method was deprecated and made unnecessary in Ib308190c.

Change-Id: I1729ac0b3a88270a4c2f064187a2472112aaeb1e
2017-09-01 12:28:39 -04:00
Aaron Schulz
f525c72590 Rename getSlaveDB() FileRepo method to getReplicaDB()
The old name is left as an alias.

Change-Id: I60ab2cd5ce05df4247d5e25b017d2debee56554e
2016-11-18 07:42:39 -08:00
Aaron Schulz
ff5abb66b4 Migrate callers to new MWFileProps::getPropsFromPath() method
* FSFile should not be responsible for handling this much logic.
* Make more MediaHandler classes aware of the fact that an object
  other than File might be passed in. Use the FSFile instead of a
  useless empty stdClass object.
* Also added more fields to FSFile::placeholderProps to make it
  more complete.

Change-Id: I9fe764b2a7261af507c6555e6a57273cf7d00d36
2016-09-22 00:33:46 +00:00
jenkins-bot
c24cbb13df Merge "Revert "Clean up user handling in UploadStash"" 2016-09-11 00:35:32 +00:00
Bartosz Dziewoński
44947af94a Revert "Clean up user handling in UploadStash"
This reverts commit 58713d2b16.

Bug: T145228
Change-Id: Ic62f19109f98fab9dd029acccecd6518b649e34b
2016-09-10 15:27:49 +00:00
Aaron Schulz
950cf6016c Rename DB_SLAVE constant to DB_REPLICA
This is more consistent with LoadBalancer, modern, and inclusive
of master/master mysql, NDB cluster, and MariaDB galera cluster.

The old constant is an alias now.

Change-Id: I0b37299ecb439cc446ffbe8c341365d1eef45849
2016-09-05 22:55:53 -07:00
Chad Horohoe
58713d2b16 Clean up user handling in UploadStash
- User parameter is now *required*, remove $wgUser fallback
- We don't actually need the object after construction, don't store it

Change-Id: Id0cc859b70e5d0608ffbfa591bce6a1feb7cc3be
2016-09-02 17:40:49 +00:00
Reedy
b5656b6953 Many more function case mismatches
Change-Id: I5d3a5eb8adea1ecbf136415bb9fd7a162633ccca
2016-03-19 00:20:58 +00:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
Reedy
00c426e3c2 Replace wfBaseConvert with Wikimedia\base_convert
Change-Id: Iadab3d018c3559daf79be90edb23d131729bdb68
2015-11-24 22:51:42 +00:00
Brian Wolff
6d59689af5 In UploadStash, prioritize core metadata over file handler metadata
If us_props is too big for the database (> 64kb), don't store the
file handler metadata. This is usually by far the biggest portion
(For pdf/djvu it contains OCR data), and it's non-critical to the
upload process as it's only needed for display, and the file handler
will probably regenerate it anyway if it is missing.

At some point in the future, having data too big for a db field
is probably going to cause errors instead of silent truncation,
so we really don't want to be doing silent truncation.

An alternative way to solve T94562 might be to make it use us_sha1
instead of the one encoded in us_props, but seems like it's important
to fix us_props for other data in it too.

Bug: T94562
Change-Id: I8aed6a1a5c9a136090b36d4ad23d8429791f58c4
2015-10-25 12:19:32 -06:00
umherirrender
977c810302 Remove empty line comments
Remove empty line comments as found by the
MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.EmptyComment sniff

Change-Id: I5d694f7a7d3bc97e16300ba03c60ad17f3c912a5
2015-10-14 09:46:44 +02:00
Thiemo Mättig
56d2a644f7 Add null to @return tags if a method can return null
Change-Id: I420998351663d92c4a101f61842e40591eebcd5f
2015-10-05 17:53:13 +02:00
Ricordisamoa
4f72efe8d8 Remove excess newlines at the end of files
Many of them added with commit 776c865077

Change-Id: I481b15c45ead1f5f482e120cb40ea8f3297543cf
2015-09-27 00:02:05 +02:00
umherirrender
50b1cd2fbc Remove never thrown UploadStashNotAvailableException
Also move creation of UploadStash to main entry point of the special
page to avoid use of context before it is set (by called getUser).

Change-Id: Ibcb17b6ee1b853d807f91104ba428b307e9a5208
2015-03-25 19:29:49 +00:00
Mark Holmquist
7585e214d2 Add more detailed upload stash error messages
There are seven (used) error types in the stash class, and we umbrella'd
them all into one error message, which is mighty silly. This should give
us more information.

Also added to the mw.Api.errors list so UploadWizard can handle them.

Change-Id: I79bf0c29a4cef19363d111cc1128e35256ae572a
2014-10-27 19:41:25 +00:00
rillke
c31fbf073e Unify the spelling of MIME in documentation
Writing MIME as written in Wikipedia and some documentation clean up.

Change-Id: I9dfc36d2bf55d72d9374c4075bd6d45eef0415a4
2014-08-07 23:38:45 +02:00
umherirrender
768ac15c70 Cleanup some docs (includes/[s-z])
- Swap "$variable type" to "type $variable"
- Added missing types
- Fixed spacing inside docs
- Makes beginning of @param/@return/@var/@throws in capital
- Changed some types to match the more common spelling

Change-Id: Ie419638e909a47aa72a274043604247830ee1a81
2014-07-24 19:43:44 +02:00
Siebrand Mazeland
d185ec734a Pass phpcs-strict on includes/upload
Change-Id: I80eaa22398227a4edb7160d560b625102c7436ac
2014-05-10 10:25:54 +02:00
Siebrand Mazeland
69a2ecfe3e Update formatting of includes/upload/
Change-Id: I8cf59cd3bb6dd8de2ed6509b7bc2ef9ff7c5caf1
2014-05-09 16:53:19 +02:00
umherirrender
957adbef22 Fixed some @params documentation (includes/[file...|upload])
Swapped some "$var type" to "type $var" or added missing types
before the $var. Changed some other types to match the more common
spelling. Makes beginning of some text in captial.
Also added some missing @param.

Change-Id: I8804ebe0922d3a414863b162a2110e0b9e49b80f
2014-04-19 17:19:17 +02:00
umherirrender
725d9d125d Removed unneeded spaces and colons in @param and friends
Also swapped some "$var type" to "type $var" or added missing types
before the $var. Changed some other types to match the more common
spelling. Makes beginning of some text in captial.

Change-Id: Ic36c8c7820a6c2d603f1138130670c6bf6a1ca59
2014-04-08 16:02:49 +00:00
jenkins-bot
806df0771e Merge "UploadStash us_props fix for Postgres" 2014-02-21 14:40:14 +00:00
Aaron Schulz
0ef8100a25 UploadStash us_props fix for Postgres
* Follows up c7f4586fe1

Change-Id: I5a8568efaf0817ca743de722d5486457ff1a8d87
2014-02-19 13:28:26 -08:00
saper
c7f4586fe1 Add missing uploadstash.us_props for PostgreSQL
This field was introduced in e5d41cca90
but only for MySQL.

Change-Id: I057b1dd845a5ab7ae05f5597454981a6e2c12698
2013-12-09 20:46:17 +01:00
Brad Jorsch
d4b250ad38 UploadStash::removeFileNoAuth shouldn't need auth
UploadStash::getFile has a "noAuth" parameter, which should be set true
when this is called from UploadStash::removeFileNoAuth.

Callers should already be doing their own auth checking, or calling
UploadStash::removeFile.

Bug: 56298
Change-Id: Ic70c4e2bc6df5cb9b139a3631766f8ff0ec4ef02
2013-10-29 11:58:17 -04:00
Aaron Schulz
c61d48f87e Stop spamming exception log with random upload stash failures
* Things like authorization and validation problems do not belong in the
  exception log.

Change-Id: I3c4c1bab65cfe9111dc2161bda6d023234112900
2013-06-25 16:10:42 -07:00
csteipp
4233341283 SECURITY: Do checks on all upload types
Also, verify file before stashing it

Change-Id: Ib2474cb778d53959a4f479e53d0392f916b18d83
2013-05-21 13:20:06 -07:00
umherirrender
ee31d37821 Fixed spacing in context/installer/media/templates/upload folder
Added spaces before if, foreach
Added some braces for one line statements

Change-Id: I9761be9fa47adc3554852a97b19792b4648466ad
2013-04-21 06:22:06 +00:00
umherirrender
15abcf71ca Added/Removed spaces around string concatenation
And added/removed spaces around some other tokens,
like +, -, *, /, <, >, =, !

Fixed windows newline style

Change-Id: I0b9c8c408f3f6bfc0d685a074d7ec468fb848fc8
2013-04-13 13:36:24 +02:00
umherirrender
8764b3aa7c Remove spaces in function signature
Change-Id: I45aea7a7af88cd913b2f485913620a8af0ab2fed
2013-03-18 20:44:43 +01:00
Tyler Anthony Romeo
4dcc7961df Fixed @param tags to conform with Doxygen format.
Doxygen expects parameter types to come before the
parameter name in @param tags. Used a quick regex
to switch everything around where possible. This
only fixes cases where a primitve variable (or a
primitive followed by other types) is the variable
type. Other cases will need to be fixed manually.

Change-Id: Ic59fd20856eb0489d70f3469a56ebce0efb3db13
2013-03-11 13:15:01 -04:00
umherirrender
d63121016d fix some spacing
Added/removed spaces around logical/arithmetic operator
Reduced multiple empty lines to one empty line
Removed wrong tabs before comments at end of line
Removed too many spaces in assigments

Change-Id: I2bba4e72f9b5f88c53324d7b70e6042f1aad8f6b
2013-03-07 17:53:21 +01:00
Brad Jorsch
8049aa3384 Fix UploadStash::removeFile() error
If nothing has called getFile() for a key before that key is passed to
removeFileNoAuth(), UploadStash will throw a fatal error when it tries to
remove the file from the filesystem because the UploadStashFile was
never created.

Change-Id: Idf0d2c53ce759b59836f34ff5aaad393b8c371c6
2013-02-26 15:27:30 -08:00
umherirrender
f97a3a4027 fix some spacing
Change-Id: I670a7baf3ba1e70d18346bb00938d518ba2063bd
2013-02-04 19:59:14 +00:00
Aaron Schulz
ba5e774de9 [Upload] Added async upload concatenation support.
* Clients can send the last chunk with 'async' to get an immediate
  response and then check the status of the upload by polling the API
  using the 'checkstatus' parameter.
* Pass the User object along to stash functions within UploadFromChunks.

Change-Id: Ie2ad4c7e94862a728e8a687c3195306e16a5059e
2012-12-05 09:39:31 -08:00
Aaron Schulz
e5d41cca90 [Upload] [Schema] Added us_props column to avoid expensive GETs.
* 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
2012-12-03 10:23:40 -08:00
Aaron Schulz
7ecf9ab87e Various simple optimizations for the chunked upload process.
* This adds an UnregisteredLocalFile::setLocalReference()
  function, which is used to avoid an extra GET request.
* This removes the useless rename() in stashFile(). We just
  need to make sure the stashed file has the right extension.
  Getting rid of the rename makes setLocalReference() usable.
* Also adds some debug logging with ellapsed time.

Change-Id: I087701ad0c27a4eba74591e6b49f5667b011424c
2012-11-18 12:40:30 -08:00
Antoine Musso
9362bb6c56 miscellaneous doxygen warnings
* @licence -> @license
* Protects inline HTML by using double quotes, our inline comments uses
  elements such as <h1> or <firstnameLastname@gmail.com>
* Commands in lowercase (@TODO -> @todo, @NOTE -> @note)
* removes @abstract and @static since doxygen detects them from PHP
  code.
* various undocumented function parameters
* typos in parameters declarations

Change-Id: I62ad6fc124c355bf31acc780b9614a59cf79a421
2012-10-22 14:00:08 +02:00
Siebrand Mazeland
d4b046a893 Update docs for return and exception info
* Removed some inline tabs in the process.
* IDE fixed some incorrect leading spaces, too.

Change-Id: Ic9303eff6db4424ac3f1fa2816839692b43e6190
2012-10-09 09:41:58 +00:00
Aaron Schulz
7cfc4f818e Removed useless begin()/commit() calls as DBO_TRX is not on in cli mode.
Change-Id: Icb80c26b64ace1f36871c6a9c772aaf1dfa6a111
2012-09-24 20:00:09 -07:00
Reedy
be32e26699 Fix strict error in UploadStashFile
Strict standards: Declaration of UploadStashFile::thumbName() should be compatible with that of File::thumbName() in /var/www/wiki/mediawiki/core/includes/upload/UploadStash.php on line 498

Call Stack:
    0.0004     645672   1. {main}() /var/www/wiki/mediawiki/core/index.php:0
    0.0756    5904264   2. MediaWiki->run() /var/www/wiki/mediawiki/core/index.php:59
    0.0756    5904264   3. MediaWiki->main() /var/www/wiki/mediawiki/core/includes/Wiki.php:446
    0.0797    6328272   4. MediaWiki->performRequest() /var/www/wiki/mediawiki/core/includes/Wiki.php:536
    0.0960    7042800   5. SpecialPageFactory::executePath() /var/www/wiki/mediawiki/core/includes/Wiki.php:290
    0.1041    8003528   6. SpecialPage->run() /var/www/wiki/mediawiki/core/includes/SpecialPageFactory.php:494
    0.1041    8003528   7. SpecialSpecialpages->execute() /var/www/wiki/mediawiki/core/includes/SpecialPage.php:611
    0.2082   17300016   8. SpecialSpecialpages->getPageGroups() /var/www/wiki/mediawiki/core/includes/specials/SpecialSpecialpages.php:42
    0.2083   17300016   9. SpecialPageFactory::getUsablePages() /var/www/wiki/mediawiki/core/includes/specials/SpecialSpecialpages.php:54
    0.4498   30176624  10. SpecialPageFactory::getPage() /var/www/wiki/mediawiki/core/includes/SpecialPageFactory.php:372
    0.4527   30373096  11. SpecialUploadStash->__construct() /var/www/wiki/mediawiki/core/includes/SpecialPageFactory.php:344
    0.4861   33604352  12. FileRepo->getUploadStash() /var/www/wiki/mediawiki/core/includes/specials/SpecialUploadStash.php:52
    0.4861   33604832  13. AutoLoader::autoload() /var/www/wiki/mediawiki/core/includes/AutoLoader.php:0
    0.4898   33952264  14. require('/var/www/wiki/mediawiki/core/includes/upload/UploadStash.php') /var/www/wiki/mediawiki/core/includes/AutoLoader.php:1150

Change-Id: Iee2aae16df804f42cbae9c21c870781a08ad3850
2012-09-16 18:18:27 +01:00
Alexandre Emsenhuber
c7870d2eae Pass the parameters to the error message in UploadStash::stashFile().
Currently it shows the error message without any parameters since
$error is an array with the message name and its parameters, and
the Message class thinks that this is a message with its fallbacks
(see wfMessageFallback())

Change-Id: I5d825144795ad108f0a71f90cc530629c5c98a41
2012-08-10 21:17:18 +02:00
Jan Gerber
c239df639b cleanup temp files left around by UploadStash
stashFile renames files to add an extension, this way it is no longer
cleaned up by php. So we have to unlink it after storing it in the FileRepo.

Change-Id: Iab697fc4535546dd25231dddf220e18f3b0b73be
2012-07-20 01:18:31 +00:00