Commit graph

308 commits

Author SHA1 Message Date
jenkins-bot
6389f3fb53 Merge "Make it possible to tag new file uploads without messy queries" 2016-01-25 21:00:13 +00:00
Bartosz Dziewoński
61c7852049 Make it possible to tag new file uploads without messy queries
UploadBase::performUpload() now takes a $tags parameter and passes it
to LocalFile::upload() and LocalFile::recordUpload2(), which
eventually adds the requested tags to the log_id, rev_id and rc_id
that are created for the file upload.

Previously you'd have to query the database for the latest rev_id and
log_id for the page title under which the title is being uploaded, as
performUpload() is unable to return them to you because it's all
deferred in funny ways.

Bug: T121874
Change-Id: I99a8fd67c84219d2715d3d88cc21500614431179
2016-01-25 20:06:53 +01:00
Bartosz Dziewoński
e09772cc56 LocalFile: Ensure same timestamp for log entry and image revision
For file patrolling, we rely on the timestamp of image revision
(`image` table) and log entry (`logging` table) being the same, but we
weren't actually making sure it is the same.

Note that the timestamp of page revision can still differ, but that
shouldn't matter and it's a more involved fix.

Change-Id: I8e1b75d744c4a96cb0bb636b153d6e8ea2ee1fcf
2016-01-24 21:31:34 +01:00
victorbarbu
df622c4195 Provide short URL to file description page in imageinfo API
Bug: T122439
Change-Id: I0f00b986e6095bdb9b8d6af6fbc5b01995227e02
2016-01-12 15:48:52 +02:00
Bartosz Dziewoński
f66ff60244 LogEntry: Make associated rev id persistent (store in logging and log_search)
The implementation from 0160b410bd only
stored the associated rev id in the `recentchanges` table, which was
sufficient for its purpose of allowing patrol of these log entries and
provided some change tagging improvements, but ephemeral.

Now we also store it in `logging` and `log_search` tables, which makes
it possible to find a revision for the log entry and vice versa.

* For `log_search` we just add a row with 'associated_rev_id' as key,
  it was designed for exactly this purpose.
* For `logging` we store it in log_params field in ManualLogEntry, and
  transparently remove it from there when building a DatabaseLogEntry.

Bug: T122089
Change-Id: I559587ff77b3c94b31a6c5951287b6f9c1e167ce
2016-01-07 02:19:51 +00:00
cenarium
c53f647658 Allow patrol of uploads
This allows to patrol file uploads, both new files and new file
versions, from the description page, provided $wgUseFilePatrol
is set to true. Special:NewFiles can be filtered to hide patrolled
files.

Bug: T11501
Change-Id: If71af58719a4461f12d125455b7bef07164525ca
2016-01-06 14:57:22 -08:00
Aaron Schulz
6af3c39c07 Replace "squid" with "CDN" in various comments
Change-Id: Idcc528daf28e119349155d36e30a9bcf61b2e7d5
2015-12-09 17:35:37 -08:00
Aaron Schulz
282c5fa9f3 Rename SquidUpdate => CdnCacheUpdate
Squid is not the only possible CDN

Change-Id: Ie2a2955847c5706e630322bbbab71c9d063b378f
2015-12-09 16:31:17 -08:00
Aaron Schulz
afbff42aca Make CDN purge calls use DeferredUpdates
* Using addUpdate() makes sure purges are coalesced and
  de-duplicated.
* Also removed incosistent $wgUseSquid checks. If CDN caching
  is not used, then $wgSquidServers will just be empty anyway.

Bug: T119016
Change-Id: I8b448366f037f668385d252f9d68289b71d1a707
2015-12-04 19:09:03 +00:00
Aaron Schulz
bbc8f40575 Move down $logEntry publish() call in recordUpload2()
This was moved before the defered doEditContent() call
for new pages by mistake.

Bug: T118433
Change-Id: I007acf82622ec6d68c007921f632793392025f40
2015-11-11 19:36:16 -08:00
Aaron Schulz
8c1d27c1d7 Remove spammy wfDebug() from LocalFile::loadFromCache()
Change-Id: I36ad31f197ec8f71c97e6a8673ac5ca979f8d9ab
2015-11-11 13:36:53 -08:00
Aaron Schulz
a62f165013 Always defer the log publish() in recordUpload2
This is more performant and simplifies the code a bit.

Change-Id: I7a30e000ae4eff47519b83eb6bdde57eeb8a18f6
2015-11-06 16:15:34 -08:00
Aaron Schulz
8e1f6d5506 Convert recordUpload2() to using startAtomic/endAtomic
* This avoids breaking transactions due to nesting
* Also improve readability a bit in this area

Change-Id: I81c41e83d14aa59930bfb99522ebcc25d8aa14f9
2015-11-05 18:33:38 +00:00
jenkins-bot
d9d5cbc8fc Merge "Remove begin/commit from recordUpload2()" 2015-10-07 02:31:39 +00:00
Aaron Schulz
d9725ffe16 Remove begin/commit from recordUpload2()
Use deferred updates and transaction hooks
to get the cache updates after the publish()
DB updates instead

Change-Id: I0a922182f7dd5f22c1e661171b0df1a49a637aef
2015-10-06 12:02:11 -07:00
Aaron Schulz
54758dd160 Change getCacheSetOptions() callers to use "Database"
* This is less verbose that DatabaseBase
* Also add a few WAN cache doc comments

Change-Id: I5b6de6d0ffa06753ea96c50b63db7dae796475dc
2015-10-05 22:06:46 -07:00
jenkins-bot
4f7d15021d Merge "Make WANObjectCache sets account for slave lag" 2015-10-06 00:11:22 +00:00
jenkins-bot
6571a887e0 Merge "Cleanups to MigrateFileRepoLayout" 2015-10-05 23:50:38 +00:00
Aaron Schulz
db0b9ef264 Make WANObjectCache sets account for slave lag
* This gets lag information that is useful when
  the calling code is about to run queries that
  will have their results cached.
* This is now used in place of trxTimestamp() for
  WANObjectCache set() and getWithSetCallback().
* The WAN cache will use a low TTL if the lag is
  too high to avoid caching stale data for weeks.
* Bumped MAX_COMMIT_DELAY as nothing enforces it.

Bug: T113204
Change-Id: I2a95b4088cff42d6e980351555f81a4b13519e24
2015-10-05 16:45:13 -07:00
Aaron Schulz
0f7893f877 Update various @params from DatabaseBase to IDatabase
Change-Id: I98e44cdffb0fc0d729f69f702799139afb988c20
2015-10-05 05:24:29 +00:00
Aaron Schulz
b4ff14f730 Cleanups to MigrateFileRepoLayout
* Use "bypassReadOnly" as other file backend maintenance
  scripts do.  One may want to run this while site traffic
  is off via $wgReadOnly.
* Fixed handling for when img_sha1 is not set.
* Fixed some IDEA errors.

Change-Id: I95c426c5f2082576fc9ea40282d2869750a9f3d8
2015-10-04 21:45:25 -07:00
Aaron Schulz
75f06d5294 Added $opts to WANObjectCache::set() to detect snapshot lag
* This can avoid some stale write race conditions
* Made use of this option in a few key places
* HOLDOFF_TTL was also bumped

Change-Id: I83505a59cce0119e456191c3100f7d97bc86bdbf
2015-09-28 23:03:36 +00:00
Siebrand Mazeland
cc1285a708 Fix 3 PHPCS warnings in includes/filerepo/
Change-Id: I00ea32f3a0666d225096d6c45710d0de67e2fe14
2015-09-28 13:29:33 +02:00
Aaron Schulz
d02b98b8f3 Updated key WANObjectCache::delete() callers to avoid races
* They now issue the delete() write before COMMIT of
  the relevant DB (or immediately if no trx is active)
* This can avoid some stale write race conditions
* Updated the WAN cache delete() docs

Change-Id: Id54887976051120b76528070d5f2ceb357d57897
2015-09-26 18:02:00 +00:00
jeroendedauw
eb347efa1f Fix type hint in unprefixRow
Change-Id: Iba80cadfdb06b3f9b3f5a6e1d367260405bea1d0
2015-09-24 19:16:27 +02:00
Tim Starling
b4b64c82c8 In LocalFile normalize integer fields to integers
File::getWidth() etc. should return an integer not a numeric string.

Bug: T111089
Change-Id: Ic767fb6cf3db0be9810b7bfa369c209ec05a6e58
2015-09-07 06:50:35 +00:00
Aaron Schulz
f1e1313a16 Support for storing files under SHA-1 names
* Added a "storageLayout" flag to LocalRepo config (supports "sha1")
* Added a simple migration script to copy files the SHA1 paths
* Currently works with img_auth.php + thumb_handler.php for URLs
* Added visibility to some LocalFile methods
* Simple tests for the wrapper class.

Co-Authored-By: Gilles Dubuc <gdubuc@wikimedia.org>
Change-Id: Iad46ad669c8ae3c02d10da10c3f7a16fe161663f
Bug: T1210
2015-07-21 16:19:22 +02:00
Ori Livneh
b31e567b78 hierarchicalize(!) stat names
Graphite expects name components to be dot-separated, so our habit of using
dashes doesn't really make sense. Change metric names to be more compatible
with Graphite, except the job queue's, since that will require a gdash
dashboard definition migration.

Change-Id: I77d0ff7606a8fc88434e4352d23415a9a8f4725a
2015-06-03 16:27:13 -07:00
Aaron Schulz
1404c6ca2d Avoid calling load() in LocalFile::invalidateCache; not needed
Change-Id: I1e2d61722a18e4046bdf7c375ea9c1dbbea4a157
2015-05-21 18:49:02 +00:00
Timo Tijhof
19bff2537e Consistently name the $this callback variable "$that"
Most are already, but some had differnet names. In PHP 5.4+ this is
redundant as they inherit automatically, but we need these for PHP 5.3
compatibility. Settle on "$that" to make these easier to find.

Change-Id: I0b68b2c550fde9c2da53d844421e34b8df0c42ed
2015-05-13 23:05:07 +01:00
Aaron Schulz
1f954a10cd Fixed variable collision in LocalFile::saveToCache()
Bug: T98754
Change-Id: I656b0c415e1b7ec64ee6c15d9a91ebc427663009
2015-05-11 10:20:25 -07:00
jenkins-bot
fac57b4b96 Merge "Converted LocalFile to using the WAN cache" 2015-05-11 16:21:20 +00:00
Aaron Schulz
429a22cd08 Converted LocalFile to using the WAN cache
Bug: T93141
Change-Id: Iecb182428ae0d8e7511bc28340b57f6e7042b723
2015-05-08 11:52:33 -07:00
Brad Jorsch
a90cbb48f8 Cast various things that are supposed to be ints
Mysqli is returning SELECTed ints as strings rather than as ints, I'm
guessing to avoid problems with 64-bit int types on 32-bit systems. PHP
mostly doesn't care, but it causes API JSON output to have strings
instead of ints all over the place.

This also fixes ForeignAPIFile::getUser( 'id' ) returning the user
*name*.

Bug: T98276
Change-Id: Ie6591d72b3ac40172f8176a8ca8b6fad8e9275a5
2015-05-06 11:40:41 -04:00
Aaron Schulz
c518eaf0e0 Removed LocalFile::purgeHistory method
* This just purges an unused key as OldLocalFile::getCacheKey
  simply returns false (rather than a key with "oldfile" in it)

Change-Id: Ic7dda9bf192803a75eaa9bd3bb5a145ad1409dd2
2015-04-27 17:36:02 -07:00
Gergő Tisza
00e925fe92 Force LocalFile::purgeMetadataCache use the master DB
This used to happen automatically via markVolatile() but that was
removed in I808c3a6, which caused cache updates after move/delete
to retain outdated information from slaves.

Bug: T93009
Bug: T88506
Change-Id: Ie4a6c5fbecec9b38ad3ff45fbc22c5d74d66601c
2015-03-18 17:56:11 +00:00
Kunal Mehta
b1d1a7f51a Fix phpcs errors and warnings in includes/filerepo
Change-Id: I8a2b437f9f393baf4ee6546d654d56845fcdd1b6
2015-03-15 02:34:41 +00:00
Aaron Schulz
7782dee83b Remove isVolatile/markVolatile logic from LocalFile
* This is obsoleted by the "latest" flag
* Follows-up 5085a4b

Bug: T88506 
Change-Id: I808c3a6f0edb3466cb600c06c5e742ab030baf14
2015-03-06 21:12:39 +00:00
Aaron Schulz
7508b86ad3 Made the "bypassCache" flag for file locator methods use the master DB
* Added a File::load() stub method
* Cleaned up the File loading flags bitfield a bit

bug: T89184
Change-Id: I1aa4b096c0cad5f5ca34321cc897019005c53a76
2015-03-04 17:02:05 -08:00
Gergő Tisza
bf40d6267c Add File::getDescriptionTouched() method
Fetch page_touched timestamp of file description page via a DB query
(possibly to a foreign DB).

Not sure about the performance implications; could add a memcached
layer on top, but the same DB lookup was already done for local
files.

Bug: T88648
Change-Id: I891c806aab235ff2c0e73c98b06b64fbe78e1517
2015-02-14 00:49:26 +00:00
Ricordisamoa
2ae155da52 Fix phpcs errors in includes/
Mostly Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines

Change-Id: I678b2f0902f11cd1dfa1611b9da24e7237df9122
2015-01-08 20:15:07 +01:00
Aaron Schulz
4ff8136807 Removed remaining profile calls
Change-Id: I31c81c78715048004fc8fca0f27d09c1fa71c118
2015-01-08 02:49:33 -08:00
Chad Horohoe
aa21e125a3 Remove obvious function-level profiling
Xhprof generates this data now. Custom profiling of various
sub-function units are kept.

Calls to profiler represented about 3% of page execution
time on Special:BlankPage (1.5% in/out); after this change
it's down to about 0.98% of page execution time.

Change-Id: Id9a1dc9d8f80bbd52e42226b724a1e1213d07af7
2015-01-07 11:14:24 -08:00
umherirrender
d2a0367914 Use content language for edit summary on upload overwrite
The edit summary for the null revision on upload overwrite was in the
user language and not in content language

Possible a regression from Idf281898d8a5a023a0b9ce3bc90b3ca55c1a6376

Bug: T72293
Change-Id: Ie70a3874e170b3849e91265e0c9c61da838f2d20
2014-12-28 14:42:14 +01:00
jenkins-bot
8eb1344fba Merge "Removed some unnecessary code in LocalFileDeleteBatch" 2014-12-12 21:18:30 +00:00
Ricordisamoa
fc5fd5c37a Typo fixes and non-code tweaks
Skipped replacements:
* prefered → preferred
* prolly → probably

Skipped files:
* resources/lib/jquery.ui/jquery.ui.mouse.js
* resources/lib/jquery/jquery.form.js

Change-Id: Ib7923f362ddfca1b892bf5d601785d6b5aa5d44c
2014-12-12 18:31:15 +00:00
Aaron Schulz
e369f66d00 Replace wfRunHooks calls with direct Hooks::run calls
* This avoids the overhead of an extra function call

Change-Id: I8ee996f237fd111873ab51965bded3d91e61e4dd
2014-12-10 12:26:59 -08:00
Aaron Schulz
4269e65ff9 Removed some unnecessary code in LocalFileDeleteBatch
Change-Id: I4d03d03fada5c299779b7fb7e998285568672a6c
2014-11-27 12:50:41 -08:00
Aaron Schulz
17cc78767a Switch to LOCK IN SHARE MODE in recordUpload2()
* We just need the latest data; the advisory locking in lock()
  already manages mutual exclusion.

Change-Id: I9af7a892b2dcafd30149332b0084f61d117c9cad
2014-10-29 06:59:51 +00:00
Aaron Schulz
745637c3da Reduced LocalFileRestoreBatch::execute deadlocks when doing batch restores
* Often users restore a batch of many files with similar names.
  This fails due to gap locking on non-existing rows which tangles up
  unrelated actions. Avoid that locking for the common case.
* This changes the return value of LocalFile::lock() from a useless
  one (due to the exception) to one that conveys some useful information.
  The method is fairly internal in any case.

Change-Id: Idb86367cf45b731d4b2a67b1813a660bc0e7a84f
2014-10-17 04:07:54 +00:00
Aaron Schulz
a578bd195b Made LocalFileMoveBatch::addOlds use SH locks instead of EX ones
Change-Id: I928f98deded6e71b4b1e63167ca8b565e39c6394
2014-10-09 22:50:26 +00:00
jenkins-bot
396927c0b6 Merge "Made LocalFile move/delete/restore handle network partitions better" 2014-08-21 15:38:10 +00:00
umherirrender
3b2b6a2773 Add missing @param to function docs
Change-Id: I47fa96a976f55a1a93cb75397285edb8c7f4cd8a
2014-08-14 20:22:52 +02:00
Aaron Schulz
8dca7488ec Made LocalFile move/delete/restore handle network partitions better
* Previously, the file existence checks would not distinguish an answer
  in the negative from a non-answer. This was a long-standing problem.
  This avoids moving DB entries without moving the files (unless the
  partition happens in the middle of the moves of course).
* Optimized fileExistsBatch() to do concurrent stats if possible.

bug: 40927
bug: 69312
Change-Id: I9132fd5591bb7a3d5852f17514dcf51a3d8b7812
2014-08-14 17:26:57 +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
b883e8c7c0 Cleanup some docs (includes/[e-l])
- 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: I41a84e8e1dec39170aa655250325ffc485eaeaef
2014-07-24 19:43:03 +02:00
umherirrender
d5d37cd034 Add missing rollback to LocalFile::recordUpload2
When begin was called, all returns should have rollback called to
close the transaction.

Change-Id: I8197f73fb45c2e2900db6d5e588623f9b0c46ea5
2014-07-17 10:41:18 +02:00
Aaron Schulz
c87c9c14da Added missing unlock() calls in LocalFile
Change-Id: Id427fb424bfb46670f2074664aca750014c70225
2014-07-16 17:14:23 -07:00
jenkins-bot
6f38f78cdd Merge "Fixed possible race condition in LocalFileMoveBatch" 2014-05-22 04:56:48 +00:00
Aaron Schulz
fc6d99cb20 Tweaked timestamp kludge logic in recordUpload2
* This now only does the SELECT FOR UPDATE for the re-upload case

Change-Id: I21b1b0328b6dbfb30f4f0293212515b9ee081778
2014-05-20 14:51:16 -07:00
Aaron Schulz
399198c28e Replace FOR UPDATE with LockManager use in LocalFile::lock()
* This avoids excess contention where inserts of rows for
  similarly named files get blocked. This often would effect
  users of UploadWizard or any bot doing mass uploads.

Change-Id: Ie7a328f7d4f03aa249770804417347a50356ea42
2014-05-20 14:22:52 -07:00
Aaron Schulz
51c173912a Fixed possible race condition in LocalFileMoveBatch
* If a move is blocked by a re-upload and the TRX started outside of
  LocalFile::lock, then the move did not see the new row in the oldimage
  table and so it will not move that version of the file in storage. Use
  the latest DB data to avoid that.

Change-Id: I7ec46941170293c96b99a449cb396517108e8b3d
2014-05-19 15:18:05 -07:00
Aaron Schulz
582fd02fb9 Use FOR UPDATE in prior LocalFile timestamp check
* This covers the case with a snapshotted transaction outside of lock()/unlock()

Change-Id: I8639c2e51cb918f452dc1576681d6224fb4fb2c0
2014-05-14 09:43:02 -07:00
Aaron Schulz
605329976f Made LocalFile avoid duplicate (name,timestamp) pairs
* Various bits of code seem to assume uniqueness already

bug: 65264
Change-Id: Ib00fdbe87a79296c640cd69d74928236ce7a4aee
2014-05-13 15:03:32 -07:00
Siebrand Mazeland
4b8523198f Make phpcs-strict pass on includes/ (4/~10)
Change-Id: I2767205a7059adfb8fa090a82abd332e518f2590
2014-05-11 19:35:09 +00:00
umherirrender
2d11016ecd Pass $user to LocalFileDeleteBatch
This avoids the use of $wgUser

Change-Id: I60cab27e0708a818c77791cc89194b6dd726da0b
2014-05-06 21:31:29 +02:00
Jeff
8c62609dc8 PostgreSQL: decode image.img_metadata
The img_metadata field was not being decoded from bytea into text.

This change to core fixes the reported problem with PdfHandler against
1.22.6, origin/REL1_23 and git head.

Bug: 59147
Change-Id: I285a317a57a29713af1f7f630b340278bd5400da
2014-05-05 16:02:55 -07:00
umherirrender
3cca294d75 Avoid raw sql in LocalFileDeleteBatch::doDBInserts
Use Database::conditional instead of raw sql.

Change-Id: Ic00146e9ec582a263b9dec117b12532fdc24789e
2014-05-05 21:28:32 +02:00
Aaron Schulz
250b23aa01 Removed commented-out migrateThumbFile() code
Change-Id: Ic52d3a8d93808b365c3f06fef9e51d65efcd1d57
2014-04-30 00:30:37 -07:00
umherirrender
26e705f808 Add $user param to Revision::newNullRevision
This avoids the use of $wgUser in Revision constructor and makes the
dependency on the global visible.

Change-Id: Ib67bd706a3c4ef081f475406e9aa1094c42222ef
2014-04-28 18:59:20 +02:00
Ori Livneh
776d0900b9 Simplify LocalFile::isVolatile
Make the logic a bit easier to follow. Follow-up to I99a39c3d2.

Change-Id: I9b815d7f0d229ef25db5b7f48f6e49ca4dac046e
2014-04-24 15:57:09 -07:00
jenkins-bot
7b8af70f26 Merge "Made LocalFile::loadExtraFromDB() handle re-upload race conditions" 2014-04-24 22:17:51 +00:00
Aaron Schulz
3eced85d60 Made LocalFile::loadExtraFromDB() handle re-upload race conditions
Change-Id: I99a39c3d2b5d7a227be9b11a2f23c534ea4739d9
2014-04-24 15:05:12 -07:00
Siebrand Mazeland
f994817f6b Pass phpcs-strict on various files in includes/
These files have all had treatment before, and these occurrences have either
been missed or have been introduced after.

Change-Id: I06cdab4616b5bff47c85152df28f18c861730a23
2014-04-24 21:50:01 +02:00
Aaron Schulz
bb0651087f Use slave DB connections for LocalFile cache misses
* Previously LocalFile cache misses would hit the master DB
  (even for shared repos like Commons).
* Since lock() is always called before file changes, this has
  been modified to call a new markVolatile() method to track
  changing (or recently changed) files in memcached. On cache
  miss this tracking is used to decide whether to use the
  slave or the master DB.

Change-Id: I942f5e28dd9e0953b6382cc2247ca480494d5718
2014-04-24 05:55:21 +00:00
Aaron Schulz
2354da0538 Fixed slow query in LocalFileDeleteBatch::getHashes()
* All the old files will have the oi_name of the $file

bug: 62360
Change-Id: Ie3aeee44a7ec1ef4cad0c0fcde9b7d0dba003da2
2014-04-21 22:58:42 -07:00
jenkins-bot
10de9847fb Merge "Avoid image table updates on file upload failure" 2014-04-21 16:54:19 +00: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
Aaron Schulz
17480be012 Avoid image table updates on file upload failure
* If the publish() call did not really do anything, then there is
  no use in saving the page and file DB records. Previously the
  user would get an error but the description page would be made.

bug: 64071
Change-Id: I1959f8c1ef33dbd1b238f6020117d2862d4b0fd3
2014-04-18 12:36:20 -07:00
umherirrender
1e64c2d0c9 Avoid using raw sql in LocalFile.php
Now the IN-List is created by the database abstraction layer.

Change-Id: I08d309eb4aad830ad6141cbfbe16447eb2674f52
2014-04-09 17:35:20 +02:00
Brian Wolff
ceb5abb7e0 When uploading a new file, save to memcached directly after commit
Previously if an exception was thrown when creating the description
page, the old (negative) memcached entry would not be purged, and
the file would appear not to exist until 24 hours later.

This way, as soon as we have the image row committed to db, we
change the memcache entry, so memcache of image row always looks
like actual image row.

Bug: 32551
Change-Id: I9c260e9a4a1e0d6ade1771542dd834f969904cef
2014-04-06 02:30:22 +00:00
Aaron Schulz
3cc06f6d8c Speed up LocalFile locking behavior
* Lowered the lock() timeout
* Wrap the destination DB write with memcached locks for move
  ops since it is easier to control that lock timeout than the
  DB lock timeouts.
* Cleanup locks in the destructor (e.g. on exceptions). Other
  process can pile up more if locks have to expire.

bug: 63058
Change-Id: I38b28d81ec96daa80ece2354db284a614289ba0b
2014-04-01 09:27:38 +00:00
Prod
fe019f8568 Execute LocalFilePurgeThumbnails hook before purging thumbnails
bug: 62273
Change-Id: I08ae902debb36039d2c0be829eec07a109e70a24
2014-03-12 22:10:57 -04:00
Siebrand Mazeland
f077c4b1d6 Update formatting
Change-Id: I18aff576262479c9bb1c56eb8e1d1aaae200e4b1
2014-02-06 09:27:05 +01:00
Brad Jorsch
a2120b0bd0 Make imagelinks work like templatelinks
Due to bug 17259 (which is fixed in a better way in Id44d566a),
imagelinks only records the redirect and not the actual image used when
an image redirect is referenced. This causes various problems, such as
cascading protection not working through image redirects.

It makes more sense for imagelinks to work like tempaltelinks, recording
both so that things like cascading protection don't have to care about
image redirects explicitly.

Comparing imagelinks to templatelinks also reveals a few places
(WikiPage::doDeleteUpdates, WikiPage::doCascadeProtectionUpdates) that
should be triggering a LinksUpdate if the image links changed.

Bug: 23002
Bug: 23542
Bug: 26503
Change-Id: I64fe7d25646cae2c8213211893c6f821f3504dbf
2014-01-07 23:13:43 +00:00
Siebrand Mazeland
7b1642d1b5 Change line breaks in LocalFile::recordUpload2()
Change-Id: Ib27e381106d048bb0a24286a877c85f0e62408cf
2013-12-05 23:32:50 +01:00
Siebrand Mazeland
43605121f8 Satisfy code analyzer by ensuring $urls is defined
Change-Id: I0f399edfca51c8949f0d0ce02c7a84f0890db92f
2013-12-04 22:30:00 +00:00
Siebrand Mazeland
417d4fbbfa Update documentation for file repo related classes
Change-Id: I626d972f92934afc9349e11d3a5550c4044dcb53
2013-12-04 23:06:53 +01:00
jenkins-bot
0a54e70cdd Merge "Set visibility on class properties in LocalFile.php" 2013-12-04 09:20:19 +00:00
Siebrand Mazeland
aab1a070d2 Set visibility on class properties in LocalFile.php
Change-Id: Ibab58651bb147433bd99046013e11f8c773bef70
2013-12-04 10:10:33 +01:00
Aaron Schulz
3775237e78 Avoid calling oldFileFromRowFactory field directly
Change-Id: Ibbd5a8baa27015eec443349a67edc57ede5d174d
2013-12-02 10:47:24 -08:00
Siebrand Mazeland
f742b27dd3 Break long lines in file repo files
Change-Id: I6d95c1b3e14a947a92127efa681007baaeab89ba
2013-11-23 21:17:08 +00:00
Siebrand Mazeland
bb39b5a6e4 Update formatting of file repo classes
Change-Id: I780070e07352d84d7cda7628994b28b04e8a1ebf
2013-11-23 21:00:11 +01:00
umherirrender
5dbfd5bf80 Fixed spacing
- Removed trailing spaces in comments
- Removed multiple empty lines
- Removed space after object operator

Change-Id: I9fd3256ab490c7cd2034de3fd94e6be6e6d6d8f2
2013-11-21 18:52:25 +00:00
umherirrender
f153998317 Fixed spacing
- Removed double spaces
- Added space after if/switch/foreach
- Removed space on elseif
- Added space around parentheses
- Added newline at end of file
- Removed space before semicolon at end of line

Change-Id: Id40b87e04786c6111e6686d7f7eea1e588bdf37d
2013-11-19 19:03:54 +01:00
Aaron Schulz
bbadd9b3df Reduce excess lock contention and chance for failure on rename
* DB locks and transactions were getting held up by sometimes slow purges (10+ seconds)

Change-Id: I0eead60e8faf5aee6b2ddf59cfdd928f9c8083ff
2013-10-18 20:16:21 +00:00
Erich Lerch
1cb9da7a14 Escape backslashes in image metadata
Uploading a file with backslashes in the metadata
causes database exception on PostgreSQL, because
backslashes are sent to the 'bytea' datatype unencoded.

Bug: 52017
Change-Id: Ife56cffe3df83ec1a7bd39cdc4a0489f23354494
2013-10-16 01:09:27 +02:00
Aaron Schulz
53b361e52c Fixed silly unlock bug in LocalFile
* Removed the lock instead of just purging some cache data

bug: 54978
Change-Id: Ida007c28e07b0fe1803ab8ed027bc2ec4f55af19
2013-10-04 16:06:35 +00:00
Aaron Schulz
2cd16b8a4e Make sure LocalFile::lock() works for brand new uploads
bug: 54736
Change-Id: I10f950939d34ff5917d168ef1d905c86e2cfc075
2013-10-01 23:53:11 +00:00
Aaron Schulz
64e9b88abf Hide filebackend listing exceptions for thumbnail purges
bug: 54674
Change-Id: I20db9004fc8b5509f7731b1e678efc6f0aed6cdb
2013-09-27 11:37:02 -07:00
jenkins-bot
ee1eb85b61 Merge "Add option to chose what language to fetch file description in." 2013-09-25 15:51:13 +00:00
Brian Wolff
bd7ebdec65 Add option to chose what language to fetch file description in.
I want to get the file description in a language other then
the user language in an extension (I5e6bc45f9751).

Change-Id: Ifcae821a51f4207e7816e710d3b3857c7ed438b6
2013-09-24 20:19:33 -03:00
Bryan Davis
176e012fe3 Guard against non-object returns from File::getHander()
MediaHandler::getHandler() can return false when a handler cannot be
determined for the given file's derived mime type. This change adds
guards to invocations that I could find that did not properly check for
this potential return result.

Bug: 53820
Change-Id: I8c0165311cc75f9920ac30ce2b38ccd207439198
2013-09-17 06:48:43 +00:00
Aaron Schulz
c312218534 Move slow deletion purges out of complex DB transactions
* This should help reduce deletion related deadlock errors

Change-Id: Ie7cafbf87ab0c71cc6c4c4fe1e53af364974a745
2013-08-21 13:22:05 -07:00
Bryan Davis
ede015209d Purge upstream caches when deleting file assets.
Inform upstream caches when a file asset is deleted by calling
SquidUpdate::purge(). This helps prevent unintentional information leakage in
the event that the asset is being deleted for reasons of license or content.

Bug: 51064
Change-Id: Ibf57e8f32d7dd04b8508a69706be5a40b49e5abd
2013-08-19 18:11:44 +00:00
Brian Wolff
5239b2db2d Don't purge thumbs for old versions of an image during ?action=purge
This tends to become extremely expensive as the number of
oldversions of a file increase. It is also not generally
needed since ?action=purge is usually targeting the
current version (additionally old versions of the file
have fixed urls, so they're less likely to get out
of sync). If an old version does need to be purged, one
can revdel and un-revdel it.

It should be noted that this extra purging was added
for bug 30192. However, since that bug was fixed,
most of the places requiring purging of old thumbnails
have now done it directly instead of by relying on
$file->purgeCache. The exception being revision
deletion, which still assumes $file->purgeCache clears
the thumbnails of old versions of the file.

There's no real bug for this, but I kind of hijacked
bug 49362

Change-Id: Ib399132cabe79fd2b4b23bad5708bfa50b282074
2013-07-09 23:13:07 +00:00
Brian Wolff
f8d0f0a780 Fix getPageDimensions failure handling
getPageDimensions returning false for failure wasn't being handled
properly, causing ugly output. The doc comment on that method was
wrong as well.

Most notably causing random whitespace output:
https://commons.wikimedia.org/wiki/?curid=22151015
(screenshot: http://i.imgur.com/c21EpVx.png).

Bug: 41281
Change-Id: I1a49474309e15808928f877dfc29ae366d028928
2013-06-27 00:02:30 +02:00
Brian Wolff
c25bf70238 Make rc_cur_id have proper value for upload log entries.
Primary motivation here is to make Special:Recentchangelinked work
correctly for uploads where the description page doesn't exist yet.
(Previously it was mostly only showing reupload log entries)

Mild downside to this approach is adding the recentchanges row is
now in a different commit...

Change-Id: I74c68b972c47c03066d3065e3748769a27a654fb
2013-06-17 21:35:47 -03:00
Brian Wolff
10d877dfe8 RefreshLinks on imagelinks on new uploads to kill tracking cat.
When someone uploads a new file, we should refresh all the pages
that use that image, so that [[Category:Pages with broken file links]]
gets removed.

Future fixme would to run this again on file deletes, but that's
less critical as they will eventually get added on next reparse
and people don't expect that to happen instantly like when fixing
the issue. Ditto for someone creating a new file redirect.

Bug: 46749
Change-Id: I7889598eee54a1c07c64f750b8499e922ba59704
2013-06-05 11:01:22 -03:00
Aaron Schulz
619a3f3b85 Fixed bug in LocalFile::isCacheable().
* The metadata field is actually defaulting to "" not null.

Change-Id: I745441c7061494db26de7f64dda30b80171c9443
2013-05-14 11:45:34 -07:00
Aaron Schulz
e42c4b82f5 Fixed LocalFile::isCacheable() to account for object type metadata.
Change-Id: I8104201c84ea008446df587650a098f6732b8d39
2013-05-14 11:06:35 -07:00
Brian Wolff
8c328d030f Add identifying info (img_timestamp and img_sha1) to upload log.
I came across people complaining that it was hard to associate
upload log events to actual images since img_timestamp could
be different from log_timestamp, and generally no unique id.

Well I was there I made uploads use the new logging system.

Change-Id: Icd8662ecb9eb0f6c0ff9841bdbd5736d6dd0d015
2013-05-10 21:10:49 +00:00
Aaron Schulz
042baf43bd Fix bug in OOM avoidance for RepoGroup cache.
Change-Id: Ic2e7fb6a9a7207315fd65454d883b84278efafc0
2013-04-23 17:22:30 -07:00
umherirrender
1bfc8feb25 Fixed spacing in actions/cache/filebackend/filerepo/job folder
Added spaces before if, foreach
Added some braces for one line statements

Change-Id: Idb93d34e314e5f314223b79208968d6bcd30c40e
2013-04-20 19:18:13 +02: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
978bb31c5e Add missing wfProfileOut before throwing an exception
Change-Id: I1d830da0597f19efd0b2ae48642389975e736e23
2013-04-08 18:37:24 +00:00
Alexandre Emsenhuber
df5265e14d Fix case of some Title methods
Change-Id: I37ce7fe392f4941c500fa0a88007664501d7e338
2013-03-27 14:36:05 +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
Reedy
c3e4057e06 Kill off numerous unused variables
Change-Id: I7039f1328f37ee669b694f73ee282602186bffd1
2013-03-08 02:36:24 +00: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
umherirrender
678f2da99d Pass user to File::recordUpload to avoid $wgUser
Moves the giving of a user one level up, because File::recordUpload2
already needs this (and fallback to $wgUser).
Can also use the user for the watching of the file, which was using
$wgUser before.

Change-Id: I697ae0df65b07ea59ab11b62804853cdc03cb172
2013-02-23 12:46:28 +00:00
Aaron Schulz
4c26684de5 [FileRepo] Changed LocalFile locking to avoid breaking transactions.
* Only BEGIN on lock() if no trx was in progress.
  Likewise, only COMMIT in unlock() if the lock() call started a trx.
* This can avoid problems with commiting page update transactions
  prematurely, which could leave broken page stub rows. (bug 40178)

Change-Id: I9a0adb25ee107df9a6bf70c6103ddfb7f034be25
2013-02-20 11:30:38 -08:00
Reedy
e028051140 Add a handful of missing @return
Change-Id: I21b218e6694600a2d2df4dd0a6b2b5cd2e10f1f9
2013-02-16 17:51:13 +01:00
IAlex
3f92a5672e Merge "remove space before semicolon" 2013-02-10 12:51:02 +00:00
umherirrender
f3cf109e62 remove space before semicolon
Change-Id: Ic0d890f5e27cec017c7f7910a67d53b2edf82079
2013-02-09 22:44:24 +01:00
umherirrender
180c74875b Add ArchivedFile::selectFields() and use it
Change-Id: Ia19d7bc1eb2bf77f1aca9d3891cebf57e45c030b
2013-02-09 15:59:13 +01:00
umherirrender
570dda0455 fix some spacing
Change-Id: I88e73d47a552918880514d88a876296a6cb80d88
2013-02-04 20:09:18 +00:00
Aaron Schulz
dcbdcf0781 [FileRepo] Lazy load large metadata from the DB.
* Previously, large values that could not fit into memcached would not be cached
  and the master DB would be hit for any file loading (djvu files hit this often).

Change-Id: I3ed8ad4a85d6e3084330b56c3b48ee76103bd2b8
2013-01-28 17:29:27 -08:00
Aaron Schulz
7cd5b25321 [FileRepo] Lowered negative caching duration.
Change-Id: I288ce2eef3cf547e254843c7f806925ee44391ca
2013-01-28 09:49:20 -08:00
umherirrender
7d2bf6aac1 Trim spaces on user supplied comments
This helps on bug 29575

Change-Id: Ic05e5898f8a7c93a95188c9342d22c70d7413b09
2013-01-20 14:08:38 +00:00
Jan Gerber
3aeed2d2dc Purge videos from squid on action=purge
While we don't want to re-encode videos on purge, they should still
be removed from squid; compute the list of all urls before extensions
can filter it to remove files that should not be deleted from the
file backend.

Change-Id: Id837843b5a203e49a8594439ce3620da9b3c7b6a
2012-12-06 11:58:14 -08:00
umherirrender
7cc01d56b2 Add some __METHOD__ to begin/commit/rollback calls
Change-Id: I20dad8d6bb7a523e8a6f50bc0af5cdba57d7160f
2012-12-01 15:04:10 +01:00
Platonides
84e1e6b5ae Removal of unused globals.
Change-Id: I870665d18f955a245222cfceca4665897277e7e4
2012-11-26 22:15:11 +01:00
Jan Gerber
8199d6121a Bug 42445: Fix file revert with local repo
reverting a file a virtual url is passed to upload without props,
get props from backend, virutal urls are not local files.

Change-Id: I1d56a6237e1d2af9941f29e4ba3f0262817b0e8d
2012-11-26 10:29:04 -08:00
Aaron Schulz
81ebc15b05 [FileRepo] [FileBackend] Added support for custom file headers.
* For backends that support it, custom HTTP headers can be set on files.
* Added a getStreamHeaders() function to MediaHandler to let subclasses
  recommend header name/value pairs to be used for responses to GET/HEAD
  requests. For example, an OGG handler could set "X-Content-Duration".
* Made LocalFile use this function to set HTTP headers of new uploads.

Change-Id: I1b017e1342513f0097fe6d142aae18e819403293
2012-11-20 14:07:02 -08:00
Aaron Schulz
9d58cb641c [FileRepo] Fixed purging for "short style" thumbnail names.
Change-Id: If63b4c609b7bc43cda658cb87abe59562b335c69
2012-10-29 11:09:43 -07:00
umherirrender
82375631c2 Fix tabs inside/between statements/text
This tabs are strange and a space there is better

Change-Id: I0885dff575ee2fcd0668d08fef3226e132c5b319
2012-10-26 18:18:59 +02:00
umherirrender
fb2c1c645b Add separate fa_sha1 field to filearchive table
This allows sha1 searches with the api in miser mode for deleted files

Added script to populate the rows
Adding new field to selects and handle it in all places, where needed

Using a 10 byte index for the new field per
http://lists.wikimedia.org/pipermail/wikitech-l/2012-September/063429.html

Change-Id: Ie54a513fe361202e63df44be44a0fdd91926c974
2012-10-14 20:58:25 +02:00
daniel
c546fae8ed merge latest master into Wikidata branch
Change-Id: Id4e0f40c03679c13d8934a6add99b5cd86d0437d
2012-10-08 13:58:54 +02:00
Max Semenik
f000f14555 Add 2 new options to importImages.php
--timestamp overrides upload timestamp
--summary sets upload summary

Change-Id: I930c8b1ce55af0543a41f412ecf702715c82c6df
2012-09-27 00:16:17 +04:00
daniel
12166f46b4 merged master (2012-09-11)
Change-Id: I8e953eaa22f9d331b0af5e780fbeff6d702b23e3
2012-09-11 11:43:02 +02:00
daniel
8322771ec3 Fix transaction nesting caused by LocalFile.
The transaction bracket in LocalFile::recordUpload2 used to span a call
to WikiPage::doEdit, which in turn opens a transaction. Nesting transactions
this way does not work: the first transaction is committed prematurely when
the second one starts. This may cause serious database corruption and
generally exciting behavior.

This change commits LocalFile's own transaction before any interaction
with WikiPage. There may be a race condition here, but that case seems to
be already handled in the code. Also, in the previous "broken" state, all
transactional protection got lost anyway - so this should at least be no
worse than what we had.

This may be changed back if and when we have support for nested
transactions.

Change-Id: I20d90fedb2d19c64ccf0f3942ddda756fe511c12
2012-09-07 14:33:35 -07:00
Aaron
e0718c496a Avoid redundant logging UPDATE query.
Change-Id: I277f311ea92ff3470039d9416e720573debba44a
2012-09-07 10:17:12 -07:00
daniel
b6fe213226 merge latest master.
some tests fail due to logical changes, will fix that in a follow-up

Change-Id: I8a5e4087ecf674fbcf6327c5d168cd401be12400
2012-09-05 17:50:13 +02:00
Platonides
ee39f5f7c5 (Bug 38606) Set log_page on uploads to the page_id of its description page
This change updates the log_page in a second step after performing
the edit, which is not terribly elegant, but is very robust.

Change-Id: I9015230df772d049b2879fb34914c68183f1da05
2012-08-29 23:23:27 +02:00
daniel
2c488a0eba Replace usage of doEdit() with doEditContent()
Change-Id: I2c423744bd91044c37bbec53b35729bd1c09901b
2012-08-28 16:53:19 +02:00
daniel
29719f846b merging latest master
Change-Id: I36b7f2f63ab8c08f8412d521dc68ea45c8b67711
2012-08-20 16:55:28 +02:00
Aaron
00c0319ed3 Profiling fix for LocalFile.
Change-Id: I02d770aee15e42b1046b06d405715cc046c9e7ca
2012-08-17 13:44:54 -07:00
Aaron Schulz
eb183bac87 Revision and WikiPage cleanup with IDBAccessObject interface.
* Replaced WikiPage::DATA_FROM_* constants with IDBAccessObject ones.
* Renamed IDBAccessObject constants a bit for visual consistency.
* Removed AVOID_MASTER parameter and replaced calling instances with READ_NORMAL.
  Instead of getting page_latest from the master and the revision from a
  slave, just get it all from the master in one RTT. Most callers used
  AVOID_MASTER (and now READ_NORMAL), so this case is barely hit anymore.

Change-Id: Ifbefdcd4490094b38e49bbb46c95fdb71b5c9e1a
2012-08-08 16:34:08 +00:00
daniel
d87135d706 merged master
Change-Id: Iad12ee382d6aeb1fab6fefb611d290b74865ea4b
2012-07-23 22:07:18 +02:00