Commit graph

1516 commits

Author SHA1 Message Date
Kunal Mehta
525dd55065 Add and use wikimedia/base-convert 1.0.1
Change-Id: I3ae56e761ef6fb2b2d506bc2990b97f57183ccf1
2015-10-30 00:53:46 +00:00
Aaron Schulz
52010e6d21 Make DB handles inherit configured read-only mode
LBFactory inherits $wgReadOnly, the LBs inherit
any LBFactory read only mode, and Database objects
inherit any LB read-only mode.

Add some methods callers can use to check if
a DB/LB handle is read-only before trying writes.

Additionally:
* Fix 5ec1e47475 regression where readOnlyBySection
  read-only mode would not affect wfReadOnly() but only
  lagged-slave read-only mode for LBFactoryMulti.
* Catch errors when getLaggedSlaveMode() is called after
  master connection and object is established.
* Make getLaggedSlaveMode() a no-op if there are no slaves.
* Make string/false logic for read-only consistent everywhere.
* Remove mLaggedSlaveMode "m" prefix.

Change-Id: Ice3224caae564aa5ffb41b424c23d1593229117a
2015-10-20 23:27:14 +00:00
Aaron Schulz
cb862afaf3 Rename getMainClusterInstance() -> getLocalClusterInstance()
Also corrected some ObjectCache docs

Change-Id: I322f4cbd72fbd5d4c6887d90ee75d0baddb6ac25
2015-10-20 00:26:21 +00:00
jenkins-bot
7436cd31a2 Merge "Add makeKey and makeGlobalKey to BagOStuff" 2015-10-17 01:06:12 +00:00
csteipp
59b627b0b7 SECURITY: API: Improve validation in chunked uploading
This fixes a few shortcomings in the chunked uploader:
* Raises an error if offset + chunksize > filesize.
* Enforces a minimum chunk size for non-final chunks.
* Refuses additional chunks after seeing a final chunk.
* Status of a chunked upload in progress is now available with
  'checkstatus'.

Bug: T91203
Bug: T91205
Change-Id: I2262db1bc8460616b069c564475d2e4148001768
2015-10-16 14:10:44 -07:00
Alex Monk
23f633c5a6 Use the frame 'type' in wfFormatStackFrame, like MWExceptionHandler::prettyPrintTrace
Instead of assuming '::'

Change-Id: I2452bc5ebd3716eb61f53da41a0050f4833fb5a4
2015-10-14 16:40:02 +01:00
Alex Monk
9144554931 Handle $frame['function'] not being set in stack frames
Bug: T115107
Change-Id: I9fbfcd53fbcba1800a924acb1a1702c3c9037cc5
2015-10-14 13:05:29 +00:00
umherirrender
2320f5cfe2 Change some line comments to multi line comments
This allows empty lines inside the comment as found by the
MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.EmptyComment sniff

Change-Id: Iac155bbda4a84562db2b452baeae9b8973899453
2015-10-14 09:40:50 +02:00
Ori Livneh
6916548490 Add makeKey and makeGlobalKey to BagOStuff
* Add a string `keyspace` member to BagOStuff instances. The default
  implementation, meant for simple key/value stores, treats the key space
  as a string prefix to prepend to keys. By default, its value is `local`,
  but any instance created via ObjectCache::newFromParams() (or or one of
  its callers) will have that default to $wgCachePrefix / wfWikiID().
* Add `makeKey` and `makeGlobalKey` methods to the base BagOStuff class.
  These methods are not static to allow for BagOStuff types which require
  a configured instance to know the underlying storage engine's key semantics.
* Make wfMemcKey() and wfGlobalCacheKey() delegate to these methods on the main
  ObjectCache instance.

Change-Id: Ib7fc2f939be3decfa97f66af8c2431c51039905f
2015-10-13 09:32:48 -04:00
Bryan Davis
b264cee6d4 Fix namespaced class references for Doxygen
Doxygen doesn't quite grok PHP's use of the reverse solidus (backslash)
character as a namespace separator. The C++ based parser it uses needs
them to be escaped in comments just as if they were being used in
a literal string context in PHP.

Change-Id: I9aff9dd0fb74a95039da1091c2f247cf71fd085a
2015-10-08 11:10:33 -06:00
Ori Livneh
7628a11d8e Remove .php5 entrypoints and $wgScriptExtension
* The '.php5' entrypoints were deprecated in I68b1ae842, $wgScriptExtension
  in I3690f78bc.
* Drop the associated ResourceLoader configuration variable, too. `mwgrep`
  shows no usage in the MediaWiki namespace.
* Keep the scriptExtension configuration parameter for FileRepo for people who
  would like to interoperate with older MediaWiki installations that still use
  '.php5'.

Change-Id: I17c8a15484b7e82cd5970d34e688109a2aae3840
2015-10-08 15:45:31 +01:00
Aaron Schulz
8a3816529a Apply $wgReadOnly to all file backends
* Also added a wfConfiguredReadOnly() method
  to avoid DB_SLAVE connections

Change-Id: I9e7ec95c4b2f763505166d2345d27abaef6257a3
2015-10-03 00:15:28 +00:00
Aaron Schulz
e055d8abcd Removed wfDataCenter()/wfDataCenter() roles
* Follows-up 0a1c04bea
* The DC name ended up not being used in the cookie, 
  making these unused

Change-Id: I5f0d822a334102ee9596b1ec2a8d911010294e7c
2015-10-01 20:00:05 +00:00
Aaron Schulz
0a1c04beae Added $wgDataCenterId/$wgDataCenterRoles
* This is used to set sticky DC cookies to avoid
  session replication lag (which also makes sure
  ChronologyProtector works)

Bug: T91816
Change-Id: I7bc2f8185a3c05cb3ca5ccc42d300eccffae48e1
2015-10-01 00:52:54 -07:00
Aaron Schulz
6e115a7cc1 Optimized wfIsBadImage() redirect check
* Callers end up hitting wfFindFile() anyway, so we
  may as well use/prime the process cache. By trying
  to call checkRedirect() manually, it actually just
  caused an extra memcached query.
* 404 pages are often customized to show various
  icons file from sister sites, so this was taking
  up a significant portion of rendering time.

Change-Id: I7e2a1c6acf853629fcca3a8b3c2c810ebacd2acb
2015-09-27 14:43:39 +00:00
Vivek Ghaisas
c54766586a Fix issues identified by SpaceBeforeSingleLineComment sniff
Change-Id: I048ccb1fa260e4b7152ca5f09b053defdd72d8f9
2015-09-26 23:06:52 +00:00
Aaron Schulz
a607f11f94 Made wfIsBadImage() use APC
* Article 404s spend are large chunk of their time
  there and the method is also hit on page save

Change-Id: I26043f596195a8fe322bc154bf375a6c5d39c968
2015-09-25 22:38:04 +00:00
umherirrender
271da88127 Some bugzilla.wikimedia.org -> phabricator.wikimedia.org changes
Changed some old bugzilla links to new phabricator links in comments,
test data and error message. This reduces the need for redirects from
old bugzilla to new phabricator from our source code.

Change-Id: Id98278e26ce31656295a23f3cadb536859c4caa5
2015-09-24 17:17:25 +02:00
jenkins-bot
e491904eef Merge "Add new authentication-related hooks (and remove one) replacing some AuthPlugin methods" 2015-09-22 07:32:03 +00:00
jenkins-bot
35f61c7c4b Merge "registration: Allow extensions to specify which MW core versions they require" 2015-09-22 04:57:47 +00:00
Kunal Mehta
cef1f31167 registration: Allow extensions to specify which MW core versions they require
This adds a "requires" property to extension.json, which extensions and
skins can use to indicate which versions of MediaWiki core they support.
The hacky wfUseMW() is now deprecated in favor of this.

Rather than writing our own version constraint and parser library, we
can re-use composer's, which was recently split out into a separate
library named "composer/semver" for this patch.

Any syntax accepted by composer[1] is available for usage here. Test
cases have been provided to demonstrate how versions are parsed. For now
it is recommended that people stick to expressing compatability with
stable versions (e.g. ">= 1.26").

This patch does not support requiring specific MediaWiki core WMF
branches, since those do not follow the standard semver format that
composer parses. If we are unable to parse $wgVersion, all checking will
be skipped and reported as compatible.

[1] https://getcomposer.org/doc/01-basic-usage.md#package-versions

Bug: T99084
Change-Id: I7785827216e16c596356d0ae42d6b30f3f179f10
2015-09-21 09:56:53 -07:00
Brad Jorsch
37062a0c0d Add new authentication-related hooks (and remove one) replacing some AuthPlugin methods
* LocalUserCreated: Replaces AuthPlugin::initUser()
* UserGroupsChanged: Replaces AuthPlugin::updateExternalDBGroups()
** The similar UserRights hook is deprecated, mainly to get rid of the
   passing of $user by reference.
* UserIsHidden: Replaces AuthPluginUser::isHidden()
* UserIsLocked: Replaces AuthPluginUser::isLocked()
* UserLoggedIn: Replaces AuthPlugin::updateUser()

Also, AuthPlugin::updateExternalDB() is deprecated in favor of the
existing UserSaveSettings hook.

Also, 'ResetSessionID' has been removed. Nothing uses it, I don't know
why I even added it in the first place.

Also, replacing the User object passed to AuthPlugin::initUser() and
AuthPlugin::updateUser() will now raise a warning.

Change-Id: If7474cfb26a29b11c2e78147069419ca3b1cba95
2015-09-18 10:46:13 -04:00
Bartosz Dziewoński
aa511ccd86 Add '@since 1.25' annotation to wfLoad*() functions
Change-Id: I2cf9c2eddaa8b3449bd2852c496515b5bc133981
2015-09-16 15:55:13 +02:00
jenkins-bot
804cc6885a Merge "Revert "Do not encode "'" as %27 (redirect loop in Opera 12)"" 2015-09-10 15:36:10 +00:00
Bartosz Dziewoński
8477b1b277 Revert "Do not encode "'" as %27 (redirect loop in Opera 12)"
This seems to cause redirect loops in current Firefox instead.

This reverts commit a89a21990e.

Bug: T106793
Change-Id: I18fac8ab0f94e2df8476131b132c9866902a02c4
2015-09-10 15:23:25 +00:00
jenkins-bot
d891ffecbd Merge "Fix so wfResetOutputBuffers doesn't break unit tests" 2015-09-10 00:14:21 +00:00
jenkins-bot
e3a3f2293b Merge "Unbreak wfResetOutputBuffers" 2015-09-10 00:03:45 +00:00
Bartosz Dziewoński
a89a21990e Do not encode "'" as %27 (redirect loop in Opera 12)
Similar to 7b4df0e12e,
but for apostrophe instead of tilde and for Opera
instead of Chrome.

Bug: T106793
Change-Id: Ic54390434cebcc76a6c8ab49acc164d36e0cdff6
2015-09-05 21:17:33 +01:00
Florian
20f2df9c9f Implement wfArrayPlus2d which combines 2d arrays
Moved the logic of ExtensionRegistrations array_plus_2d merge method out
to it's own global function wfArrayPlus2d, so any other function in mediawiki
core and it's extensions can use this method when they need to union
a 2d array.

Change-Id: I56afdf306e399a4a1505828ed76c60c1bfd033b6
2015-09-01 20:53:54 +02:00
Timo Tijhof
62e3da7e58 objectcache: Document the primary entry points people should use
There are imho too many ObjectCache methods, $wg*Cache* variables,
CACHE_ types, and wfGet*Cache() functions to know which ones
should actually be used publicly. This should make it easier to
know which ones should be used.

The difference between them was also harder to understand with the
main documentation sections about each of these living in
conceptually different places:
- classes (WANObjectCache)
- methods (ObjectCache::getMainStashInstance)
- variables (DefaultSettings: wgMainCacheType, wgMainWANCache, wgMainStash)

Also:
* Correct wfGetCache() documentation.
* Add the missing keywords for 'public' visibility.

Change-Id: I3b05fdb8b7888bf7e3f05bdca36538f3484556b8
2015-08-25 03:11:15 +02:00
Timo Tijhof
86c701f290 objectcache: Remove use of deprecated $wgSessionsInMemcached
Deprecated since MediaWiki 1.20.

Change-Id: I3b431714e0d2b21b3911c80bbf2b4b4868634510
2015-08-24 22:11:22 +02:00
Brad Jorsch
4379362154 Fix so wfResetOutputBuffers doesn't break unit tests
If something being unit tested calls wfResetOutputBuffers(), it'll break
PHPUnit's attempt to capture output in order to fail tests. In the old
version we're currently using for Jenkins it will throw a warning
"ob_end_clean(): failed to delete buffer. No buffer to delete", while in
newer versions it'll detect that its buffer was removed and fail the
test as risky instead.

The solution here is to have MediaWikiTestCase add a buffer with a known
name in setUp() (and remove it in tearDown()), and have
wfResetOutputBuffers() stop when it sees that known name on the stack.

Bug: T109843
Change-Id: I8acd91ec9dd9c6d78a5d91d96202249f571d5d83
2015-08-21 12:24:07 -04:00
Brad Jorsch
8c76a6f0ff Unbreak wfResetOutputBuffers
Sometime between 5.3 and 5.6, PHP changed from considering the default
output buffer (ob_start() or ob_start( null )) as "user" to considering
it as "internal", which prevents wfResetOutputBuffers() from removing
any buffers.

What we really should do here is test directly for whether the buffer
can be deleted, using the 'del' flag in PHP 5.3 or 'flags' in PHP 5.4+.
As for HHVM, we'll need to continue falling back to testing 'type' for
now thanks to https://github.com/facebook/hhvm/issues/5563.

Bug: T109842
Change-Id: If0163257a8fb471fd594a3754a20c65274f84a4c
2015-08-21 12:23:32 -04:00
Brad Jorsch
093a0c1106 Fix return value comment on wfMemoryLimit()
It was changed incorrectly in I893ddd77.

Change-Id: I1f1e3c53a2cefe69b42ef338aa2a6b126e3d5526
2015-08-17 11:42:10 -04:00
Aaron Schulz
9bba2d169e Added wfTransactionalTimeLimit() method and applied it
* Potentially long running POST requests often use multiple transactions,
  talk to multiple services, or defer updates. Try to make sure they have
  a chance to complete all of the work. WMF already sets ignore_user_abort()
  across the board in config, but this applies it to key spots for all
  installs, in addition to bumping the time limit. 
* Eventually this can lower the need for high overall time limits.

Bug: T102890
Change-Id: I893ddd773064dcd63b5b24c84c6391974f4b5aee
2015-08-12 22:09:40 +00:00
Aaron Schulz
203d2c9c11 Moved ObjectCacheSessionHandler renewal logic to wfSetupSession()
* This should trigger more reliably than the shutdown function
  callback, which is really only there for sanity to make sure
  session close/write happens.

Change-Id: I9a1aa76de121ba8de33b3fa850bd223929fae404
2015-08-10 19:10:38 +00:00
addshore
acf2130bc5 Remove unused StatsdClient use from GlobalFunctions
Change-Id: I5a773590e229f891298ff3d2eda5e4a258cc1f25
2015-08-06 18:00:43 +01:00
Gergő Tisza
e56f7b6c63 Sample StatsD messages when instructed
Bug: T106457
Change-Id: I8ddb5a53dcbaf398f5a114d2a4a862842e980db4
2015-08-03 22:09:18 +00:00
Gergő Tisza
3ebb384513 Log exceptions in the StatsD process
Change-Id: Iff14cbbfbe81d38c55b41ff115c66156323df035
2015-07-23 21:26:29 +00:00
jenkins-bot
012248fc5a Merge "Allow constructing a Message from a MessageSpecifier" 2015-07-20 23:05:26 +00:00
jenkins-bot
08db2b721e Merge "Hygiene: Use strtr() instead of str_replace() for character swapping" 2015-07-15 09:39:45 +00:00
Brian Wolff
7b4df0e12e Do not encode '~' as %7E. Fixes redirect loop in chrome.
As of 155d555b83, we now redirect variations on hex escapes
into their canonical form. This was causing '~' to be redirected
to %7E. However google chrome seems to canonicalize %7E back
into ~, causing a redirect loop.

RFC 3986 says ~ is unreserved, so not hex encoding it should be
fine. To quote: "For consistency, percent-encoded octets in the
ranges of...tilde (%7E) should not be created by URI producers"

Bug: T105265
Change-Id: I01556eee496e2fb540de8ff09c082c1fedddb5f7
2015-07-09 11:52:24 +01:00
Timo Tijhof
c318e3a265 Hygiene: Use strtr() instead of str_replace() for character swapping
strtr() is marginally faster as it runs through the string only
once. A better fit for one-for-one character translation.

The strtr() function also supports an associative array as second
parameter for entire string replacements. This, too, has the same
performance and predictable behaviour (starts with the longest key).
Whereas str_replace is for more aggressive needs where you want
multiple passes until there are no further matches.

The associative array form is arguably also easier to understand
and harder to mess up since the needle/replacement pairs are
explicitly connected instead of two separate arrays.

Also:
* Use getFormattedNsText instead of strtr( getNsText, .. ) which
  reduces duplication of this fact through a more semantic intent.

Change-Id: Ie23e4210a5b6908dd79eebc8a2b931d12fe31af6
2015-07-06 20:25:19 +00:00
Timo Tijhof
4ef96ff1f2 Declare and document $wgStatsdServer and $wgStatsdMetricPrefix
Follows-up 87dfc20.

Change-Id: Ie1b799a8f2a73b974ba8c930cfabc00e377d6eee
2015-07-02 08:03:21 +00:00
Timo Tijhof
0f64b61271 Implement wfGlobalCacheKey() for database-agnostic keys
Some code paths abuse wfForeignMemcKey() for this purpose. This is semantically
incorrect and seems fragile. Also the empty second argument (for db-prefix) is
either misused or akwardly set to the empty string.

It also creates a namespace conflict between arbitrary application keys (from
the software) and any database names (from users). This commit reduces the
conflict surface down to a single key (namely, "global").

Also added unit tests to assert the implicit restrictions and
assumptions between these cache key functions are valid.

Change-Id: Ia0953b51005fe3de3b881dd1bd64c9d3c85e8c66
2015-06-23 07:52:18 +01:00
Vivek Ghaisas
9f5b6f5aeb Fix whitespace issues around parentheses
Fix issues found by MediaWiki.WhiteSpace.SpaceyParenthesis sniff.

Bug: T102617
Change-Id: Iec7f71e64081659fba373ec20d9d2006306a98f4
2015-06-16 22:14:02 +03:00
Kunal Mehta
f6e5079a69 Use mediawiki/at-ease library for suppressing warnings
wfSuppressWarnings() and wfRestoreWarnings() were split out into a
separate library. All usages in core were replaced with the new
functions, and the wf* global functions are marked as deprecated.

Additionally, some uses of @ were replaced due to composer's autoloader
being loaded even earlier.

Ie1234f8c12693408de9b94bf6f84480a90bd4f8e adds the library to
mediawiki/vendor.

Bug: T100923
Change-Id: I5c35079a0a656180852be0ae6b1262d40f6534c4
2015-06-11 18:49:29 +00:00
Timo Tijhof
70429dc8a2 Use HttpStatus::header instead of manually crafting header()
Also:
* Update wfHttpError() to use uppercase DOCTYPE, to match other code
  such as Html.php, wfThumbError(), HttpError.php, etc.

Change-Id: I4027e7fe1a138b03f78797b6d1bfe7bd1064d360
2015-06-04 02:27:35 +00:00
Kevin Israel
cfaaff1068 wfBaseConvert(): Avoid PHP warning when converting zero
The warning occurs when gmp_init() tries to convert the empty string
that came from ltrim(). This is causing tests to fail under HHVM 3.6.1.

Follows-up 5957856c46.

Bug: T98882
Change-Id: Ica86c91d7897db979e09d7cfc82fb3a20b95d4ce
2015-05-13 15:52:49 +00:00
Ed Sanders
cf2678e24d Allow override of extension directory
Also sets default paths immediately (not in Setup.php) so
they are available before extensions register.

Bug: T98319
Change-Id: I41a8aec7a3e9c576ec7344abf51f8106248ade4b
2015-05-06 19:22:55 +01:00
Thiemo Mättig
0b79eebfa6 Add @var LoadBalancer[] type doc
This avoids a good amount of type warnings in certain IDEs, e.g. in
my PHPStorm.

Change-Id: Id2b99ad48fa2c0d924a1f51b7d2e382eaac7347d
2015-04-29 19:16:50 +00:00
Aaron Schulz
aef1c677f1 Made wfReadOnlyReason catch DB connection errors
Change-Id: I4e960d9bd751b2a6f95f08861fc8ed360af4a04a
2015-04-24 13:52:32 -07:00
jenkins-bot
979681f488 Merge "Use PHP_OS rather than php_uname, which may be disabled" 2015-04-22 20:19:52 +00:00
Brad Jorsch
3a878b81be Allow constructing a Message from a MessageSpecifier
Bug: T91986
Change-Id: Id6a9862d23c2b71da2c8b34acdd19b8247ac5301
2015-04-21 11:48:39 -04:00
Aaron Schulz
95cfa54557 Made wfWaitForSlaves check all master connections for writes
* Previously it just checked the main connection

Change-Id: If63498e4fa2800f8ffbde4c570c556f21b554473
2015-04-16 22:27:24 -07:00
jenkins-bot
6733f81d33 Merge "Only need one check for is_dir" 2015-04-12 18:29:36 +00:00
Kunal Mehta
dda1696b7f Remove unused "swap" global function
Deprecated in 26e1e083e8, unused since r12411.

Change-Id: If328f09114ac5a5d23a300d9b0bbcd7d67e051c8
2015-04-10 18:07:38 +01:00
Ori Livneh
e0e6c9c746 Use PHP_OS rather than php_uname, which may be disabled
A user just logged on to the #mediawiki channel to ask for help because his
webhost disallowed php_uname(), causing wfIsWindows() to crash. Google
autocompletes 'php_uname()' to 'php_uname() has been disabled for security
reasons', so it is probably not uncommon. Consulting the PHP_OS constant
instead side-steps the problem nicely.

Change-Id: I8d63826db4fc5d142eac53717d4f9fbbf9928de9
2015-04-09 12:16:17 +00:00
Aaron Schulz
01a5c6013e Made wfReadOnly() more robust at handling the lagged-slave case
* Previously if it was called before a DB_SLAVE connection, it would not
  be set. This is fixed now.
* Also set mLaggedSlaveMode in LoadBalancer as appropriate. Before, it
  was only set in the "too lagged for ChronologyProtector" case.

Change-Id: Ic4dc555cf762653f157df1795f53f3577c1e587a
2015-04-08 18:41:57 +00:00
Bryan Davis
1195e11a8a Move MWLogger classes to MediaWiki\Logger namespace
Move the MWLogger PSR-3 logging related classes into the
MediaWiki\Logger namespace. Create shim classes to ease migration of
existing MWLoggerFactory usage to the namespaced classes.

Bug: T93406
Change-Id: I359cc81fbd2dcf8937742311dcc7d3dee08747b0
2015-04-03 11:32:24 -07:00
Ori Livneh
97a9c65895 PHPCS lint fixes
Change-Id: I16288db03f34439bdb16940a86720d2511f46467
2015-04-03 11:08:19 -07:00
Ori Livneh
1b6f70089d Introduce ProfilerOutputStats
* Associate Profiler objects with a request context by adding a $context
  property with a getter and a setter.
* Introduce ProfilerOutputStats, which writes profiling data to the stats
  buffer associated with the current request context.
* Make it the Profiler class's responsibility to enforce $wgProfilerLimit.
* Deprecate $wgProfilerLimit in favor of the (more aptly named, IMO)
  $wgProfiler['threshold'] config setting.
* Tidy up Profiler instance creation code in Profiler::instance().
* Add Profiler::getOutputs, which returns an array of ProfilerOutput instances
  which are configured for the current profiler and whose canUse() method
  returns true.
* Make ProfilerStub not log by creating a stub ProfilerStub::logData() method
  which does not call the parent. Previously the parent class checked if $this
  was an instance of ProfilerStub and returned early if so.

Task: T90623
Task: T85641
Change-Id: Icf644ad3435c1f30d0a49957a97b481808a3153d
2015-04-02 01:32:46 +00:00
Ori Livneh
667fa3e264 Make WebRequest objects time-aware
* Deprecate $wgRequestTime in favor of $_SERVER['REQUEST_TIME_FLOAT'], which is
  more accurate. Because $_SERVER['REQUEST_TIME_FLOAT'] is only set for PHP
  5.4+, set it to microtime( true ) in WebStart.php for back-compatibility.
* Add a 'requestTime' property to WebRequest objects, set to
  $_SERVER['REQUEST_TIME_FLOAT'] for WebRequest or the instance creation time
  for FauxRequest instances.
* Use that to provide WebRequest::getElapsedTime(), which gets the time since
  the request was initiated.
* In wfLogProfilingData(), get the user and request objects from the context
  object rather than from global scope.

Opportunistic clean-up: move the magic quotes check to WebStart.php and make
the error message more helpful.

Change-Id: I7e07e22eaf16b5141b80ad9f843285c542a127b7
2015-04-01 18:21:26 -07:00
Kunal Mehta
78fbe31c2b registration: Have wfLoadExtension() (and similar) use the queue
Right now wfLoadExtension() and related functions explicitly load
extensions immediately, bypassing the queue. This was done to be
extremely backwards-compatible with the old require_once style of
loading which does the same.

However, for a future configuration database to work, we need to be able
to reliably load extensions after configuration (LocalSettings.php) is
loaded, which is currently at the top of Setup.php. Rather than doing
this later, we should do this now to make sure the registration system
will be able to handle it.

In Wikimedia production, excentions are currently being loaded with
direct calls to:
  ExtensionRegistry::getInstance()->queue(...);
so we know that this should work, but that is not a nice API for sysadmins
and developers to be entering into LocalSettings.php.

If for some reason an extension really needs to be loaded immediately,
they can still call:
  ExtensionRegistry::getInstance()->loadFromQueue();
But that should be the exception, not the norm.

Change-Id: I72672e5c9541ede02d09f548c39ef6c8df0ec78a
2015-03-31 00:47:15 +00:00
Max Semenik
4b28391820 Deprecate wfDiff()
This function is backwards:
* The stated purpose is to generate a list of differences for callers to parse,
  however we already have DiffEngine that returns a list of differences that you
  don't need to parse manually shooting your feet off in process.
* With improvements in PHP performance in the last 10 years, shelling out instead of using
  a pure-PHP diff has a doubtful performance benefit.
* Even in configurations where it's faster on predominant diffs (which have to be huge),
  shelling out has its own security implications.

This function is not used in core. The only extensons using it are Echo (which just parses
its output so would be better off with DiffEngine) and AbuseFilter, let's not add more users
by tolerating this function.

Also, add error checking while I'm at it.

Change-Id: Ia67debce39de8252312fd887ebfbe6fb89f9edc9
2015-03-25 21:19:32 -07:00
Kunal Mehta
8911a8d0b7 Send messages logged via MWLoggerLegacyLogger::log() to the debug toolbar
Bug: T93145
Change-Id: Ia96525faf4ffcbd2b5beae9716d6be009f2b6074
2015-03-18 23:57:47 +00:00
JuneHyeon Bae
511525a136 Refactor out 'infinity' variants
Refactor out 'infinity' vartiant values which used in blocking and
protecting actions. This patchset adds GlobalFunction wfIsInfinity.

Bug: T68646
Change-Id: I60cc55a5bbd43c72916a1c2ea3807457d4e33765
2015-03-12 16:38:02 +00:00
Ori Livneh
87dfc20b1e Add StatsD metric logging
This patch adds a metric data service object to the IContextSource interface,
with full support for StatsD meters, gauges, counters and timing metrics, via
the liuggio/statsd-php-client, which this patch also introduces.

Usage example:

    $stats = $context->getStats();
    $stats->increment( 'resourceloader.cache.hits' );
    $stats->timing( 'resourceloader.cache.rtt', $rtt );

The metrics are flushed to a StatsD server, which may be specified via the
'StatsdServer' configuration key. If no such configuration key exists, the
metrics are discarded.

The StatsD client supplants MediaWiki's StatCounter class. wfIncrStats()
will continue to work, but it will delegate to the StatsD data object.

Change-Id: Ie10db1c154d225971398e189737de7c560bf0f90
2015-03-09 16:57:14 -07:00
Yuri Astrakhan
7c75ee3976 Remove duplicate param escaping code
wfEscapeShellArg() can handle multiple params, escaping each.
This patch changes wfShellExec() to call wfEscapeShellArg() directly
instead of doing the gluing itself.

This patch also extends wfEscapeShellArg() to accept an array parameter
optionally instead of as separate args, which is often useful.

Added also unit test cases for single, multiple args, and single array args.

Change-Id: I7a0761cc2ba98c210a9eacadd12da407d933e42a
2015-03-05 17:06:04 +00:00
jenkins-bot
0bf1384b16 Merge "Made the "bypassCache" flag for file locator methods use the master DB" 2015-03-05 16:28:31 +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
jenkins-bot
1318ac9ac0 Merge "Profile wfShellExec() calls by caller" 2015-03-04 23:32:17 +00:00
Chad Horohoe
615d513f87 Profile wfShellExec() calls by caller
Change-Id: Ide437ec586b9e123ca73b5abd17278a72375dfb0
2015-03-04 15:04:45 -08:00
Chad Horohoe
9eefeaed6d Remove unused alias/layer of test abstraction wfShellMaintenanceCmd()
Change-Id: I28d303f9b89ffad052d06eb2dbb9e6f8cfaeea24
2015-03-03 22:15:52 -08:00
Chad Horohoe
9971834131 Delay language conversion cache construction until needed
Instead of instantiating this on every single request. Removes
wfGetLangConverterCacheStorage() and $wgLangConvMemc which were
otherwise unused.

Change-Id: Ic500944a92c2a94bc649e1b492c33714d81dca00
2015-03-03 21:12:28 -08:00
Elliott Eggleston
7d8f8ae84d Only need one check for is_dir
It implicitly includes file_exists test.

Change-Id: I25a6e609801455f2102d14035900248192e49f39
2015-03-02 18:38:16 +00:00
Brion Vibber
2922b7f34f Account for HiDPI variants in thumb.php rate limiting
If $wgResponsiveImages is on, include the 1.5x and 2x multipliers
in the wfThumbIsStandard() standard image size comparisons.

Change-Id: I79d866387730cdd4d7c7a976e691192b2335b7ce
2015-02-04 19:55:44 -08:00
Timo Tijhof
39ac4fa5a4 Move wfThumbIsStandard() to GlobalFunctions and add tests
Change-Id: Ife9c011a476a4022cd72d433497944cbd7258e67
2015-02-04 19:50:06 -08:00
Bryan Davis
56b70b61af Replace MWLogger with MWLoggerFactory
Time wounds all heels. During the code review for the PSR-3 logging
introduction, several people asked me why we needed a wrapper
for Psr\Log\LoggerInterface if the point was to use the standard. At the
time I was convinced that it would be better to introduce the dependency
via a wrapper class so that we could use the wrapper to patch over any
deficiencies that we might find in the PSR-3 API. After going on to work
on a project to disentangle other MediaWiki components from internal
project dependencies I have suddenly and clearly seen the error of my
ways.

We still need a logger factory as PSR-3 does not specify
a standard mechanism for creating Psr\Log\LoggerInterface instances. My
solution is to convert MWLogger into MWLoggerFactory to retain a static
factory interface for creating PSR-3 loggers but remove the MWLogger
wrapper class itself in favor of direct exposure of
Psr\Log\LoggerInterface to the MediaWiki consumer classes.

Change-Id: Ie47467657dcf341991ada00827dca5e8eff95438
2015-01-22 22:10:49 +00:00
jeroendedauw
ea9612e947 Document alternative to deprecated function
Change-Id: I89ae5f5062f8e3eb8dac38d7efcca7723d6b62b1
2015-01-21 01:30:14 +01:00
Brad Jorsch
7d91612411 Don't call $wgOut->disable() from wfHttpError if $wgOut isn't set up yet
For example, if the database cannot be connected to, the language is
something other than 'en', and the l10n cache is LCStoreDB, then the
call to Language::factory() in Setup.php line 604 will do it when it's
trying to get the fallback list.

Bug: T86398
Change-Id: Ia0e9ea440dcc4c8ab7bab1f33802aeff487eb3f0
2015-01-12 16:48:40 -05:00
Aaron Schulz
6921770414 Updated some try-catch statements: MWException -> Exception
Change-Id: I76601a86e30f4984e3b1a8c8ec5ef5a0f652433a
2015-01-09 17:20:22 -08:00
Kunal Mehta
bfe4ddd810 Implement extension registration from an extension.json file
Introduces wfLoadExtension()/wfLoadSkin() which should be used in
LocalSettings.php rather than require-ing a PHP entry point.

Extensions and skins would add "extension.json" or "skin.json" files
in their root, which contains all the information typically
present in PHP entry point files (classes to autoload, special pages,
API modules, etc.) A full schema can be found at
docs/extension.schema.json, and a script to validate these to the
schema is provided. An additional script is provided to convert
typical PHP entry point files into their JSON equivalents.

The basic flow of loading an extension goes like:
 * Get the ExtensionRegistry singleton instance
 * ExtensionRegistry takes a filename, reads the file or tries
   to get the parsed JSON from APC if possible.
 * The JSON is run through a Processor instance,
   which registers things with the appropriate
   global settings.
 * The output of the processor is cached in APC if possible.
 * The extension/skin is marked as loaded in the
   ExtensionRegistry and a callback function is executed
   if one was specified.

For ideal performance, a batch loading method is also provided:
 * The absolute path name to the JSON file is queued
   in the ExtensionRegistry instance.
 * When loadFromQueue() is called, it constructs a hash
   unique to the members of the current queue, and sees
   if the queue has been cached in APC. If not, it processes
   each file individually, and combines the result of each
   Processor into one giant array, which is cached in APC.
 * The giant array then sets various global settings,
   defines constants, and calls callbacks.

To invalidate the cached processed info, by default the mtime
of each JSON file is checked. However that can be slow if you
have a large number of extensions, so you can set $wgExtensionInfoMTime
to the mtime of one file, and `touch` it whenever you update
your extensions.

Change-Id: I7074b65d07c5c7d4e3f1fb0755d74a0b07ed4596
2015-01-08 01:40:01 +00: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
jenkins-bot
d34a6ca677 Merge "Fix some stuttering in comments and documentation" 2014-12-17 22:28:27 +00:00
Ricordisamoa
12dec5d85d Fix some stuttering in comments and documentation
Change-Id: I9c0088b9aab37335203cad45a1d6fa8ac3f43321
2014-12-17 19:44:10 +00:00
Bryan Davis
6aa3c4fe84 Logging related comment updates
* Pretty up some logging related comments.
* Send wfDebugLog messages to logger at info level

Change-Id: I97b8629095e8d6168dbeb791dfb5e7753d281cbe
2014-12-16 17:12:23 -07:00
Bryan Davis
6a8c686c7a Deprecate wfErrorLog
When a logging service other than MWLoggerLegacySpi is used, the
behavior of wfErrorLog is not guaranteed.

Change-Id: I8543bfd556aa752665f7a3daa855d3c2f7fc8956
2014-12-15 16:26:03 -07:00
Kunal Mehta
e27ae6b5ec Convert more wfRunHooks() --> Hooks::run()
Change-Id: I1b1e3cb6871721fc05dda881a8020c9a5d30a514
2014-12-12 14:47:31 -08:00
Bartosz Dziewoński
c819a558fe GlobalFunctions: Fix 'Undefined index' notice in wfBacktrace
Notice: Undefined index: line in
/var/www/wiki/includes/GlobalFunctions.php on line 1840

Caused by fc2e6df64f, previous versions
used isset here.

Change-Id: Ie9434f09e0905346ace19909fb316d47c75e0440
2014-12-12 21:35:36 +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
jenkins-bot
d8ab903223 Merge "Cleaned up LoadBalancer::getConnection" 2014-12-12 02:47:39 +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
52e6121447 Cleaned up LoadBalancer::getConnection
* It will also no longer call getReaderIndex( false, ... ) twice
* Removed various related ampersands

Change-Id: Ia79e2007dbf84e7437f9439aa6371333aa3e1b23
2014-12-10 00:27:48 -08:00
Chad Horohoe
52f3b13312 Remove Profiler::isStub()
Just check for ProfilerStub directly.

Change-Id: I503916599f182df4206da5282193ae6ec9324ee6
2014-12-03 20:19:56 -08:00
Bryan Davis
9be737caef Decorate deprecated functions with wfDeprecated()
Change-Id: Iaa7d11a9fdd1c68dc7ff1b3138fe8c9ba229cc69
2014-11-24 16:41:10 -07:00
Bryan Davis
2792ea9783 Add logging context to database logs
* Add optional $context parameter to wfDebug, wfDebugLog, wfLogDBError
  and wfErrorLog that will be passed to MWLogger.
* Add support for PSR-3 style log message parameter interpolation in
  MWLoggerLegacyLogger.
* Add context information to wfLogDBError calls made from DatabaseBase,
  DatabaseMysqlBase and LoadBalancer instances.
* Deprecate wfDebugTimer() which now appears to be unused.

Change-Id: Ic90d593d00a2b0b5b80ed205908cbe624042603c
2014-11-19 17:59:55 +00:00
Bryan Davis
0b91f622a3 Prettier wfLogProfilingData() log message
Make the profiler logging output introduced in Iae11e1e a little nicer.
Stop adding the Profiler::getRawData() information and add the URL and
textual report to the default log message. When testing with a Monolog
logger and Logstash the getRawData output from the Xhprof profiler was
found to be too big to be usable. The default message output was found
to be less informative than desirable when a PSR-3 logger other than
MWLoggerLegacyLogger was used. MWLoggerLegacyLogger implements special
backwards compatible formatting for the profileoutput channel that will
not be effected by this change.

Change-Id: Id326aed4f72a3489fac30661c101ac3bb3af2530
2014-11-17 10:41:49 -07:00
Bartosz Dziewoński
3e85dfb8ad Standardize indentation of multiline 'if'/'elseif' conditions
Always indent the continuation one level deeper, and always place the
closing parenthesis on the next line, per coding conventions.
https://www.mediawiki.org/wiki/Manual:Coding_conventions#Indenting_and_alignment
https://www.mediawiki.org/wiki/Manual:Coding_conventions#Line_continuation

Regexp used: (\t+)(if|while|\} elseif|foreach).+(?<![;}])\n\1\S

Also:
* Change to just one line if line length stays under 100 characters.
* Add "// Do nothing" comment in empty 'if' bodies.
* Change '#' comments to '//' comments near affected code.

Change-Id: I4f62658fddb5a0ed18bbf9b2231cd794683d6402
2014-11-17 15:33:34 +00:00
Aaron Schulz
fc2e6df64f Added wfLogDBError() call to LoadBalancer::doWait()
Change-Id: Ida0970754a2a7287c129bb5ad633765dab97133a
2014-11-13 21:34:54 +00:00
umherirrender
6f50f1bee5 Remove unused global in wfLogProfilingData
Change-Id: I873efb8967cd17c89de5b32fcde6c738eefa03e6
2014-11-07 14:33:24 +00:00
jenkins-bot
fd92d3cd5f Merge "wfDebugLog(): remove unused global" 2014-11-04 21:17:30 +00:00
jenkins-bot
19c2a08267 Merge "Use MWLogger logging for wfLogProfilingData" 2014-11-04 21:17:19 +00:00
Chad Horohoe
beea060441 wfDebugLog(): remove unused global
Change-Id: I336b022c7c87550729ca4e97b0960ba6adec7bb5
2014-11-04 13:06:10 -08:00
jenkins-bot
cc3b1d1e2c Merge "Fixed spacing" 2014-10-30 20:09:54 +00:00
Kunal Mehta
0e17070d40 Require PHP >= 5.3.3
Bug: T839
Change-Id: Iac827ef8505ff0653a40e45d759b0f79619351ee
2014-10-30 10:10:52 -07:00
umherirrender
2a7c95acda Fixed spacing
- Changed spaces to tabs for indentation
- space after 'function'/'if'
- Added/Removed space after parenthesis/brackets/end of line
- Removed space after cast

Change-Id: I0e8e6a19b84b5e1308b632a0266cb78f688494ee
2014-10-30 17:50:19 +01:00
Aaron Schulz
5e5bf769fe Fixed possible db error log spam when cluster=* in wfWaitForSlaves()
Change-Id: Idd385cddb0fa9f56bddc46d41ae584ca65bc45ed
2014-10-29 16:36:55 -07:00
Bryan Davis
3328bd9961 Use MWLogger logging for wfLogProfilingData
Output structured profiling report data from wfLogProfilingData using
MWLogger.

Requires Ie667944, I5c82299, and I1e5596d.

Change-Id: Iae11e1e4fe970ada74136f0e969dc624c586ce17
2014-10-29 23:04:09 +00:00
Bryan Davis
28a7ce420b Use MWLogger logging for legacy logging methods
Send wfDebug, wfDebugLog, wfLogDBError and wfLogDBError log messages to
the new MWLogger PSR-3 logger subsystem. Compatibility with the historic
logging operations of wfLogDBError are provided by MWLoggerLegacyLogger
and the MWLoggerLegacySpi logger factory.

Requires the MWLogger system introduced in I5c82299 and the Composer
managed libraries from Ie667944.

Change-Id: I1e5596d590144fbfdfd5f18bc42cf1ef0dbcac12
2014-10-29 11:55:08 -07:00
Aaron Schulz
dadaf48a39 Optimized wfWaitForSlaves() to get the master positions for all LBs first
Change-Id: I4a4aa6a3f68ace85dcbfb73e982a16c62e21e6ed
2014-10-22 10:56:36 -07:00
Aaron Schulz
91733632d7 Fixed loop in wfWaitForSlaves()
* The "break" statements should obviously be "continue" here.

Change-Id: Ia4a9bad77a9f512153aee6b77443104e71f5cd56
2014-10-22 10:32:48 -07:00
Aaron Schulz
6b2177bdc3 Made wfWaitForSlaves() support waiting on all clusters as needed
Change-Id: Icc45ae26fee655597ae1c437b5f774d7e84f643a
2014-10-21 14:35:42 -07:00
Yuri Astrakhan
df43a26e0a Minor doc fix for wfShellExecWithStderr()
Change-Id: I9d5fe442c6e85d61c1cdec8c42caab06b37856b1
2014-10-08 14:12:11 -04:00
Kevin Israel
4620e3b862 hash_equals(): Avoid division by zero when $known_string is empty
Per Tim Starling's review of Icb239471, reverted back to the version of
the function from Patch Set 1 of Iece006ec, which did not have the bug.
This version does not attempt to minimize the inevitable leakage of the
string's length.

Also revised the doc comment to explain more effectively what the problem
with a normal (===) string comparison is for the use cases of this function.

Follows-up b9e1d5f5c0.

Change-Id: I1b347e69b39af3d7d8ba6673af63f1a616befbdf
2014-10-07 06:42:12 +00:00
Anomie
8f0ed5f5a7 Revert "Replace wfMsgReplaceArgs by RawMessage"
This was merged too quickly, has several issues.

This reverts commit 6abefb274f.

Change-Id: Ibf3e464fa9eb534d599274dd9262a30d5a6a6948
2014-09-29 17:41:56 +00:00
umherirrender
6abefb274f Replace wfMsgReplaceArgs by RawMessage
The replace of $n params can also be done using the Message class. In
case there are no message keys, the RawMessage class is used.

Deprecated wfMsgReplaceArgs, but added no warning, because it is used in
some extensions and from deprecated functions

Change-Id: I62091b09e4490e59ed7258566e0ddf2f8ee799d2
2014-09-29 19:23:19 +02:00
Aaron Schulz
a55544180b Slave lag check tweaks to JobRunner
* Do not block forever, but wait up to 10 seconds. Likewise,
  check the lag times in memcached on startup. This at least
  lets runners avoid lagged wikis but still work on others.
* Made a few small related documentation and code cleanups.

Change-Id: Ic1339bab54cba6b6cbea7d97a80ff87c7c5c87af
2014-09-24 00:59:55 +00:00
Brad Jorsch
0011f2a77f Update wfMessage doc
The Message class constructor has long supported passing an array of
keys for fallback messages, and wfMessage passes the $keys parameter
through unchanged.

And since this is already in use in core, we may as well document it.

Change-Id: I8f7f9ade87e855300650b2e7e31b9303daa96ac5
2014-09-17 06:02:24 +00:00
Marius Hoch
fbc7206444 Prevent "Notice: Undefined index" in wfDiff
Change-Id: I4cc7d10021a114a2035dd2d9274c2340242800cb
2014-09-15 03:52:31 +02:00
Kevin Israel
5957856c46 wfBaseConvert(): Work around PHP Bug #50175
Before php/php-src@834daa455b, PHP's gmp_init() function would try
to autodetect hex and binary numbers even when a base was explicitly
specified[1], so the results for some base-36 numbers having leading
zeros could be incorrect. Work around this bug by trimming off any
leading zeros before calling gmp_init().

[1]: https://bugs.php.net/bug.php?id=50175

Bug: 69249
Change-Id: I5f5458c1a1195f55fa12904c103da6ea7558010a
2014-09-02 16:02:27 -04:00
umherirrender
51adb81e6e Add some @see to doc blocks
This avoids repeating the @params for the functions

Change-Id: Ie1f4488a0a7aa30ab128b9ea7ff6f3af12a88884
2014-08-24 11:19:32 +02:00
umherirrender
6b4c44c2db Add missing @param to function docs
Change-Id: Ib26407bc55dff7969d8a3b1e2ae51751b202d8fb
2014-08-18 16:24:59 +00:00
Aaron Schulz
cafcb6b225 Vastly increase how long wfWaitForSlaves() can block in CLI mode
* All maintenance scripts pretty much assumed this behavior, but it
  was not actually the case. This can avoid some massive lag problems.

Change-Id: I5894409d6abade16afd8144f6689c2aff3fa7327
2014-07-31 23:28:11 -07:00
withoutaname
aa21cbc5fb Remove global functions deprecated since 1.22
Specifically functions wfArrayLookup(), wfArrayMerge(),
wfDebugDieBacktrace() and wfTime() from GlobalFunctions.php.

Change-Id: I9339cb2d8da41953a0e2a051452298f480256ebc
2014-07-31 00:25:05 -07:00
umherirrender
1c68a1ee86 Cleanup some docs (includes/*.php)
- 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: I783e4dbfe5f6f98b32b9a03ccf6439e13e132bcc
2014-07-24 19:42:24 +02:00
umherirrender
4ee680a8b3 Fixed spacing
- Removed spaces after not operator (!)
- Removed spaces inside array index
- use tab as indent instead of spaces
- Add newline at end of file
- Removed spaces after casts

Change-Id: I9ba17c4385fcb43d38998d45f89cf42952bc791b
2014-07-24 11:53:04 +02:00
Yuri Astrakhan
d1d6cb7bc3 Allow wfShellExec() to use an array as a command prompt
Command line may now be given as an array, where each value
will be escaped and glued together with a space.

Change-Id: I9237ec1fccc60c0c4a360562db1c050a3be7e6a3
2014-07-24 05:00:37 +00:00
Max Semenik
9f522988b8 Fix race condition in wfShellExec()
Especially when executing commands that return a relatively lot of data in stdout
quickly, proc_get_status() may return that command has terminated before everything
has been read from pipes. Handle this case by continuing to perform
non-blocking select on the process's streams until all remaining data has been
read.

Bug: 67870
Change-Id: I050292dbb76821f66a15f937bf3aaf4defe67687
2014-07-21 23:21:23 -07:00
Kevin Israel
d3b172af3b Remove Fallback::iconv()
The iconv fallback is, for the most part, a remnant of PHP 4 support.
Though iconv was not enabled by default in PHP 4, it is in PHP 5. This
is the case even for Windows builds, which use GNU libiconv.

As for the major Linux distributions:

* Debian, CentOS, Ubuntu -> always enabled
* Fedora, Slackware -> .so in the same package, enabled by default
* Arch -> .so in the same package, disabled by default
* openSUSE -> separate package

Change-Id: Ie1112a5742646a0e1f951e188480c23851859320
2014-07-21 00:36:22 -04:00
Aaron Schulz
92e0d0f927 Added a hasMasterConnection() method to LoadBalancer
* Made wfWaitForSlaves() use it instead of using isOpen() incorrectly.
  The index for the master is 0, not DB_MASTER. This fixes 2979f0b6.

Change-Id: I48e5c7f10d8fe6b8bf6e830282352e3238b5d3ae
2014-07-19 16:19:43 -07:00
Aaron Schulz
2979f0b6f1 Avoid useless delay and master connections in wfWaitForSlaves() in runJobs.php
* Some jobs, like Parsoid ones, do not actually do master DB updates

Change-Id: I1a8830eafd7760d081df966bb423030dcdc96408
2014-07-19 15:19:40 -07:00
withoutaname
a5ed84d4d9 Remove deprecated global function wfViewPrevNext()
Deprecated since 1.19, alternative is Language::viewPrevNext().

Change-Id: I26d8dec1475ac3f6592f8d0ef7936440c1a0f14d
2014-07-18 21:20:00 +00:00
jenkins-bot
358f2a07c6 Merge "GlobalFunctions: Deprecate swap()" 2014-07-10 00:50:28 +00:00
jenkins-bot
02f10d2bdd Merge "Deprecate wfCheckLimits(), nothing calls this anymore" 2014-06-26 15:34:38 +00:00
jenkins-bot
add089c254 Merge "Only use limit.sh if /bin/bash executable, instead of if linux." 2014-06-25 21:53:56 +00:00
Kevin Israel
74e6ce4fd6 Don't parse disable_functions INI value
In wfDebugBacktrace() and wfShellExecDisabled(), use function_exists()
instead of getting the value of the disable_functions INI setting,
then splitting it into a list of functions, then checking that list
for the function to be called.

Also removed the check for Zend Optimizer, an old PHP extension that
does not work with PHP 5.3.

Change-Id: I04f0e026f8a6e0414f08d5302aff6c084a1d19a7
2014-06-25 20:24:28 +00:00
Chad Horohoe
85d7e6203f Deprecate wfCheckLimits(), nothing calls this anymore
Some old things in SVN called it, hence the deprecation.

Change-Id: Iefabd1a6bee261a393f3b1af083c8a075abf1e48
2014-06-25 11:22:39 -07:00
rillke
548b7de4dd Typo in documentation: wgMaxShell not wgShellMax
Change-Id: I02f2437c33e87ea389e4bbb753af0c6cc18b4410
2014-06-23 15:02:37 +02:00
Kevin Israel
476b532f15 Fix copy-paste error in wfIsConfiguredProxy()
It should call IP::isConfiguredProxy(), not IP::isTrustedProxy().

Follows-up e323bc3393.

Change-Id: I3caf8261f6058aa1a243c055b746b2fa61b1bf49
2014-06-20 01:27:33 -04:00
Brian Wolff
3e108ea4d8 Only use limit.sh if /bin/bash executable, instead of if linux.
gute on irc just mentioned how his BusyBox server identifies as
linux but doesn't have bash installed. Additionally I see no
reason to limit limit.sh to linux, if for example somebody has
installed bash on a different *nix.

Change-Id: I51677295ab6bbc58fc5152106cf2c4c32bd1b0ea
2014-06-19 22:13:48 -03:00
Kevin Israel
26e1e083e8 GlobalFunctions: Deprecate swap()
This unprefixed function, added in r7198 (2b3f4c749d3d), has been
unused since r12411 (f2a59db33f).

It is short and simple enough that on the rare occasions it is needed,
it can be inlined or copied into the calling class as a private method.

Alternatively, the idiom `list( $a, $b ) = array( $b, $a )` can be used.

Change-Id: Ieb4602597a54eb21a5de177fee6dafa7ac71ce1d
2014-06-18 02:31:03 +00:00
Kevin Israel
b9e1d5f5c0 Add hash_equals() fallback and use it
Two classes (User and SpecialRunJobs) currently contain string
equality checks that purport to be timing-attack resistant.

Reduce code duplication by adding and using a fallback for the
hash_equals() function from PHP 5.6 (currently in beta), in a way
addressing the comment "@todo: make a common method for this".

Change-Id: Iece006ec0216edb3fc5fbef7cc6ec00a6d182775
2014-05-28 20:52:08 -04:00
jenkins-bot
4f42c2bbe4 Merge "Make HTTPS port configurable" 2014-05-23 22:47:03 +00:00
Sergio Santoro
9736bf082c wfDebugMem: Fix binary prefix and improve usability
* Fix: wfDebugMem no longer reports kibibytes as kilobytes
* Usability: wfDebugMem now uses unit symbols (e.g. KiB)

Change-Id: I1ab8aa3ccdb0fdea307913ada4ed42964d7fe960
2014-05-22 16:22:12 +02:00
awjrichards
86f68d31d3 Make HTTPS port configurable
Introduces wgHttpsPort configuration variable and makes use of it when
appropriate in wfExpandUrl()

Bug: 65184
Change-Id: I325ee0ff7be16de2a964fb7d8654b88cbd5fe239
2014-05-19 13:23:13 -07:00
Brandon Black
e323bc3393 Speed up CIDR matching from $wgSquidServersNoPurge
This adds a new generic library class IPSet, which precomputes
a reasonably-efficient data structure from the input list of
addresses and CIDR net/mask specs for fast runtime matching,
and then uses it to check trusted XFF-setters.

See also: 32b4f19f173fc5cff1029eedee63a39a2d72dd3a
Bug: 57021
Change-Id: Ia3b12fb90c3e7e492374a128943b014481cc2730
2014-05-15 17:23:12 +00:00
Bartosz Dziewoński
c3aa5ef597 Create Parser::stripOuterParagraph to avoid code duplication
We've had the logic for stripping the outer <p/> element in three
separate places. The version in OutputPage was missing the '$' at the
end of the regex, that was most likely a mistake caused by the
duplication.

Also, extend the logic in order not to generate invalid HTML if the
input contains more than one <p/> tag. Added tests for this and the
previous behaviour.

https://www.mail-archive.com/mediawiki-api@lists.wikimedia.org/msg03188.html

Change-Id: I6bb3597898324556df912a23a7ffc9ff250b8f58
2014-05-15 12:20:19 -04:00
Siebrand Mazeland
e9eb00b203 Make phpcs-strict pass on includes/ (1/~10)
Change-Id: Ib51381a2261d064988ba2f39b71c0252f2458faf
2014-05-11 19:14:17 +00:00
umherirrender
5a93df2fba Fix some @params documentation in includes/{GlobalFunctions,User.php}
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 capital.

Change-Id: If8c0cf4627fc62ff288d33658e327ae80548f5c5
2014-04-23 09:53:38 +00:00
Bartosz Dziewoński
59002d8935 Consistently use '@deprecated since <version>'
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
2014-04-15 22:18:19 +02:00
Aaron Schulz
1f19a345bc Revert "Work around HHVM bug with stdin/stdout in proc_open()"
This was fixed in HHVM (https://github.com/facebook/hhvm/issues/1247).

This reverts commit 52e546640c.

bug: 56597
Change-Id: I9c97ba5645d794ff562347979e3f2027eb8b4534
2014-04-11 22:07:19 +00:00
Ori Livneh
b20f740e38 Convert <!-- timing data --> to a <script></script> block
This patch replaces:

  <!-- Served by mw1069 in 0.976 secs. -->

With:

  <script>mw.config.set({"wgBackendResponseTime":976,"wgHostname":"mw1069"});</script>

In the default HTML output of MediaWiki.

While the latter is a nearly twice as long, it is almost as readable for human
beings, while being substantially easy to get via JavaScript.

To get the values from the comment, you have to do something like:

  var comments, comment, hostname, duration;
  comments = $.grep( document.body.childNodes, function ( el ) {
	return el.nodeType === 8
  } );
  comment = comments.length
	? comments.pop().nodeValue.match( /(\S+) in ([\d.]+)/ ).slice( 1 )
	: [ null, null ];
  hostname = comment[0];
  respTime = parseFloat( comment[1] );

On the other hand, to get the values from the JavaScript code, you can simply:

  var hostname = mw.config.get( 'wgHostname' );
  var respTime = mw.config.get( 'wgBackendResponseTime' );

I believe that the ability to parse the number easily via JavaScript will make
it easier to include with other client-side measurements as part of reports on
site performance as experienced by users.

Change-Id: I895cd03f0968815484ff8cda4b23cc602ac555f0
2014-04-07 21:39:08 +00:00
Alexandre Emsenhuber
d966a5266f Send the profiler output to the 'profileoutput' log group
And deprecate $wgProfileOnly in the same time.

This has the advantage of allowing profiler output to be separated
from the main debug log file; or even be completely disabled while
keeping the other debugging messages.

Also updated the checks in wfLogProfilingData() to detect the cases
where the output would not be sent anywhere to not execute the
last part of the method which would be useless otherwise.

Backward compatibility with installations having $wgProfileOnly
set to true is kept by moving the log file from $wgDebugLogFile
to $wgDebugLogGroups['profileoutput'] in Setup.php in that case.

Change-Id: I7b35195e527dfa7978b710126ed4599e75dab46b
2014-03-28 07:39:08 +01:00
Thiemo Mättig
d0b400476e Fix/update inline documentations in GlobalFunctions
I mainly fixed PHPDoc comments that are highlighted by PHPStorm
as being wrong or incomplete.

* Fixed some wrong inline documentations, e.g. wrong @return types.
* Used the style suggested by the Doxygen and phpDocumentor
  documentations: @param type [$optional,...]
* Doxygen and phpDocumentor suggest the order: @param type $var
* Avoid unclear "varargs" and "mixed" if possible.
* Lowercased "array" and such, they are no classes.

Change-Id: Iff16e05fed6652cefec29e3d254807f52d84c9ab
2014-03-26 14:40:25 +00:00
Alexandre Emsenhuber
9cfd31a708 Remove wfDebugLog() call from wfSetupSession()
Since Iffba121a99 (00b7f76) with the removal of wfHttpOnlySafe(),
session cookie's parameters are based only on configuration
settings, so there is no point to spam the "cookie" log group
with predicitible values.

Change-Id: I8b1cdea929cefc32dd8b01c2ecbf2d76bb64189f
2014-03-25 19:41:18 +01:00
jenkins-bot
453ee14fe1 Merge "Remove $wgHttpOnlyBlacklist" 2014-03-25 13:13:34 +00:00
jenkins-bot
3e326854f2 Merge "Fix documentation of wfDebugLog()" 2014-03-25 07:19:54 +00:00
Alexandre Emsenhuber
59c42b90d5 Automatically add a new line at the end of wfLogDBError()
I found two calls to wfLogDBError() that do not add a new line
at the end of the message. So instead of adding them to that
entries, I changed wfLogDBError() to automatically put it on
icoming messages; as for wfDebugLog().

Change-Id: Id014b5827a0aeef6873ebf08d78f0a3d7581d63b
2014-03-23 10:30:59 +01:00
Alexandre Emsenhuber
1edba2526d Fix documentation of wfDebugLog()
- $public parameter does not exist anymore
- Put the type before the parameter name

Change-Id: I0f3a893803ab5466570ef45398f797e4714d9d37
2014-03-23 10:17:48 +01:00
Kevin Israel
00b7f76aaf Remove $wgHttpOnlyBlacklist
This hack was added in r34083 / 6b16f44108 to support IE for Mac.
That browser is no longer supported, and no additional user-agent
strings have been added in WMF configuration.

Change-Id: Iffba121a9964e2ad387fad8827ddfd8dabcbd12e
2014-03-20 21:19:08 -04:00
Alexandre Emsenhuber
19084be0a2 Allow to disable specific groups in $wgDebugLogGroups
So that they don't even appear in $wgDebugLogFile.

Change-Id: Ibf1a28fa566915d790e4d915354238441c3ff5c7
2014-02-26 20:46:14 +00:00
Alexandre Emsenhuber
8d701eeeea Remove trailing line breaks from wfDebugLog() messages
This is useless since the message is passed through trim() and a
line break is added afterwards.

Change-Id: I1a26b30a07f7c9c749fce5bb6b2b4b3d79901b7c
2014-02-04 22:16:13 +01:00
Alexandre Emsenhuber
a7a0883019 Enhance the destination control parameter of wfDebug() and wfDebugLog()
- The parameter is now a string, making is more understandable than
  boolean values
- It takes the same values in both wfDebug() and wfDebugLog() (except
  for 'private' which is only used in the latter)
- This adds a new possibility to wfDebugLog() to log the message either
  on the specific log or the general one, but not to the debug toolbar
- Old boolean values are still recognised for backward compatibility
- Also send the messages passed to wfDebugLog() to the debug toolbar
  when they are written to a specific log and not restricted to logs
- Updated the calls of and wfDebug() and wfDebugLog() with the last
  parameter to change it into a string
- Renamed MWDebug::sendWarning() to MWDebug::sendMessage() and added
  $group parameter to it; will not break anything since that method
  is marked as private
- Changed the call to wfDebug() from MWDebug::sendMessage() to use
  wfDebugLog() with 'log' as thrid parameter, so that those messages
  can be logged separately from the main log and they don't show up
  a second time on the "debug log" tab of the debug toolbar

Change-Id: I1be09d4c1d3408ed5b26a5db02691c17c0ec0926
2014-02-04 19:56:24 +00:00
Siebrand Mazeland
118567a4ba Remove some deprecated global functions
Some uses remained in Gerrit extensions, and patches have been submitted
to replace the usages. See below for details.

* in_string (deprecated in 1.21)
* wfGenerateToken (deprecated in 1.20) (had 2 uses)
* wfStreamFile (deprecated in 1.19) (had 1 use)
* wfUILang (deprecated in 1.18)

Change-Id: Ic67a968da8f37daf44503b98d00710eb99180805
2014-01-23 01:38:27 +01:00
aude
5963aa7ed7 Add ability to mark hooks as deprecated
Change-Id: I8fd29e97a2b5d02746b572a9c315fbe54faf36f2
2014-01-10 09:12:26 +01:00
Siebrand Mazeland
903a77b569 Update comment for wfMsgExt()
Change-Id: Ia705a5a1bcef6d2b5c94a003b44e7d15b58df249
2014-01-01 15:25:39 +00:00
umherirrender
44495315c2 Fix typo - fuction -> function
Change-Id: I5a82849af85296b324d460ed21d9a547c391d341
2013-12-30 18:48:11 +01:00
Aaron Schulz
6640bdf0d8 Removed deprecated functions and merged ProxyTools into GlobalFunctions
Kept wfGetIP() for now because it is still in use in the SecurePoll
extension and in WMF configuration.

Change-Id: Id412e37743f89bb67eb329a2f475f8496cf7b006
2013-12-16 12:54:16 +00:00
umherirrender
661c5c3f01 Fixed spacing
- Added space after foreach
- Added/Removed spaces inside arrays

Change-Id: Ia8775824fa33976b1a4dab43e07f1bff0c57479c
2013-12-08 20:31:47 +01:00
umherirrender
0bc583af2c Move closing parenthesis from multi line if and function to own line
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
2013-12-01 21:39:00 +01:00
Niklas Laxström
24c89161b4 Fix variable name in comments
Change-Id: I2fbe47f7843c40b2806ba40b031a6047715db5f3
2013-11-24 10:03:38 +00: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
Yuri Astrakhan
5aa7c747ad Logic optimization for wfExpandUrl()
removed redundant checks of the same variable, making the code
slightly more efficient

Change-Id: Ice4d3c45e80ca1214e2c36444baf0ce87b15a59b
2013-11-16 14:55:08 -05:00
Chad Horohoe
52e546640c Work around HHVM bug with stdin/stdout in proc_open()
Bug: 56597
Change-Id: I06122d82fce4567be110ca25010c244dd9269c57
2013-11-08 04:48:04 +00:00
Chad Horohoe
5ff5bcfde7 Remove unused function
Change-Id: I68ad2093c08adba2a92344c7db0737c10db9d150
2013-11-06 16:19:38 -08:00
Chad Horohoe
dbab8a83d5 Remove unused function
Change-Id: I6a1386077282cbf8faf7b35311cd886e939c76a8
2013-11-06 16:18:54 -08:00
Chad Horohoe
f3d6db5843 Remove unused function
Change-Id: I51975357c91295f757532ff219a8db8ca939ba0c
2013-11-06 16:09:42 -08:00
jenkins-bot
fb0db00b92 Merge "Introduce WebRequest::getProtocol()" 2013-11-06 17:23:01 +00:00
Tim Starling
8af1c9503d Introduce WebRequest::getProtocol()
The use of static server detection outside of its intended use case
(i.e. at the start of DefaultSettings.php), for example in r93258, was
an architectural error. Every other bit of information about the web
request in non-setup code comes from non-static methods of WebRequest,
which allows the request object to be meaningfully replaced or
subclassed. The situation became increasingly ridiculous as more
callers of WebRequest::detectProtocol() were introduced. Two of the
callers were calling it non-statically! I suppose they had the right
idea, in a way.

Using a non-static call allows caching, which is a nice additional
benefit.

WebRequest::detectProtocolAndStdPort() was introduced in r93258 as part of
the introduction of WebRequest::detectProtocol(). It was basically
useless. Grep indicates there was only one caller in core and WMF
deployed extensions, and it is patched here.

Change-Id: Ia0a61e98fbff7a46ceaeebcb02236e5eac3df0e1
2013-11-06 21:13:10 +04:00
Ori Livneh
edac6c3716 Release notes & comment fix for Ib0ece5d5d
Adds release notes and fixes two inaccurate comments added in Ib0ece5d5d
("Configurable log sampling via $wgDebugLogGroups").

Change-Id: I224a0319b7432300d3cb6f4d14e61ea9d36ee228
2013-11-05 12:22:35 -08:00
Ori Livneh
2c25e14642 Configurable log sampling via $wgDebugLogGroups
Make it possible to configure a log-group-specific sampling factor by allowing
$wgDebugLogGroups values to be associative arrays with 'destination' & 'sample'
keys.

The immediate use-case I have in mind is the memcached log, which is too
verbose to enable in production. We could sample on the receiving end, but
doing so would not help MediaWiki, which would still be on the hook for
processing and dispatching every single record.

Idea was vetted by Dr. Manhattan:

<TimStarling> I think you could have each element in $wgDebugLogGroups be an
  associative array
<TimStarling> e.g. array( 'sample' => 1000, 'target' => "$host:$port")
<TimStarling> that would allow for more features to be added to it in
  future

Change-Id: Ib0ece5d5d9c2aadef13b77ac38995b0e47ac086f
2013-11-05 11:49:42 -08:00
jenkins-bot
853c6852ec Merge "Rename wfIsHipHop() to wfIsHHVM()" 2013-11-04 18:32:39 +00:00
Siebrand Mazeland
e61cb8218b Update docs and declare visibility on class props
Change-Id: Ib0f02202d075d4a56dc4e37b08d7ac9399e8c86c
2013-11-01 12:35:27 +01:00
jenkins-bot
a46b589d88 Merge "Add clarification to wfUseMW() phpdoc" 2013-10-31 19:21:38 +00:00
Kevin Israel
8bd6f698cc wfShellExec: Work around PHP 5.3 stream_select() issue
Follows-up e53af95c93.

Bug: 56360
Change-Id: I66f2dc8a2f43236799c23f6e25bbbd0a440f4283
2013-10-29 21:56:38 -04:00
jenkins-bot
51f2a693af Merge "Improve logging for wfShellExec() and ignore missing cgroup" 2013-10-29 22:42:17 +00:00
Chad Horohoe
22dca6484f Rename wfIsHipHop() to wfIsHHVM()
The former is only really used to refer to the older hphp compiler.
Now all docs pretty much exclusively are referring to HHVM and
that's the project's name going forward.

While we're here, swap HPHP_VERSION for HHVM_VERSION. Either work,
but the latter is more correct.

Only affected extension (in Git or SVN) is GWToolset, fixing in
I3a490ef.

Change-Id: I81e4ce5d14e344e67045050261f91b3c0159f222
2013-10-29 15:36:10 -07:00
Tim Starling
e53af95c93 Improve logging for wfShellExec() and ignore missing cgroup
Allow limit.sh to log its errors to an MW debug log channel, by opening
a separate FD for private communication.

Ensure that the log FD is always closed (3>&-) before executing a
subprocess, so that MW will not hang waiting for background processes
to close the log FD. This means using a fixed FD number, since the bash
syntax for closing a file requires a literal FD number.

The "exec" debug channel is now intended for production monitoring. In
addition to errors from limit.sh, it also records when a subprocess is
terminated by a signal.

The case where stream_select() returns false was tested by patching PHP
to inject EINTR or EBADF into errno.

When wfShellExec() is used with a memory cgroup, and the cgroup is missing, log and continue with no cgroup instead of immediately exiting.

Bug: 55709
Change-Id: Ie40befe9c0d00c9a0ddb01077df4afb774d17e15
2013-10-28 21:14:09 +00:00
Bryan Davis
33ffbd7f00 Add clarification to wfUseMW() phpdoc
While reviewing Ia5a7661c I happened to stumble in to the dark labyrinth
of PHP's version_compare() function. This comment attempts to leave
bread crumbs behind for the next unwary adventurer who stumbles into the
same damp cave.

The tricky bit is that when '1.22wmf22' is compared with '1.22'
internally it is as though you are comparing '1.22.wmf.22' with
'1.22.0.0'. By the component-wise comparison then performed 'wmf' is
considered the lowest priority value that could be in the third
position. When using '1.22c' for the required version the 'c' is given
the same lowest priority as 'wmf'.

Change-Id: I58aeb8dc6b1ff31897d72eb44904d96487ad3653
2013-10-28 14:00:34 -06:00
jenkins-bot
99362c6add Merge "Fixes for duplicateStderr (I833aeb3a)" 2013-10-22 02:34:27 +00:00
Tim Starling
b071c709d8 Fixes for duplicateStderr (I833aeb3a)
* Separate code from data. $2 in limit.sh is an option list.
* Don't duplicate stderr on linux when limit.sh is not used, unless
  duplicateStderr is specified

Change-Id: I8e6e74810864830c12af627bfbe75e74ba34e3e3
2013-10-21 15:18:04 +11:00
Erik Bernhardson
0f33c14576 Remove 'Debug' hook from wfDebug and wfDebugLog
Per the bug report, the 'Debug' hook was triggering an infinite loop when
wgDebugFunctionEntry is enabled.  The Debug hook is used if an extension wants
to stop a debug message from being sent out.  Ideally the wfDebug and related
functions should be as low-level and avoid calling other code as much as
possible to avoid situations like this.

Bug: 55818
Change-Id: I679782489b683503fc624cfea3c7ad72a989b005
2013-10-17 15:45:05 -07:00
Chad Horohoe
d0c8ba037c Remove wfDl() and cleanup everything it touched
wfDl() is a wrapper around dl(), which is an evil function and
basically only works from the command line of Zend. Luckily
no extension has ever used this thing, so let's just remove it
outright.

For comparison, here's a list of places it does not work:
- hhvm
- php as apache module
- php compiled with zts support
- safe_mode
- Basically any shared host that cares about security

Most callers are using it to check for extension support and are
actually failing gracefully when wfDl() returns false. In these
places we're just going to use extension_loaded().

While we're at it, clean up some of the test skip logic in the
media tests so we can bail as early as possible if we know we
can't complete the test.

This also immediately removes $wgLoadFileinfoExtension. It's been
enabled by default since 5.3 and falls back gracefully when the
support isn't available.

Change-Id: Ieb430dfc74483731dde51d6e20fa700d641ba1f4
2013-10-09 10:51:35 -07:00
Kevin Israel
93d0572d76 Use HPHP_VERSION constant to detect HipHop
Follows-up Ic3e769f1fbad4f7ad26dd819406796fee48c6b45.

Change-Id: I0210002c05efd79242b00592639b7be50a79020b
2013-10-03 02:33:27 -04:00
Chad Horohoe
6ed4f857eb Remove wfSpecialList()
Has been deprecated for several releases, nothing in Git or SVN
uses it.

Change-Id: I899a0a76a5cb23686caaf6fd244f926a6938fe77
2013-10-02 14:44:24 -07:00
jenkins-bot
591f756dc5 Merge "Add way of including all stderr output when executing command" 2013-09-30 16:03:24 +00:00
Brian Wolff
37e32abb0e Add way of including all stderr output when executing command
This adds an option to wfShellExec (and convenience function
wfShellExecWithStderr), to make sure all stderr is duplicated
to stdout. The previous method of doing this was to include
2>&1 on the command line. However this did not redirect errors
from limit.sh (For example cgroups not set up, or if a command
reached the file size limit set by ulimit).

Not sure if this is the best approach, but it seems to work well,
and compared to most other approaches I considered, actually gets
the ulimit errors redirected too.

Currently some files fail to render with no error whatsoever,
hopefully this patch will make what went wrong more obvious.

Also fix a comment in wfShellExec that was incorrect (trailing \n),
and make the initial value of the return value variable be 200, so
if there's ever a bug in php where its not being set properly, it
would be immediately obvious what is happening.

Bug: 53824
Change-Id: I833aeb3ab9da726ecb97331369ea187daad7e795
2013-09-28 17:48:37 -03:00
jenkins-bot
1bea3da95b Merge "Deprecate wfDebugDieBacktrace" 2013-09-28 04:44:50 +00:00
Kevin Israel
725df97b1b Deprecate wfDebugDieBacktrace
Change-Id: I12336983e29524a450fc61ed9df4d840066be9b6
2013-09-27 19:57:41 -04:00
Reedy
994bf115a7 In wfArrayDiff2_cmp only compare $a and $b as string if they both are strings
Noticed during bug 54662

Warning: strcmp() expects parameter 2 to be string, array given in
/usr/local/apache/common-local/php-1.22wmf19/includes/GlobalFunctions.php on
line 127

Bug: 54662
Change-Id: Icdd7fa229e49d7e83aa2a7992895f497806448e1
2013-09-27 20:15:21 +01:00
Brad Jorsch
b670b6de3a Improve wfEscapeWikiText, part 2
The following are now correctly escaped:
* Blank lines (including those with only tabs)
* ---- at the start of a line

Bug: 53658
Change-Id: I300e15a22c93ca542913135c9c83913c18c99faf
2013-09-20 12:51:02 -04:00
Timo Tijhof
f72117e768 Add gzdecode fallback to GlobalFunctions
* Follows-up I6383e933b.
* Replaced existing usage of `gzinflate( substr( $data, 10, -8 ) );`
  with `gzdecode( $data )`.

Change-Id: Ie2916584f92ff72c7d7ddca73acf1c94dda38cca
2013-09-18 00:04:31 +02:00
Elliott Eggleston
f0ea8fdfb9 wfMkdirParents: recover from mkdir race condition
If mkdir fails, check again to see if dir has been created
since our initial check, and return true if so.

Also, in initial check, only return true if $dir is really
a directory, not a file.

Bug: 49391
Change-Id: I2b331669fae70948ce79ba1477c05968a3095c3d
2013-09-12 23:43:45 +00:00
jenkins-bot
46f74ea958 Merge "Add plain semicolons to wfEscapeWikitext()." 2013-09-06 18:01:14 +00:00
Liangent
01240e5eb4 Add plain semicolons to wfEscapeWikitext().
It's a part of language conversion syntax, even when not used at
beginning of lines.

Change-Id: I848b6d13096887d51618f2694da93b6d65c0376e
2013-09-05 19:30:51 +00:00
jenkins-bot
edb4ed713c Merge "No spaces after (casts)" 2013-09-04 18:14:05 +00:00
MatmaRex
df8ec1e216 No spaces after (casts)
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
2013-09-04 20:05:43 +02:00
Brad Jorsch
a2f7598911 Improve wfEscapeWikiText
The following are now correctly escaped:
* Space at the start of a line
* Start-of-line characters after \r
* Magic links such as "RFC 123" with non-space whitespace
* URIs that don't use "://", such as "urn:foo"
* Double-underscore magic words

Bug: 53658
Change-Id: Ie8803a03b20e3fd7e5cc7e55829f24bb86f60b17
2013-09-03 17:36:13 -04:00
umherirrender
24bfde2710 Fix spacing and break some lines
Change-Id: Ia57685d8858e02e399ad5c75ce64d12609d340ac
2013-08-24 17:06:25 +02:00
Tim Starling
f0b346d6d0 Core support for disabling HTTPS based on GeoIP
* Introduce a hook allowing automatic redirects to HTTPS to be
  disabled on the basis of client IP address.
* Make User::requiresHTTPS() return false if the client IP is
  blacklisted as such.
* On login, make the "stick HTTPS" option default to false if the
  client IP address is blacklisted as such.
* Do not redirect anonymous requests to HTTPS.
* If $wgSecureLogin is enabled, link to the HTTPS login page *via*
  the HTTP redirect, so that there is no need to vary the cache of
  anonymous page view HTML on client IP address.

Change-Id: Iaa9dd2108431b8c35e05db4bfe78a629018a003c
2013-08-21 13:43:46 +10:00
Kevin Israel
b345e2492b Make wfReadOnly() a wrapper around wfReadOnlyReason()
This makes more sense than having wfReadOnlyReason() call
wfReadOnly() for its side effect of setting $wgReadOnly
to the contents of $wgReadOnlyFile if the file exists.

Change-Id: Ic723aed368915ac3757f3100ddbbeb3b5a4cdc15
2013-08-13 04:42:24 +00:00
Brad Jorsch
136861fe3a Add wfResetSessionID()
The code for changing the session id cookie from Special:Userlogin is
also needed in CentralAuth. So let's factor it out to avoid code
duplication.

Change-Id: I777f76ee8e2b953a1e972327bedc28e0ab1acf0d
2013-08-07 23:18:46 +00:00
jenkins-bot
af94bc9c69 Merge "Make wfForeignMemcKey consistent with wfMemcKey" 2013-08-03 05:20:17 +00:00
Erik Bernhardson
213fe05330 Make wfForeignMemcKey consistent with wfMemcKey
The wfMemcKey function converts any spaces in the key into _, while
the wfForeignMemcKey does not.  As such they would not return the same
key in certain corner cases.

Change-Id: I520dacdce953414dee5907324c2c98db858bcd42
2013-08-02 16:50:05 -07:00
Kevin Israel
c2d0b90633 Make wfMatchesDomainList not match partial domains
Change-Id: I90e7af152fbd9bb8d84d5f2c54bd352b461c530d
2013-07-28 11:18:38 +02:00
Kevin Israel
052f1fcf30 Deprecate MWFunction::call and ::callArray
These functions existed to work around a bug (fixed in PHP 5.3) and
a missing feature (added in PHP 5.2) in older versions of PHP;
therefore, they are no longer necessary.

Change-Id: Ifebbe3d449fc57fd83f8350c28f467605c1a07b7
2013-07-19 18:48:51 -04:00
Kevin Israel
8ea3dc7faa Deprecate a few one-line global functions
Additions to the PHP language made these redundant.

* wfArrayLookup() is similar to PHP 5.1's array_intersect_key()
  yet has serious limitations. For example, integer string values
  are implicitly cast to integers.

* wfArrayMerge() can be replaced by PHP 5.3's array_replace().

* wfTime() just returns microtime( true ).

Change-Id: I2c6844fc48a265d2d885083b5bed8df846e0aaf4
2013-07-05 21:06:11 -04:00
Liangent
c5e3c3ffc2 Drop a code path in wfBCP47() which is never reached.
count( $codeSegment ) > 0 should be never true in a foreach loop of
$codeSegment itself. See also Iffe166f3.

Change-Id: I453b5ec3379951a2ad6e34b9835907c2eba3046b
2013-07-01 20:50:19 +00:00
physikerwelt
63df600442 (Bug 48952) Show debug output in toolbar
The debug output written with the function wfDebugLog should  be
printed to the debug toolbar in the same way as wfDebug does.

Change-Id: Ib979df080332e16c8e0e6a89eab8741986ab39c3
2013-06-13 05:26:24 +00:00
Antoine Musso
8bfe2518f7 wfIniGetBool: reduce strtolower() calls
We were calling strtolower() up to three times. As a micro optimization,
call it once around ini_get() and do the logical checks against the
variable containing the lower case output.

Change-Id: I16c149fbb9de84d7b6f3e68da06de208c5572b7c
2013-05-29 10:51:01 +00:00
Daniel Friesen
97caae596d Drop support for XHTML 1.0
* $wgHtml5 = false; is now ignored completely.
* $wgDocType and $wgDTD have been removed.
* $wgXhtmlDefaultNamespace is now ignored.
* XHTML5 will be output if $wgMimeType is set to an XML mime type (according to HTML5's rules).
* For backwards compatibility with extensions $wgHtml5 and $wgXhtmlDefaultNamespace are set
  in Setup.php but depending on them is deprecated.

Change-Id: Iad9634e2ee420b5a3bbffe550421fde4fa1819b0
2013-05-15 23:09:25 -07:00
Tim Starling
196865004d Remove taint support
Venema's taint feature was apparently never publicised beyond the
php-dev mailing list, and now there is a PECL taint extension which is
incompatible with the interface assumed here.

Grep confirms that wfArrayMap() is not used in any extensions.

Change-Id: I17d8d302947443262474c608829c7c7504bef589
2013-05-06 17:39:07 +10:00
Max Semenik
068ce81799 Merge "Import: Fix incorrect wfRunHooks usage" 2013-05-02 19:26:07 +00:00
Max Semenik
1f8a7dc2d2 Import: Fix incorrect wfRunHooks usage
af125df519 broke importing
because Import.php was calling wfRunHooks() improperly.
Fixing the calls and making the wfRunHooks() signature
match Hooks::run() to make call errors immediately detectable.

Change-Id: If44292fedf6917cde1dae7f0391231a18d414610
2013-05-02 18:06:19 +00:00
Kevin Israel
34d49b33a5 wfRandomString: Correct bias toward digits 1-7
Two problems with a single line of code:

* dechex() does not include leading zeros, so the first digit
  generated in each iteration cannot be zero unless the return
  value of mt_rand() is 0.

  This also means wfRandomString() is extremely unlikely to
  start a string with '0'.

* mt_rand() does not actually uniformly distribute values over
  [0,2^32-1]; it actually right-shifts one of the bits off (just
  because "[...] the previous php_rand only returns 31 at most"),
  so the maximum value is 0x7fffffff, not 0xffffffff.

  This means wfRandomString() will never start a string with
  any of the digits 8-f.

Including leading zeros and using only the 28 LSBs to form seven
hex digits at a time is the simplest fix.

Change-Id: Ic19b5b97c582485780b24fd35ffef2111cc8b3ca
2013-04-29 00:33:06 -04:00
umherirrender
6f79eef473 Fixed spacing around parenthesis in includes
Change-Id: Ie8adc00f4ee8ecec4554e584c18d5d2073415397
2013-04-28 15:50:07 +00:00
umherirrender
9f14ecf829 Added space after switch/Removed spaces after unset
While at it, added/removed some other spaces in the same files

Change-Id: I84d8001aa123a008807ad5eb76f396aed7c899a4
2013-04-26 16:42:31 +02:00
Aaron Schulz
ccabd0efb0 Changed on-request job running to shell out instead of doing a loop.
* Also factored out a new wfShellExecDisabled() function.
* This will keep the process in the background if possible to avoid
  killing site performance, especially with slow jobs.
* This also keep fatals and uncatcheable exceptions from
  hitting the user.
* If $wgPhpCli is not set to an actual path or safe mode
  is on, then the old code will be used.

Change-Id: I6a28152251659ee53eee2604f16d5bf02c85a44f
2013-04-25 23:46:05 +00:00
umherirrender
dbd0b590e9 else if -> elseif
Also fixed some spacing while at it
Added some braces for one line statements

Change-Id: Iebfa2b17091509daabc76248121c7763e2295d20
2013-04-17 16:52:47 +02:00
umherirrender
97234cc884 Added spaces before and removed spaces after 'array'
Fix some other spacing while at it

Change-Id: I13f81533eaf40e06c13cf377c0f08ef5cef01d00
2013-04-14 21:57:46 +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
jenkins-bot
8e8856146d Merge "Fixed fatal when using fake load balancers." 2013-04-05 20:29:29 +00:00
Aaron Schulz
97dcbc1c26 Added "cluster" parameter to wfWaitForSlaves() for external DBs.
Change-Id: I226a1793dfb901de8e1c0ac40c1dc3ad890de95a
2013-04-04 16:10:56 -07:00
Aaron Schulz
7fd8d513c4 Fixed fatal when using fake load balancers.
The error was:
Catchable fatal error: Argument 1 passed to DatabaseMysql::masterPosWait()
must implement interface DBMasterPos, boolean given, called in
/var/www/DevWiki/core/includes/db/LoadBalancer.php on line 419

Change-Id: I230585930c1424b0868f9aa290167c66bc6848bd
2013-04-04 10:29:13 -07:00
jenkins-bot
cfcbb5e3ba Merge "Adding wfLogWarning for production warnings." 2013-04-04 16:52:45 +00:00
Aaron Schulz
5f1e95436e Avoid sending multiple UDP packets for the same key in wfIncrStats().
* This should help reduce collector data loss.

Change-Id: Ibe55648422d1b8aac86dd6fa83973d3c8715b0aa
2013-03-29 12:01:42 -07:00
Alexandre Emsenhuber
15833dafdf Fix case of some Title methods
Change-Id: I1a37ffb0e8cde4deac027721b0e463585b58d634
2013-03-26 10:54:15 +01:00
umherirrender
6c278b6d7e fix some spacing
* 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
2013-03-25 22:22:46 +00:00
Peter Gehres
2772d8c1a6 Merge "Fix wfWaitForSlaves() so the $wiki parameter actually works correctly" 2013-03-20 21:44:04 +00:00
Peter Gehres
7cb764095f Fix wfWaitForSlaves() so the $wiki parameter actually works correctly
Change-Id: I1f3da5921f2d724e10c448700ea8b958ff159451
2013-03-20 14:25:38 -07:00
daniel
aacdbbc6f3 Adding wfLogWarning for production warnings.
Currently, trigger_error() is used to report non-fatal problems in 
production. It seems more consistent to have our own function to do 
that, with behavior consistent with wfWarn().

Change-Id: I531b7ceec089978c2832721486f277fdfca65270
2013-03-19 15:24:00 +00:00
umherirrender
926d2ee143 Remove spaces between parentheses in function calls
Change-Id: If8ec665a01b566fa5189dfcc810b2d9a17f371e1
2013-03-17 16:13:22 +01:00
Yuri Astrakhan
9506e3d812 Spellchecked /includes directory
* 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
2013-03-13 03:42:41 -04: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
jenkins-bot
073a675adf Merge "fix some spacing" 2013-03-07 17:13:27 +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
e43dc272bd Fix align of block comments
Change-Id: I88ea33a125a71671886b49e4ebf4c1d0a1cce572
2013-03-07 17:27:38 +01:00
Aaron Schulz
9ace77f03c Moved wfPickRandom to ArrayUtils.
Change-Id: I45e21e722245901ab2988be4892cdb393169c62c
2013-03-05 15:07:09 -08:00