Commit graph

1198 commits

Author SHA1 Message Date
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
jenkins-bot
7027ba7e93 Merge "Remove DB2 support" 2013-03-01 22:00:46 +00:00
Alexandre Emsenhuber
4421f598ea Correct documentation for wfPickRandom()'s return types
Also make LoadBalancer::pickRandom()'s one consistent.

Change-Id: Ib80827ef20b32fecb799f327545b1232272076d2
2013-03-01 08:22:46 +01:00
Reedy
99512fd3d6 Move LoadBalancer::pickRandom() to wfPickRandom()
Code is copypaste reused in other extensions

Change-Id: I4c677ddc01ee264f3b72bb17135972adc96144ae
2013-02-28 12:52:35 -08:00
Niklas Laxström
74667197d6 Refresh docs for wfMessage
Change-Id: I53d2d32e7d6972171f3c2430412a44eea0b5b0a8
2013-02-26 10:48:06 +00:00
Chad Horohoe
6f4448dd71 Remove DB2 support
Change-Id: I9b294a213a4000f503c0010d88757db6dda927c0
2013-02-25 13:47:03 -08:00
jenkins-bot
c48323708b Merge "(bug 45069) wfParseUrl() no longer produces a PHP notice if passed a "mailto:" URL without address" 2013-02-20 15:42:16 +00:00
Kevin Israel
1d41a94cff Always cast input to string in wfBaseConvert
Fixes a regression caused by I841717be: IP::toHex('128.0.0.0')
was broken on 32-bit systems with the GMP extension installed.

Change-Id: I0c9a4ae771668e005355e381de4065d73c261460
2013-02-19 04:31:33 -05:00
Alexandre Emsenhuber
a7c103ad00 (bug 45069) wfParseUrl() no longer produces a PHP notice if passed a "mailto:" URL without address
Calling wfParseUrl( 'mailto:' ) or wfParseUrl( 'mailto:?subject=...' ) was resulting in the following PHP errors:
PHP Notice:  Undefined index: path in includes/GlobalFunctions.php on line 813
PHP Notice:  Undefined index: path in includes/GlobalFunctions.php on line 814

Now the existence of that key is checked and if missing an empty string is set so for consistency of the returned value.

The fix is based on the snippet provided on
https://www.mediawiki.org/wiki/Thread:Project:Support_desk/GLobafunctions.php_wfParseUrl_choking_on_url

Change-Id: Ife07d6e2a364a7cafda387cf7ed9cd71c2b68ef8
2013-02-18 13:17:23 +01:00
jenkins-bot
a87e2ea37a Merge "Improve the shell cgroup feature" 2013-02-07 18:40:49 +00:00
Chad Horohoe
296e57f634 Deprecate in_string()
It's a silly wrapper for something you can do in one line
of PHP anyway.

Change-Id: Ib85e4aaa20e62fe5f218b38cf0759c9c799c3381
2013-02-06 14:38:57 -05:00
Tim Starling
674962b339 Improve the shell cgroup feature
* Make the cgroup name configurable, so that it can be switched on and
  off in configuration, or so a different cgroup can be used for
  different wikis. The DefaultSettings.php entry also makes the feature
  more discoverable and so more useful to non-Wikimedia users.

* Send named parameters to the shell script instead of numbered
  parameters. Send the command as argument 1, for easier ps -f
  interpretation.

* Move the wrapper script to includes/, since it doesn't need to be
  executable anymore, so it doesn't make sense for it to be in bin/.

* Remove the requirement for a release script to be used. Clean up in
  the wrapper script instead. The release script had to be configured
  globally, which might not be suitable for all MediaWiki installations.

Change-Id: Ic8362cab63df162852d5df56cf695ef163cd6232
2013-02-05 16:47:34 +11:00
Ori Livneh
6c163ad265 (Bug 37957) Replace php_sapi_name() with PHP_SAPI
The PHP_SAPI constant has been available since PHP 4.2.0. It's more
concise to use the constant and has less overhead than a function call.

Furthermore, PHP_SAPI rhymes with "happy", whereas "php_sapi_name"
rhymes with "lame". QED, etc.

Change-Id: Ie8c121cb8fcef50536af8d3f66723b458f0bf9af
2013-02-04 12:50:45 -08:00
umherirrender
1044b0b8df fix some spacing
Change-Id: I8f976013f33c5818e4402604fe8610aa3f43b0c6
2013-02-04 20:18:33 +00:00
S Page
a5e40b661c Document that default timestamp is current time.
Change-Id: Ie255ac62a52f5d023f7cd6ffc6c0df91e7a02403
2013-01-19 07:35:22 +00:00
Aaron Schulz
3943a73e21 Do not send data for 0 increment calls in wfIncrStats().
Change-Id: I5f1ca83ad56e129b42a96a5c73ec42cd2d978901
2013-01-18 10:26:54 -08:00
Tim Starling
c8e3fa04db Implement wall clock time limits for shell commands
* Use the "timeout" command to implement wall clock time limits.
* Write a message to stderr when the time limit is exceeded, for
consistency with ulimit
* Configure with $wgMaxShellWallClockTime
* If "time" is specified in $limits, use that as the wall clock limit in
preference to the global variable, to support legacy callers which
usually want to disable the limits.
* Remove the requirement for ulimit5.sh to be executable since this is
not necessary when you specify the interpreter. Should avoid subtle
problems when the executable bit is accidentally stripped.
* Move the interpretation of 0/-1/false limits to the shell script, so
that e.g. wall clock time can be limited even if memory is unlimited.

Change-Id: Id9f2fea7c3b027565bdc33b88a1a7d4cdfe43a6c
2013-01-14 09:53:59 +11:00
jenkins-bot
f02f1a7658 Merge "Cleaned up and optimized wfBaseConvert();" 2013-01-02 21:38:58 +00:00
btongminh
4f23290816 wfMerge() now works if $wgDiff3 contains spaces
Change-Id: Ia18012ee87fe45e292cf08542f5b0680d0b85371
2012-12-29 21:39:54 +01:00
Tyler Anthony Romeo
9b9daadc46 Cleaned up and optimized wfBaseConvert();
* Added code to use BCMath or GMP if they are
  loaded, since they are both significantly faster.
  A parameter was added that can be used to force
  usage of a specific engine (mainly for testing).
* Made an array of base digits rather than using
  strpos() every time.
* Used casting instead of intval(), since the latter
  is six times slower.

Also added unit tests for wfBaseConvert as well as
a benchmarking class that measures the difference
between using GMP, BCMath, and pure PHP.

Change-Id: I841717be2b29a0b7fc57a13fde5cc0642cda82df
2012-12-27 00:17:18 -05:00
Aaron Schulz
b44f8b296b Made wfBaseconvert actually work with $lowercase=false.
* This used to return false for any non-digit input characters.

Change-Id: Ie7fca2669724dea29f4733bbc77a559d4f48a5b1
2012-12-25 09:36:45 +00:00
Alexandre Emsenhuber
4b5f75205b Use wfWikiID() instead of $wgDBname in wfIncrStats()
This allows to have distinct stat groups for people using database table prefix and
it makes wfIncrStats() consistent with ProfilerSimpleUDP that already uses wfWikiID().

Change-Id: Iecef9f490df8c5685a4887cc81dcb4a7e4d3172c
2012-12-21 18:17:30 +00:00
Brian Wolff
02f6386b3b Make wfSuppressWarnings kill E_STRICT in PHP 5.4+
Since PHP 5.4+ E_STRICT is now included in E_ALL. Hence
wfSuppressWarnings was not filtering E_STRICT.

There was some complaints on project:support_desk about
timezone warnings popping up. See also bug 43092

Change-Id: Ie1ace158dac1733e6b2b2c1d533004d9bcab8c80
2012-12-16 07:28:57 +00:00
Antoine Musso
e32c8afe54 prefix debug log when they end up in the main log
Whenever we use wfDebugLog( "group", "message" ); and "group" is not
also set in $wfDebugLogGroups, the group information is lost. By
prefixing the message with the group name, it makes it obvious where the
message comes from.

Example output:

...
[EventLogging] wgEventLoggingSchemaIndexUri has not been configured.
[EventLogging] EventLogging requires memcached, and no memcached[...]
Fully initialised
Profiler::instance called without $wgProfiler['class'] set[...]
Connected to database 0 at
MessageGroups::init-nocache
SQL ERROR (ignored): no such table: revtag_type
MessageGroups::loadGroupDefinitions-end
[ContentHandler] Created handler for wikitext: WikitextContentHandler
[ContentHandler] Created handler for javascript: JavaScriptContentHandler
...

Change-Id: Id75401bec516b5111cd1e3d4a9b29843953ce12b
2012-12-07 16:53:12 +01:00
Siebrand Mazeland
02f8475482 Add wfDeprecated to wfMsg* methods from 1.21 on
These were marked soft deprecated in 1.18.

Change-Id: Ifa82da981c69b2ea9d5b298e9dfb04fc29483206
2012-12-04 12:19:09 +01:00
csteipp
d834a4892a (bug 40995) Refresh SessionId on login
SpecialUserlogin updated to refresh the user's session_id on each
successful login.

Change-Id: I1bd76f2c199b515f570e18669ca2138668bf847e
2012-11-29 22:18:31 +00:00
Hashar
34a65359cc Merge "Log profiling data when tests have finished." 2012-11-19 13:12:16 +00:00
daniel
e606537090 Log profiling data when tests have finished.
Previously, no profiling data was recorded from unit test runs.
That made it impossible to a) use unit tests for selective profiling
of individual functions, and b) made it impossibel to profile
the tests themselves.

This change fixes this problem by calling wfLogProfilingData()
after the test runner has finished.

Thaks to Hashar for some ideas, especially the fix in GlobalFunctions.

Change-Id: Iaa295115f3c4eb3b529388dcd953fe8932448b3e
2012-11-16 20:14:29 +01:00
Daniel Kinzler
2c85e0dd5b avoid STDERR diff3 messages when using wfMerge()
diff3 issues a warning to stderr if any of the files does not end with a
newline character.

TextContent::preSaveTransform() does normalize revision text by simply
calling trim().  Thus to avoid a diff3 error we simply apply the same
normalization and add a newline to please the command.

Change-Id: I7baa3df95dd70cbc865b2491ccc791e60f8b9e6e
2012-11-10 17:26:08 +00:00
Siebrand Mazeland
d4b046a893 Update docs for return and exception info
* Removed some inline tabs in the process.
* IDE fixed some incorrect leading spaces, too.

Change-Id: Ic9303eff6db4424ac3f1fa2816839692b43e6190
2012-10-09 09:41:58 +00:00
umherirrender
161c35bcb4 Remove deprecated 1.16 wfLoadExtensionMessages
Change-Id: I9b9ecc9818d17c98748f39177c28554f8c485de5
2012-10-05 22:41:22 +02:00
umherirrender
99159fd750 wfTimestamp should not die on bogus input [Regression]
Followup I68eb9f27

No caller of wfTimestamp can handle the exception, false is always used,
as the method comment says.

See bug 40037 for File related timestamps.
The api result is also not b/c:
<api servedby="mw70">
  <error code="internal_api_error_TimestampException" info="Exception
Caught: MWTimestamp::setTimestamp : Invalid timestamp - te"
xml:space="preserve" />
</api>

Change-Id: I1e8c785941d35678f3d12824bdde0ce245572592
2012-09-14 18:28:22 +02:00
IAlex
8634014e86 Merge "Replace some occurrences of wfMsg* by alternatives. Undeprecated wfMsgReplaceArgs." 2012-09-10 17:33:37 +00:00
Tim Starling
653ee32ed2 Remove @deprecated from wfTimestamp()
Adding abbreviated wrappers for lengthy function invocations is good
practice, it improves code readability. If all we ever had was
MWTimestamp, and we had a million instances of

$timestamp = new MWTimestamp( $ts );
$mwTimestamp = $timestamp->getTimestamp( TS_MW );

I would introduce a global function or class static method wrapper to
clean up those invocations. But I don't have to, because we already have
the wrapper.

Change-Id: I9149a7626676a0115a0a877f27d8b65e6e868de9
2012-09-07 15:13:38 +10:00
Fran McCrory
d6028a1811 (bug 34939) Handle mixed-case URL protocols in wikitext
This patch marks the regex matching url protocol as being case
insensitive. We will from now render links like [HTTP://ww].

Tests added.

Change-Id: I706acb7a0ae194b50d2318763beae4e5e83671f3
2012-09-04 16:26:46 +02:00
Siebrand Mazeland
475a1daa03 Replace some occurrences of wfMsg* by alternatives. Undeprecated wfMsgReplaceArgs.
* wfMsgReplaceArgs isn't really i18n related. It just replaces text parts.
* Updated language.txt. Now refers to mediawiki.org.
* Removed deprecated Block::formatExpiry(). Merge Id7d057a4 first.
* Reformatted weirdly formatted array in ApiBase.php.
* Removed wfMsg() in RandomTest.php.

Change-Id: Ied5cfda8fa5d9283dfeebdcb0e1af8453d47e7a9
2012-09-03 11:49:58 +02:00
Tyler Anthony Romeo
e738203a8e Added PHP complement for mw.Time.
Figured since a JS Timestamp class was being implemented
it might be appropriate to create a complementary PHP
Timestamp class. Much of code is taken from wfTimestamp().

Note: Another change (I53dcf547) is attempting a related
issue. Not sure how much of scope overlap there is.

Change-Id: I68eb9f27eebe80df757187f634392e1bcba5551f
Signed-off-by: Tyler Romeo <tylerromeo@gmail.com>
2012-08-30 20:44:09 -04:00
Alexandre Emsenhuber
b455e43276 Fix wfGetCaller() and wfFormatStackFrame() documentation
These two functions cannot return a boolean.

Also simplified wfGetCaller() to not use the $caller local
variable which is totally useless in that case.

Change-Id: I81707a8292afc1829921b58cdaae81b3147ee3cb
2012-08-29 21:36:37 +02:00
Alexandre Emsenhuber
5af2159512 Moved warning stuff into MWDebug class.
- Group common code in one instead of doing checks one
  time in GlobalFunctions.php and another time in Debug.php
- Remove the code catching the fact that a warning is due
  to a deprecation warning, no longer needed
- Pass the caller offset from wfDeprecated() to
  MWDebug::deprecated(); this was breaking deprecation
  notices for global objects.
- Changed PHP error level for deprecation notices (when
  $wgDevelopmentWarnings is set to true) from E_USER_NOTICE
  to E_USER_DEPRECATED since we now require PHP 5.3+
- Added E_USER_DEPRECATED to wfSuppressWarnings() and
  removed the check for the E_DEPRECATED constant being set
  now that we require PHP 5.3+
- Fixed MWDebugTest by calling wfSuppressWarnings() and
  wfRestoreWarnings() in setUp() and tearDown()

Change-Id: I6810b57c90d384de55a2cf177047767cdb734f79
2012-08-28 15:33:44 +02:00
Nikerabbit
d6b9b27492 Merge "Use the MWDebug class to display debug log back in the request." 2012-08-28 05:49:41 +00:00
Tim Starling
ad03f2f753 Revert Uri class due to bug 39710
Revert 94f623363b. Apparently all
ReverseChronologicalPager subclasses were broken by the unexplained
interface change in wfArrayToCgi(): changing the interpretation of
null array values from "omit this key" to "include this key with no
value". The function has always been called with the former
interpretation, that's why the special case was in there.

Also reverted dependent changes 4b517fa and part of 3d97704.

Change-Id: I41dadbde5d0e0e4c54cc76bfc13c263c15c73828
2012-08-28 10:53:09 +10:00
Alexandre Emsenhuber
61dd1d037b Use the MWDebug class to display debug log back in the request.
- This removes the duplication of MWDebug::$debug and
  OutputPage::$mDebugtext, so there's no need to store two times
  the same text
- Removed OutputPage::debug() since it's no longer used
- Had to keep OutputPage::$mDebugtext because it's still
  referenced by SemanticPageMaker extension
- Moved Skin::formatDebugHTML() to MWDebug::GetHTMLDebugLog()
  and replaced the call in Skin::generateDebugHTML() to use it
- Also check $logonly before sending entries to the debug
  toolbar in wfDebug(), for consistency
- Changed MWDebug::getDebugHTML() to also return the debug log
  in an HTML comment if $wgDebugComments is set to true and
  changed the location of this call to BaseTemplate::printTrail()
  so that its result is the latest possible. This also includes
  the debug toolbar.
- Removed MockOutputPage and related test cases since they are
  no longer accurate

Change-Id: Ie0f389f8566457b1c938c627ed930040741ac9d9
2012-08-27 23:47:19 +02:00
Aaron Schulz
a17e263c81 Added sanity check to StreamFile for mwstore paths.
Change-Id: Id402f077037f3e84c9158f7d48be0ed82ba4a1cf
2012-08-22 20:46:54 -07:00
Catrope
8b1b82f396 Make wfScript()/mw.util.wikiScript() respect $wgScript/$wgLoadScript
mw.util.wikiScript() and mw.util.wikiScript( 'index' ) now return the
value of $wgScript rather than building the path to index.php manually;
the latter is incorrect if $wgScript is customized. Similarly,
mw.util.wikiScript( 'load' ) now uses $wgLoadScript.

Same for wfScript(), wfScript( 'index' ) and wfScript( 'load' )

The qunit tests already had a test case for wgScript, but wgScript was
set in a way that didn't trigger the bug. Changed it to use customized
wgScript and wgLoadScript values and added test cases for 'index' and
'load'

This fixes bug 39103 (wfScript/mw.util.wikiScript do not respect custom
$wgScript/$wgLoadScript) as well as bug 39102 ("Entry points" on
Special:Version do not respect custom $wgScript/$wgLoadScript)

Change-Id: I5c9e82849e314dc7a87f8ae91150cc412b4011cf
2012-08-21 14:27:04 -07:00
Siebrand Mazeland
6fe1f0509b Replace deprecated wfMsg* calls with Message class calls.
Doing this in steps of roughly 100 changes per commit, so that it remains reviewable.

Change-Id: Ib15e670badd3f6aecae8b60e2f9129a31341ce16
2012-08-21 18:38:44 +02:00
Reedy
2e0be64b93 Bug 39516 - Call to a member function format() on a non-object
Workaround for php bug [1], reported in 5.3.2, fixed already

Workaround can be removed when our minimum PHP version is > 5.3.2

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

Change-Id: Ia60e64300787d0b683829765e8eeac1535e9d0a4
2012-08-20 23:41:18 +01:00
Alex Monk
2fabea7eea Use wfMessage instead of deprecated wfMsg*
Or $this->msg in special pages.

Change-Id: I774a89d646615053c8424050e42ad95601f92543
2012-08-18 14:11:05 +02:00
Siebrand Mazeland
4b517facdd Add version of deprecation for wfAppendQuery() and suggest alternative.
Change-Id: I31f03aa38d029ca19d8e6655d05c4d201dccae47
2012-08-18 00:00:06 +02:00
Platonides
ef498e793e Replace $wgDBerrorLogInUTC with a $wgDBerrorLogTZ variable which
can be set to any other timezone.
Also avoids the ugly default-changing that was being used by c15605.

Change-Id: I7a5086f84310f50a1929e07bd2e6527a518424b2
2012-08-08 15:51:39 +01:00
Aaron Schulz
e7a615ad7c Merge "Allow session storage to be configured independently" 2012-08-08 00:35:59 +00:00
Tim Starling
6eb6313b6f Allow session storage to be configured independently
* Introduce $wgSessionCacheType to allow the session storage to be
  configured independently of $wgMemc.
* Renamed $wgSessionsInMemcached to $wgSessionsInObjectCache to reflect
  the new versatility.
* Modernized the relevant code, removing the explicit require_once(),
  used the autoloader instead. Moved it to ObjectCacheSessionHandler.
* Tested with memcached, external sharded MySQL and APC, it all seems to
  work just fine.

Change-Id: I473334bb56cafb4e21ac1c1304d69095676fc0c4
2012-08-08 10:25:56 +10:00
Waldir Pimenta
1e769a5f9a improve wfStripIllegalFilenameChars()'s readability
make the preg_replace regex more readable,
and expand documentation a little.

Change-Id: Id26d9d42be7d3f2780e82da27dd2477d62d8e106
2012-08-07 20:09:26 +01:00
Aaron Schulz
3d60b479de Merge "Add a Uri class." 2012-08-07 03:37:30 +00:00
Daniel Friesen
94f623363b Add a Uri class.
Add a Uri class matching our mw.Uri JS class for handling uris.
This class should be helpful in a bunch of places where we end up doing manual
concatenation of things like the path + '?' + query of a url parsed with wfParseUrl.

[tylerromeo@gmail.com: Removed cat() function, fixed wfWarn() usage for aliases
 and added visibility to all functions. Also added test for aliases.]
Signed-off-by: Tyler Romeo <tylerromeo@gmail.com>

Change-Id: Iefdedb7c80cf1d4aab58050edab3ab44ba868a58
2012-08-06 22:46:25 -04:00
jeroendedauw
2b65df98fe Add @deperecation stuff to message functions
Change-Id: I69168ed9d850baf02b3dd7c8bd0e820f3f00f43f
2012-08-06 19:32:52 +02:00
Jan Gerber
2a02b44b59 add optional limits argument to wgShellExec
add optional limits argument to overwrite
filesize, memory and time limits or a command
executed with wfShellExec.
Just having once size fits all $wgMaxShell* options
is not good enough for tasks that take long
or create large files (i.e. video transcoding)

Change-Id: I54148907bfd103fd28aff69baae03437efcfe1ee
2012-07-16 14:35:51 -07:00
Antoine Musso
ef9534313e prevents some doxygen warnings
This patch fix misc issues reported by doxygen. Nothing fancy.

Change-Id: I98edc8c877019f1dc4a82a37bca518df2eb904fc
2012-07-15 22:32:48 +02:00
Reedy
fb9cbb1b4c Fix casing of wgDBerrorLogInUtc
Change-Id: I644ea64b1a40160f3468ec35836ee9aa003c03de
2012-07-13 19:02:12 +01:00
Antoine Musso
bc6d5fb88a dbErrorLog can now be forced to UTC
$wgDBerrorLog is used to log database error. It is using
$wgLocalTimezone to format the date which might not always be wanted in
a multi Timezone cluster of wiki.

wgDBerrorLogInUTC , when true, will override the Wiki timezone to uses
UTC whenever a database error is logged.

Change-Id: I091d6029272b69db0aefdebfc37896d0a8e8770e
2012-07-13 16:56:36 +02:00
Antoine Musso
aab43dd495 escape tags and entity in doxygen comments
When inserting XML elements inline <such as this one>, doxygen chokes
about it not being known. Simply enclosing the tag in double quotes
prevents doxygen from emitting a warning.

Also enclosed a few invalid functions calls such as \. and double quoted
the HTML entities such as &foobar;

Change-Id: I4019637145e683c2bec3d17b2fd98b0c50a932f1
2012-07-10 17:08:32 +02:00
Antoine Musso
4d1324f47d setting to completely override server hostname
Labs has instances hostnames forged in sequences which make them not
that much useful for human readable output. Labs does publish a
meaningful instance name as an env variable though, so we could use it
to get better output.

This patch introduce $wgOverrideHostname (default false) which when
set will override the hostname returned by wfHostname().

Change-Id: Ibdba007cc4025fa0b0ebef39b5669c32852a95a7
2012-06-26 22:27:02 +02:00
Mark A. Hershberger
99fdc6e838 Bug 24985 use $wgTmpDirectory when available
We had two way to get a temporary directory:

 - $wgTempDirectory: more or less stable accross sessions
 - wfTempDir(): set through environnement variable and could potentially
   vary from a session to another one thanks to tempnam()

This patch makes wfTempDir() to always use the global $wgTempDirectory
first when it is available. Thus explicitly overriding tempnam() or any
environnement variable such as TMP or TEMP.

Hence, people who don't have access to a system wide directory
specificed by their environnement (such as /tmp) can specify an
alternative straight from the MediaWiki configuration.

The patch remove references to $wgTmpDirectory and replace them with
calls to wfTempDir().  Make wfTempDir() use $wgTmpDirectory first.

The default setting of $wgTmpDirectory was removed in favor of having it
initialized through Setup.php by calling wfTempDir.

Note: this may also address Bug 36475 - Generating thumbnails does not
work when there is no access to /tmp

Change-Id: Ifdc79e9c5d95f978025b237a5eeb95fd75092f46
2012-06-13 21:30:22 +02:00
awjrichards
c29fd59775 Big oops - merged to wrong branch.
Revert "Revert to arbitrarily old point before initial remote branch creation to help clean up"

This reverts commit ee0d3d330f
2012-06-05 22:58:54 +00:00
awjrichards
ee0d3d330f Revert to arbitrarily old point before initial remote branch creation to help clean up
Change-Id: I41a3d1e55d3ea9dffa42451237fe065f9334361d
2012-06-02 08:43:04 -07:00
Platonides
2e506c4809 PHP >= 5.4.0 started taking advantage of $limit optimization of wfDebugBacktrace(),
which we weren't treating right.

* $limit in wfDebugBacktrace() is the number of returned frames,
we thus need to take into account the wfDebugBacktrace() frame, which
is sliced from debug_backtrace().

* wfGetCaller() needs to add a level for itself.

* MWDebug::warning() was logging itself as the warning issuer,
which is useless (the call a few lines before was right, though)
MWDebugTest.php changed accordingly.

* Removed double call to wfGetCaller( $callerOffset + 1 )

* Documented the meaning of wfGetCaller() parameter

* Added unit test

Change-Id: Ief50f4c810bad8b03bb2bf9dc6d945d9acb29851
2012-05-31 17:32:33 +02:00
Aaron Schulz
2dbea5d278 Removed dead code since PHP minimum is > 5.2.1.
Change-Id: I565ff44e5e058ce72cd2eaeaec9ea1e441d01010
2012-05-29 22:23:07 +02:00
Alexandre Emsenhuber
b6c04726c6 Removed function_exists() check for header_remove() since it's now always available.
header_remove() was added in PHP 5.3.0 which is below that our minimum requirement; also fixed a comment for the minimum required PHP version.

Change-Id: Ib6992ed772f1a707f96020fdfe6eb6152102402a
2012-05-26 21:31:30 +02:00
Alexandre Emsenhuber
15e9fcca01 Added missing GPLv2 headers in some places.
Also made file/class documentation more consistent.

Change-Id: Iaebd4e253ff3b35b568e9b394231a5691445ac95
2012-05-14 19:59:58 +02:00
Timo Tijhof
6b8a256d5d (bug 36537) Rename wfArrayToCGI to wfArrayToCgi
- For consistency with wfCgiToArray()
  This way instead of the other way around to keep lowerCamelCase natural.

Change-Id: If4528f6572afeab42ef0602a427ac44da9830a3f
2012-05-05 19:02:58 +02:00
Reedy
c1ed53da6c Kill off pre php 5.3.2 back compat hacks
Change-Id: I5b806a5d8fd4ec6914e3786a4a9aefba4ad6faa6
2012-05-05 00:23:35 +01:00
Hashar
13224921a2 Merge "wfAssembleUrl lacked '@since 1.19' comment" 2012-04-19 19:30:49 +00:00
Reedy
f1ca21306c wfAssembleUrl lacked '@since 1.19' comment
Related to Bug 36084 - PHP Fatal error: Call to undefined function wfAssembleUrl()

Change-Id: Ief6077ab60ec8613d744e6e2e2e72043a6b3dd96
2012-04-19 11:53:48 +02:00
Platonides
1e70d71fe0 wfMkdirParents() should display mode in octal.
Patchset 2: Address issue pointed out by CR

Change-Id: Ia156903131612f3faa93a7010de2e034d528ec7d
2012-04-19 11:04:11 +02:00
Catrope
458f162b63 Merge "[LanguageConverter] Added some cache code based on the problems in r97512." 2012-04-09 22:25:24 +00:00
Reedy
97257d4e9a wfLocalFile returns a LocalFile (or null) not a File
Change-Id: Ib016f16c1b5528d9f6af4189ca8459cacb54cf10
2012-04-07 21:51:53 +01:00
Aaron Schulz
0c2a0e4d6b Merged ImageFunctions.php into GlobalFunctions.php
Change-Id: I02d468f9c54a6a0448a6d99505d0201a7949855a
2012-04-06 16:43:27 -07:00
Aaron Schulz
10f49bd065 [LanguageConverter] Added some cache code based on the problems in r97512.
* Added $wgLanguageConverterCacheType global to control LC cache type. We can use it to enable direct apc use for language converter (to match the live hack).
* Added $wgLangConvMemc object, available via Setup.php

Change 1:
* Updated unit tests
* Minor documentation cleanup in DefaultSettings.php

Change-Id: Icd5dd28407e9759ce294c784ec41d9ca15c89616
2012-04-06 13:26:17 -07:00
Aaron Schulz
770c9d8c2e Renamed "wfShellMaintenanceCmd" function and new, unused, het-deploy, hook
to "wfShellWikiCmd". The old function now remains as a wrapper. The term "maintenance" is too restrictive.

Change-Id: I5c23d6475fd1aca374ee57b89212eee3a0d8cea1
2012-04-04 16:48:55 -07:00
Santhosh Thottingal
c56cca551e (bug 32748) unicode URL for articles print version
Printer friendly version of article must encode URL in unicode.

- Patch originally written by Brion Vibber
  https://bugzilla.wikimedia.org/attachment.cgi?id=9593
- introduces wfExpandIRI() global function, uses wfExpandIRI_callback.
- phpunit test.

Change-Id: I348b9f1d2ce65cb14f20d4a5751ac9359c8b8316
2012-04-02 18:14:41 +02:00
Tim Starling
4b8e45d604 * Removed the $method parameters from MWCryptRand. Apparently Dantman didn't know about our awesome debug traceback functions like wfGetAllCallers(). The weird optional-middle-parameter calling convention thankfully disappears as a consequence.
* Reduced the amount of debug log noise slightly, removing a few redundant messages.
2012-03-21 10:27:34 +00:00
Daniel Friesen
e2ee009e5c Commit the cryptrand project worked on in git:
- MWCryptRand: A new api for generating cryptographic randomness for security tokens. Uses whatever cryptographic source is available and if not falls back to using random state and clock drift.
- wfRandomString - A simple non-cryptographic pesudo-random string generation function to replace wfGenerateToken which was written pretending to be secure when it's really not.
- Core updates to use MWCryptRand in various places:
-- user_token generation (to do this we stop generating user_token implicitly and only generate it when needed to avoid depleting the system's entropy pool by reading random data we'll never use)
-- email confirmation token generation
-- password salt generation
-- temporary password generation
-- Generation of the automatic watchlist token
-- login and create user tokens
-- session ids when php's entropy sources are not set
-- the installer when generating wgSecretKey and the upgrade key
2012-03-20 05:17:40 +00:00
Aaron Schulz
7c54a34730 Reverted r113688, r113691 per CR and filed #61440 upstream. 2012-03-19 18:28:47 +00:00
Jeroen De Dauw
4febcf9cc1 docs++ 2012-03-15 22:40:27 +00:00
Aaron Schulz
a6a58fd0dd Made wfShellMaintenanceCmd() not totally broken due to excess shell escaping. 2012-03-13 00:05:23 +00:00
Alexandre Emsenhuber
73f6907199 * Put the timer stuff after leading line breaks in debug log entries (mainly for the first call on a request) so that they are placed near the remaing text and not on its own line
* Normalise line breaks in the first entry on a web request so that it's consistent with the one for command line requests
2012-03-12 19:01:44 +00:00
Robin Pepermans
9184dc83d6 Update core usage of getLanguageName[s]. 2012-03-08 20:56:26 +00:00
Antoine Musso
6e7dfac65a move wfRecursiveRemoveDir to global functions
That useful method was hidden in SeleniumWebSettings. I need it to clean
up test files leakages.
2012-02-24 15:41:06 +00:00
Alexandre Emsenhuber
e6fbfecf46 Added wfDeprecated() call to wfSpecialList() now there no more calls to that function in core or extensions 2012-02-16 12:59:48 +00:00
Alexandre Emsenhuber
72cafa3c8d Move wfIncrStats() near other debugging functions 2012-02-15 16:17:02 +00:00
Alexandre Emsenhuber
dfa3eca14c Always send 1 for "-total" item in wfIncrStats() when destination is UDP; it should not depend on the $count parameter 2012-02-14 14:10:32 +00:00
Brian Wolff
11f4db8b2a follow-up r111342. Document the callerOffset paramter being used per CR. 2012-02-13 20:29:41 +00:00
Robin Pepermans
fb3ae443ef Remove all usage of wfUILang(), deprecated in 1.18. Also some other minor tweaks. Didn't remove wfUILang itself yet in case someone uses older versions of the extensions with trunk/1.20. 2012-02-13 20:26:02 +00:00
Brian Wolff
d5b26e049a Give a warning when people use $wgArticle. Add's a class that can be used to give warnings for other globals too.
See discussion on r111168.

Of course no one will see warning because trunk has $wgDeprecationReleaseLimit set to 1.17 by default
(<rant>have I mentioned how I don't like that variable. People enable warnings to be *warned* about
things. Making it so people won't get warned about things until a couple months after we've decided people
should stop using function/interface/etc defeats the purpose of having warnings</rant>)

p.s. Wasn't sure if this waranted something in the release notes, I don't think it does (It's just adding a warning)
but wasn't sure.
2012-02-13 00:19:06 +00:00
Antoine Musso
a600f8a781 revert core part of r111231
That one removed wfLoadExtensionMessages() . We do not want to break
back compatiliblity right now.
2012-02-12 19:40:13 +00:00
Siebrand Mazeland
53e0d99f4b * Remove last remaining traces of wfLoadExtensionMessages().
* Add missing action message and remove unused global in UploadLocal.
* Some whitespace updates in Maps.
2012-02-11 12:17:58 +00:00
Sam Reed
76246b9bf5 More return documentation 2012-02-09 21:33:27 +00:00
Sam Reed
7b25f8231f Fixing some of the "@return true" or "@return false", need to be "@return bool" and then the metadata can say true if foo, false if bar
Other documentation improvements
2012-02-09 19:30:01 +00:00
Sam Reed
e1d83d5721 Fixing some of the "@return true" or "@return false", need to be "@return bool" and then the metadata can say true if foo, false if bar
Other documentation improvements
2012-02-09 18:01:54 +00:00
John Du Hart
daeb57099d Fixes bug 33165 - GlobalFunctions.php line 1312: Call to a member function getText() on a non-object 2012-02-07 02:49:28 +00:00
Alexandre Emsenhuber
a885da4e64 Moved wfDeprecated() and wfWarn() near other debug-related functions 2012-02-03 09:54:40 +00:00
Alexandre Emsenhuber
afab06cc73 wfTime() -> microtime( true ), no need to use the former which is just a wrapper to the latter 2012-02-03 08:32:34 +00:00
Alexandre Emsenhuber
13ba0295e2 Follow-up r110591: remove unused global declaration 2012-02-02 23:01:36 +00:00
Alexandre Emsenhuber
b6e7b2d9fd * Always add the hostname in wfDebugLog(), whatever $wgShowHostnames is, since that setting is for user display, not internal stuff
* Use wfHostname() and wfWikiId() instead of executing "hostname" command and $wgDBname respectively for consistency
2012-02-02 16:35:02 +00:00
Alexandre Emsenhuber
bb7b900db4 Use $wgRequestTime in wfDebugTimer() to get the time since the start of the request instead the difference with the first call so that the time before that call is not ignored and for consistency with other time displays. 2012-02-02 10:33:42 +00:00
Max Semenik
55cb51e4c0 HTML 2??? 2012-02-01 15:44:32 +00:00
Tim Starling
6db5545f66 Fix for r109720: replace the last two regexes with plain string functions. The regular expression used for stripping the last path component from the output was inefficient, because PCRE does not optimise "$" anchors correctly. It scans the entire string forwards, instead of scanning backwards starting from the anchor. Passes tests. 2012-01-23 19:35:05 +00:00
gicode
f174914db9 Follow-up 102587 to address performance concerns in wfRemoveDotSegments. 2012-01-22 04:57:37 +00:00
Sam Reed
29e672787c Documentation
Remove unused globals
2012-01-19 17:27:29 +00:00
Antoine Musso
6f1d1c5245 reverts wgDeprecationWhitelist
Per wikitech-l
Reverts r106883 and r106946
2012-01-16 08:59:17 +00:00
Jeroen De Dauw
f93a0bbc56 revert r108508 which reverted for no good reason 2012-01-11 14:11:06 +00:00
Antoine Musso
6203ba8874 reverts $wgDeprecationWhitelist
There is no point in ignoring a deprecated function. The call really need
to be migrated OR the core function should not be deprecated if there is
any kind of valid usage.

If you really want to hide notifications, uses:
  $wgDevelopmentWarnings = false;

Reverts r106993 r106946
2012-01-10 15:40:01 +00:00
Aaron Schulz
1d77bc94c2 * Cleanup for r108175: made if easier for extensions to interact with each other in TitleReadWhitelist hook. A handler can set $whitelisted to true to whitelist the page or it can set it to false and return false (most restrictive wins).
* Added some hook doc comments.
2012-01-06 06:16:05 +00:00
John Du Hart
7e9d750cc7 Implemented console panel in debug toolbar 2012-01-03 05:56:36 +00:00
Jeroen De Dauw
0ddef438be partial revert of r106872 after discussion with Brion on #mediawiki irc 2011-12-20 22:45:14 +00:00
Brion Vibber
65f4955351 Revert r106456, r106485: system-wide setting seems to be intended to apply only to specific extensions' code but wouldn't? Also weird config parameter combining two unrelated things into one. 2011-12-20 21:52:18 +00:00
Aaron Schulz
5275f9b097 Merged FileBackend branch. Manually avoiding merging the many prop-only changes SVN likes to sprinkle in (easy to spot from the change list). Did not add SwiftFileBackend.php as it still is in development. 2011-12-20 03:52:06 +00:00
Jeroen De Dauw
5d3237fb9f follow up to r106456 - use one setting instead two, which apparently made my commit into a fixme 2011-12-16 23:13:10 +00:00
Jeroen De Dauw
9952b6692c introduce a new setting that allows extension authors to whitelist deprecated funtion usage for functions they do not wish to update due to backward compat reasons for a while 2011-12-16 18:32:45 +00:00
Jeroen De Dauw
43f00eb80c follow up to r106393 - re-add these notices, since now they wont show for people that change the depr limit to see them 2011-12-16 00:24:00 +00:00