Commit graph

1152 commits

Author SHA1 Message Date
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