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
count( $codeSegment ) > 0 should be never true in a foreach loop of
$codeSegment itself. See also Iffe166f3.
Change-Id: I453b5ec3379951a2ad6e34b9835907c2eba3046b
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
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
* $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
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
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
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
* 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
And added/removed spaces around some other tokens,
like +, -, *, /, <, >, =, !
Fixed windows newline style
Change-Id: I0b9c8c408f3f6bfc0d685a074d7ec468fb848fc8
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
* 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
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
* Ran spell-checker over code comments in /includes/
* A few spellchecking fixes for wfDebug() calls
Found one very strange (NOOP?) line in Linker.php - see "TODO: BUG?"
Change-Id: Ibb86b51073b980eda9ecce2cf0b8dd33f058adbf
Doxygen expects parameter types to come before the
parameter name in @param tags. Used a quick regex
to switch everything around where possible. This
only fixes cases where a primitve variable (or a
primitive followed by other types) is the variable
type. Other cases will need to be fixed manually.
Change-Id: Ic59fd20856eb0489d70f3469a56ebce0efb3db13
Added/removed spaces around logical/arithmetic operator
Reduced multiple empty lines to one empty line
Removed wrong tabs before comments at end of line
Removed too many spaces in assigments
Change-Id: I2bba4e72f9b5f88c53324d7b70e6042f1aad8f6b
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
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
* 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
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
* 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
* 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
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
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
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
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
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
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
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
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
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>
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
- 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
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
- 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
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
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
can be set to any other timezone.
Also avoids the ugly default-changing that was being used by c15605.
Change-Id: I7a5086f84310f50a1929e07bd2e6527a518424b2
* 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
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
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
$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
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
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
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
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
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
- For consistency with wfCgiToArray()
This way instead of the other way around to keep lowerCamelCase natural.
Change-Id: If4528f6572afeab42ef0602a427ac44da9830a3f
* 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
to "wfShellWikiCmd". The old function now remains as a wrapper. The term "maintenance" is too restrictive.
Change-Id: I5c23d6475fd1aca374ee57b89212eee3a0d8cea1
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
- 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
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.
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