Commit graph

1198 commits

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