- Added space after reserved words: function, foreach, if
- Combined 'else if' into elseif
- Added braces to one-line statements
- Added spaces after comma, before parentheses
Change-Id: Ie5bbf680d6fbe0f0872dab2700c16b1394906a72
Fixes "Fatal error: Argument 4 passed to Memcached::cas() must be an
instance of int, float given".
Change-Id: Ibf1ea638ec1a4dcf009cdaea8aa66008c74ff30b
- 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: I8ebfbcea0e2ae2670553822acedde49c1aa7e98d
Database::select() can return false, so we should check for it before
attempting to iterate on the result or to call methods on it.
Change-Id: I0862493305e5b2784422e0e94b3e62e734267795
- Added/removed spaces around parenthesis
- Added space after switch/if/foreach
- changed else if to elseif
Change-Id: I99cda543e0e077320091addd75c188cb6e3a42c2
* Callers still sees some decent time ordering since writes block
until committed. This will not blindly flush transactions though.
* Basically reverts 59e8032
Change-Id: Ib9a91ac023f8e3fafb0bf0eef9dca6e31b867be9
* This avoids breaking the main transaction in finishWrite().
* Also removed an unused variable in SqlBagOStuff.
Change-Id: Ia330ac362b080c1338616d95b793032c4752dc23
* This method is currently hit when bots use the maxlag API parameter
* Also added a $fallback param to ObjectCache::newAccelerator so code
does not have to keep reinventing that logic.
Change-Id: I45bf1085301c5cf69b29b494a146c6a067534581
It does not work with unserialize because RedisBagOStuff->unserialize
expects either strings of digits, or serialized strings. A plain integer
is neither.
incr docs were incorrect, so fix and expand by copying from parent class.
Change-Id: Ifc9c7a36f221b251ceea0d9a79ae6c3ce5753dd4
SqlBagOStuff::getMulti currently returns an array with false values for missed
cache keys.
Default BagOStuff::getMulti (and other specific implementations like memcached),
however, just omit missed values.
e.g.:
$cache->getMulti( array( 'goodkey' 'badkey' ) );
should return
array( 'goodkey' => 'value' );
instead of
array( 'goodkey' => 'value', 'badkey' => false );
Bug: 65637
Change-Id: Ib2de06a0f76421094707f7ad4218346087f4dc55
Includes implementions for Redis, Sql and MemcachedPecl,
other types will fallback to using $this->set repeatedly.
Change-Id: I0924a197b28ee69e883128ccd672343e5c041929
* This can limit how many workers work on a given file at once,
regardless of which specific thumbnail parameters are requested.
* Also added a BagOStuff::incrWithInit() method per DRY.
* Tweaked the register_shutdown_function() callback to avoid
File/MediaTransformOutput references, since they may involve
TempFSFile objects.
Change-Id: Ic01461cb974ab23b179ac3b60cf6de12e36360f6
Changed closure to capital word Closure in doc and type hint,
also changed callback in docs to callable
Change-Id: I52c8e8f13d38a837052101c38b9986be780ca057
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: I86fd10e3f2d4bb80e7432533038d124693acfb3c
Variants included 'in <version>', 'as of <version>' and just the
version number.
Some @deprecated annotations do not have the version number at all,
I want to hunt them down separately.
Change-Id: I8208c6097098f4735d4f51bc42254675f1f27f6d
- Added spaces after if/foreach/catch
- Added new line before end of file
- Added or removed spaces before/after parenthesis, comma
- Added spaces around string concat
Change-Id: I0590070f1b3542108e242730e8d9a3ba9831e94f
* Almost nothing actually uses this (one extension)
as it doesn't really solve race conditions like merge().
* Removed subclassed versions too.
Change-Id: I4d4123afcc0576a90a3cbf1e4e6daff7ebce39c3
Isn't useful outside of testing as the comments state, but it's
barely even useful for that. People who are testing the cache
code can use CACHE_DB if CACHE_MEMCACHED is too hard.
Change-Id: Ief0aa148376957fdd844c8bb585a133b854a012c
mehcache isn't a caching system, it's a pun.
I'm removing Ehcache support because it's an experiment didn't pan out
and the code's just sitting here abandoned now.
Change-Id: Ief5728b4c61bb5ad8f5a5f0b55415b23ef6727eb
For caches where CAS is not natively supported, we have a workaround, where the
CAS token is (based on) the stored value.
To confirm the data can be written to cache, the CAS token is compared against
"whatever is currently in cache", so we pull the cached data and rebuild the
value.
In the case of objects, we have now pulled & rebuilt (unserialized) 2 objects
that are actually the same object (for CAS purpose - it's the correct value to
overwrite), but in terms of ===, they're 2 different values.
This patch should make sure CAS tokens are always a serialized version of the
value we're saving (where no native CAS exists); these serialized versions can
reliably be compared.
Bug: 59941
Change-Id: I2760416c48f2ceb7a0e0c874dd70ec07b4dccdfc
* This works with local memcached (e.g. unix:///var/run/memcached/memcached.sock:0 )
and noticeably increases memcached mediawiki performance
Change-Id: Ie08c151caa09eb0a4269df88965d71c2367c398b
* Avoid serializing scalars like the memcached client does.
This means incr/decr can be fast and preserve the TTL.
* Properly call unwatch() in the cas() method.
* Made the expiry set on add() actually atomic.
* Also cleaned up the profiling calls.
bug: 56069
Change-Id: I3e0d1c4888062544c54aef32085f8ce608ff5423
The Line continuation Coding conventions prefers the closing parenthesis
on the same line than the beginning curly braces. This is done for ifs
and functions.
Also move some boolean operator from the end of a line to the beginning
and changed some indentation to make the condition hopefully better
readable.
Change-Id: Id0437b06bde86eb5a75bc59eefa19e7edb624426
Due to the PHP serialization, the Redis native INCR and INCRBY do not
work. This instead falls back on the parent class's incr, which uses
lock and unlock, and incrementing on the PHP side.
Bug: 55986
Change-Id: I500199aeb935963ca118fde163bd7ba0cba8f79f
Also removed some unnecessary ones. I think I've caught them all.
The spaceless version already appears in core ~300 times (after
accounting for false positives when grepping). Some consistency would
be nice.
Change-Id: I607655b5f4366e66dc78730d5fd2f57ed8776cae
When BagOStuff::lock() was called, it called $this->add() with only
two parameters, the key and the timeout. But BagOStuff::add() takes
three parameters (key, value, timeout), so all locks got an infinite
timeout.
Change-Id: I82bed11b0b799f2cda13a8a0bd0cd94908b6ce8e
And added/removed spaces around some other tokens,
like +, -, *, /, <, >, =, !
Fixed windows newline style
Change-Id: I0b9c8c408f3f6bfc0d685a074d7ec468fb848fc8
* Removed spaces around array index
* Removed double spaces or added spaces to begin or end of function
calls, method signature, conditions or foreachs
* Added braces to one-line ifs
* Changed multi line conditions to one line conditions
* Realigned some arrays
Change-Id: Ia04d2a99d663b07101013c2d53b3b2e872fd9cc3
* Ran spell-checker over code comments in /includes/
* A few spellchecking fixes for wfDebug() calls
Found one very strange (NOOP?) line in Linker.php - see "TODO: BUG?"
Change-Id: Ibb86b51073b980eda9ecce2cf0b8dd33f058adbf
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
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
Memcached response when fetching data typically looks like this:
VALUE <the stored value for whatever key you requested>
END
What the code used to do is read the first line (the VALUE) and re-
assemble the data being fetched there (like unserializing serialized
data). After that, it will read the next line (END).
The value could be a serialized object, which could have a __wakeup.
This __wakeup could have code which in turn executes Memcached-
related stuff. The problem is that, while that object is being
unserialized already, it's wakeup code is attempting to read new
stuff from Memcached, but we have yet to read the END of the data
we're attempting to unserialize (when we'll read a new value from
Memcached, the first thing we'd get is the END we have not yet read..)
The correct way to go about this would be to first read the full
Memcached response, and only unserialize the read data after that.
This is exactly what this patchset does.
Change-Id: I902809c6dde657091c8161a09df823170bd41f7a
Added/removed spaces after opening/before closing parentheses
Added a space after a comma
Removed unneeded parentheses in condition
Change-Id: I306091347ccaaf11dee0cdfda3019cb0c12be51b
By PSR2 PHP Standard, the files should ends with exactly one newline.
Some of our files have 2 or more and some other were missing a newline.
Fix almost all occurences of CodeSniffer sniff:
PSR2.Files.EndFileNewline.TooMany
I have not fixed the selenium files, I believe we will drop them.
Change-Id: I89fca8c1786fee94855b7b77bb0f364001ee84b6
Changes in the 1.20.x branch altered the add method to check for the return value of get against
false. Xcache 3.x returns NULL for unset values and so this check was erroneously determining that
all values are set when they were not.
This was causing basic ObjectCache usage to fail.
Change-Id: I0975e5c6a60c2813dc2d02aca84245807b8fb828
Since that revision, messages sent through wfDebugLog() and without
a corresponding entry in $wgDebugLogGroups will be prefixed there
before being sent to wfDebug(), so it's no longer needed to have the
exact same checks for the debug messages in memcached clients.
Change-Id: Ia690a87bc6d1994fe371816470efde6d09e3b881
* merge() will use CAS if supported or use locking otherwise
* The lock()/unlock() methods now have a default implementation
* added unit tests for merge
Change-Id: Ic27088488f8532f149cb4b36e156516f22880134
Also factor out consistent hash code from Redis and the new application
into a class called ArrayUtils. The name "ArrayUtils" is from
I0f4e7d7c, I expect that change will be rebased on top of this one at
some point.
Change-Id: I9375087f4d7a6e8e629d97bfb6b117d9cb7d1bcf
Added a multi-server feature to SqlBagOStuff.
Tests done:
* With both the "shard" and multi-server features enabled and
$wgAllDBsAreLocalhost, tested getMulti, set, incr, decr, keys,
garbageCollect, deleteAll. Tested wiki page views with
$wgMainCacheType set to such a cache.
* Tested connection errors.
* In the plain CACHE_DB configuration, tested wiki page views.
Change-Id: Ifba0d276ef724cc9b33f687bc0adae4637054328
* Preserve TTL in objectcache incr() method for APC, XCache and DBA.
Do not serialize numeric values, since it breaks the counters.
* Also gave some DBABagOStuff functions explicit visibility.
Change-Id: I13856832f418c843afc8e42a6d77686331f6cb41
With sharding, failover and consistent hashing. Only supports the
extension (phpredis), since the pure PHP library Predis had about a
billion files and it made my eyes hurt.
Change-Id: I90fb4a41d15265b9c22f8e32ecd1d956f89f3ce8
When $wgSessionsInObjectCache is enabled, use a configurable expiry time
instead of a hard-coded one-hour expiry.
Change-Id: Ia51962176d30fd87e298c47ec347a143cad80772
* Introduce $wgSessionCacheType to allow the session storage to be
configured independently of $wgMemc.
* Renamed $wgSessionsInMemcached to $wgSessionsInObjectCache to reflect
the new versatility.
* Modernized the relevant code, removing the explicit require_once(),
used the autoloader instead. Moved it to ObjectCacheSessionHandler.
* Tested with memcached, external sharded MySQL and APC, it all seems to
work just fine.
Change-Id: I473334bb56cafb4e21ac1c1304d69095676fc0c4
* When there is a read error, close the socket and mark the server dead,
instead of continuing to send requests through it, causing a protocol
violation.
* Also check for write errors.
* Increase the default stream and connect timeouts from 100ms to 500ms.
* Remove the commented-out _safe_fwrite() code that I wrote in 2005,
that PHP bug is fixed now, so writes can be handled the same way as
reads.
* Fix E_STRICT errors in get_multi() due to a resource being used as an
array index.
* For performance, flush the read buffer less often (only on persistent
connect).
* Move the fread() loop from _load_items() into its own new function.
* Be stricter about stripping expected newlines, don't just run trim() on
everything.
* Make MemCachedClientforWiki into a simple alias since the distinction
with MWMemcached was lost many years ago. We even renamed the class
"MWMemcached".
* Remove vim modeline made incorrect by 19d6293 (Nov 2009).
Change-Id: I81de31049b87038999e37054d8d174a782c78a68
MemcachedClient output a generic error message: "Error parsing memcached
response\n" whenever it is not able to read from the socket. It is also
lacking the remote peer it is reading from.
This patch add a new message when fgets( <socket> ) return false, which
means we could not read from the file pointer. It also get the stream
remote name for debugging purposes.
Change-Id: I9b8a25a03af0d730aa3b4830a44b1ea739343274
MemcachedClient output a generic error message: "Error parsing memcached
response\n" whenever it is not able to read from the socket. It is also
lacking the remote peer it is reading form.
This patch add a new message when fgets( <socket> ) return false and
attempt to get the remote peer address / port to append to the error
message. Might help us find out which memcached server is wild.
Change-Id: If918e824970aaa8231078e42fd28d31e8dd4e319
When inserting XML elements inline <such as this one>, doxygen chokes
about it not being known. Simply enclosing the tag in double quotes
prevents doxygen from emitting a warning.
Also enclosed a few invalid functions calls such as \. and double quoted
the HTML entities such as &foobar;
Change-Id: I4019637145e683c2bec3d17b2fd98b0c50a932f1
* SqlBagOStuff should not turn off automatic transaction
control just like that. Keep previous
connection for PostgreSQL and SQLite
* 94633ff448 introduced
rollback on error to restore sanity
for the connection. Don't do this
if you are in the middle of INSERT IGNORE
and we have a savepoint open.
Making sure query syntax errors don't
get silenced by our "wonderful" implementation
of INSERT IGNORE is bug 35572.
Change-Id: I841b03895e1189c47307fefb1516c4c7c4102e25
* When using a persistend ID in the constructor, the object is effectively shared among
the callers using that ID. If we always use __CLASS__, then this breaks when different
BagOStuffs may be used. Instead, a hash of the settings is now used.
See http://www.php.net/manual/en/memcached.construct.php.
* Don't keep adding servers to the pool, as the object is shared among callers. Once one thread
initializes the object, it will already be initialized by the next thread. Calling addSever()
again will cause an increasing number of duplicate servers to exist in the data structure, and
thus an increasing number of socket connections over time.
* Also, use addServers() instead of multiple addServer() calls per
http://www.php.net/manual/en/memcached.addserver.php.
Change-Id: I0e7510320cb79d9f152e8958ddd50400fa9da37f
We had two way to get a temporary directory:
- $wgTempDirectory: more or less stable accross sessions
- wfTempDir(): set through environnement variable and could potentially
vary from a session to another one thanks to tempnam()
This patch makes wfTempDir() to always use the global $wgTempDirectory
first when it is available. Thus explicitly overriding tempnam() or any
environnement variable such as TMP or TEMP.
Hence, people who don't have access to a system wide directory
specificed by their environnement (such as /tmp) can specify an
alternative straight from the MediaWiki configuration.
The patch remove references to $wgTmpDirectory and replace them with
calls to wfTempDir(). Make wfTempDir() use $wgTmpDirectory first.
The default setting of $wgTmpDirectory was removed in favor of having it
initialized through Setup.php by calling wfTempDir.
Note: this may also address Bug 36475 - Generating thumbnails does not
work when there is no access to /tmp
Change-Id: Ifdc79e9c5d95f978025b237a5eeb95fd75092f46
* Made getMulti() only return keys for items that exists.
* Made add() return false if the item already exist.
* Made replace() return false it the item does not already exist.
Change-Id: Idb9d9843ace0c81f71abfc22b90e30eb33d7579d
* Fixed the check for igbinary presence. It's not enough for the
extension to be loaded, the memcached extension also needs to be
compiled with --enable-memcached-igbinary.
* When delete() is attempted on a key that doesn't exist, return true,
as in the other BagOStuff implementations.
Change-Id: I298952f4a9925d860fa5673f632d073b1f20aa47
* Introduced a common base class for the two memcached clients, called
MemcachedBagOStuff.
* Moved the expiry time normalisation from MemcachedClient.php to
MemcachedBagOStuff since libmemcached needs the same workaround.
Change-Id: I507d4ec5a7fd863ae64a94f2c453981f9f03746c
When enabling memcached debug logs ($wgMemCachedDebug), they are
unconditionally sent to the main $wgDebugLogFile. This patch make it
possible to sent thoses specific log to an alternate file by setting
$wgDebugLogGroups['memcached']
Change-Id: I85d8ab92471ce3c31f8168dae83fe91e95e18dce
This reverts the SpecialCachedPage and formatDuration sagas, with some collateral damage here and there. All of these revisions are tagged with 'gerritmigration' and will be resubmitted into Gerrit after the Gerrit switchover. See also http://lists.wikimedia.org/pipermail/wikitech-l/2012-March/059124.html
DBABagOStuff was not refactored by r83140 which pass BagOStuff constructors
an array. This patch honor the 'dir' parameter to let you override the global
$wgTmpDirectory.
Need backport in REL1_18
* Do queries in batches of 100 rows instead of all at once. Note that if there are a lot of objects with the exact same expiry time, it might take multiple runs of the script to delete them all.
* Progress meter.
As Brion points out in <https://bugzilla.wikimedia.org/show_bug.cgi?id=29747#c7>, the shared memory functions are very buggy. In fact, eAccelerator has disabled the shared memory functions by default for awhile now. I didn't touch APC, XCache or WinCache, but I imagine they suffer from the same problems.
PHP fatal error in /usr/local/apache/common-local/php-1.18/includes/objectcache/MemcachedPhpBagOStuff.php line 91:
Call to undefined method MemCachedClientforWiki::lock()
* Fixed unintentional shortcut evaluation in MultiWriteBagOStuff::doWrite(). It would have caused writes to be skipped on the second cache if the first cache failed, now writes should be attempted on all caches.
Patch from John Du Hart: https://bugzilla.wikimedia.org/attachment.cgi?id=8849&action=diff
If XCache is present, but the xcache.var_size setting is off, we'll now consider it as xcache being disabled for CACHE_ACCEL purposes. It won't trigger view of the accelerator option in the installer, and at runtime if using CACHE_ACCEL and no other modules are available, it'll throw an error so you know that it doesn't work!
* In MemcachedSessions.php, register a shutdown function to shut down the session early, before $wgMemc is destroyed. I'm not sure why my recent changes caused this problem to show up now.
* Use EmptyBagOStuff instead of FakeMemCachedClient in DefaultSettings.php for CACHE_NONE.
* Moved the global functions to GlobalFunctions.php, where they are now just convenience wrappers. Made them return non-references. Updated callers (none found in extensions).
* Added an advanced configuration method, $wgObjectCaches, which allows a lot more detail in the object cache configuration than $wgMainCacheType.
* Made all object cache classes derive from BagOStuff.
* Split the MWMemcached class into a generic client class and a MediaWiki-specific wrapper class. The wrapper class presents a simple BagOStuff interface to calling code, hiding memcached client internals, and will simplify the task of supporting the PECL extension.
* Added some extra constructor parameters to MWMemcached, configurable via $wgObjectCaches.
* Removed the *_multi() methods from BagOStuff, my grepping indicates that they are not used.
* Rewrote FakeMemCachedClient as a BagOStuff subclass, called EmptyBagOStuff.
* Added an optional "server" parameter to SQLBagOStuff. This allows the server holding the objectcache table to be different from the server holding the core DB.
* Added MultiWriteBagOStuff: a cache class which writes to multiple locations, and reads from them in a defined fallback sequence. This can be used to extend the cache space by adding disk-backed storage to existing in-memory caches.
* Made MWMemcached::get() return false on failure instead of null, to match the BagOStuff documentation and the other BagOStuff subclasses. Anything that was relying on it returning null would have already been broken with SqlBagOStuff.
* Fixed a bug in the memcached client causing keys with spaces or line breaks in them to break the memcached protocol, injecting arbitrary commands or parameters. Since the PECL client apparently also has this flaw, I implemented the fix in the wrapper class.
* Renamed BagOStuff::set_debug() to setDebug(), since we aren't emulating the memcached client anymore
* Fixed spelling error in MWMemcached: persistant -> persistent