Commit graph

65 commits

Author SHA1 Message Date
jenkins-bot
91e4128955 Merge "Add fastcgi_finish_request where appropriate" 2014-01-03 16:06:47 +00:00
Tyler Anthony Romeo
6aeb565733 Add fastcgi_finish_request where appropriate
When using PHP-FPM to run PHP on a web server, the function
fastcgi_finish_request is provided, which flushes all response
data to the client and closes the connection, allowing PHP
to perform additional work without delaying the client.

This adds fastcgi_finish_request calls in index.php and api.php
where appropriate and if the function exists, so that the connection
is closed once the output is definitely finished.

Change-Id: Ic67a8956545874e94df5198088c0f4aa58ca376e
2014-01-03 04:02:52 -05:00
Brad Jorsch
76c61632f7 Add ApiBeforeMain hook
$wgExtensionFunctions is called before the RequestContext is really
available (i.e. getTitle() is null, accessing the User object may fail
because other extensions' UserLoadFromSession hooks don't expect to be
called that early, etc). The index.php code path has BeforeInitialize to
take action after RequestContext is available but before much else
happens, but the API doesn't (yet) have anything similar.

Bug: 58380
Change-Id: I0a167faaa4166da381194c53373d82e038848924
2013-12-12 10:01:33 -05:00
Timo Tijhof
beb1c4a0ec phpcs: More require/include is not a function
Follows-up I1343872de7, Ia533aedf63 and I2df2f80b81.

Also updated usage in text in documentation and the
installer LocalSettingsGenerator.

Most of them were handled by this regex:
- find: (require|include|require_once|include_once)\s*\(\s*(.+?)\s*\)\s*;$
- replace: $1 $2;

Change-Id: I6b38aad9a5149c9c43ce18bd8edbab14b8ce43fa
2013-05-21 23:26:28 +02:00
umherirrender
21751b9ba7 echo is not a function
Removed parenthesis after echo

Change-Id: Ia533aedf63b11d15dcc6a5cf75a56134a4b11d86
2013-05-09 19:52:45 +00:00
Tim Starling
1fe9340bb3 Remove hphpc support and deprecate related functions
hphpc has been superseded by hhvm, so support for hphpc is no longer
needed.

* Continue to use Preprocessor_Hash under HipHop since it is still
  faster under hhvm
* Keep $wgCompiledFiles for now, so that wikihiero doesn't give an error
  before Ic9d1e795 is merged
* Migrate the run-server script and associated configuration file to
  hhvm. Enable EnableStaticContentFromDisk since it doesn't seem
  ridiculously inefficient at first glance. Run from $IP rather than
  $IP/.. since hhvm is apparently not picky about sourcing files from
  outside of the current directory.

Change-Id: Ic3e769f1fbad4f7ad26dd819406796fee48c6b45
2013-05-09 08:28:05 +10:00
Yuri Astrakhan
27d83878c0 Lots of spelling mistakes and phpdoc attributes
@throw->@throws
@returns->@return
@seealso->@see
@cover->@covers
etc

Change-Id: I9ae6bc3034e9790e2d66cd96473b923fe9ee7953
2013-03-10 23:16:28 -04:00
Siebrand Mazeland
655f5c6b48 Update code formatting
Change-Id: I8741b5b979e55f38a666961a16c387586a92410e
2013-02-14 13:38:19 +00:00
Antoine Musso
f6b92231fd style: normalize end of files
By PSR2 PHP Standard, the files should ends with exactly one newline.
Some of our files have 2 or more and some other were missing a newline.

Fix almost all occurences of CodeSniffer sniff:
PSR2.Files.EndFileNewline.TooMany

I have not fixed the selenium files, I believe we will drop them.

Change-Id: I89fca8c1786fee94855b7b77bb0f364001ee84b6
2013-02-03 15:04:39 +01:00
Alex Monk
c2c982c4e8 (bug 36537) Rename calls to wfArrayToCGI to wfArrayToCgi
Done with this command:
grep wfArrayToCGI * -R -l -Z | xargs -0 -l sed -i -e 's/wfArrayToCGI/wfArrayToCgi/g' && git checkout -- HISTORY

Change-Id: If7f4d4bfc199289c11c43cf519c2415a1aad1c51
2013-01-28 18:04:20 +00:00
Hoo man
d13c6fa967 Follow up to dirname( __FILE__ ) clean up
Remove a trailing whitespace added by me in dirname( __FILE__ )
clean up and add some comments to the PHP version checks (they
can't use __DIR__ as they have to run in older PHP versions.

Change-Id: I6a7e8cb7dbf384d91dda4d0ecbef7ce588bc3073
2012-08-28 23:47:56 +02:00
jeroendedauw
38c7f444e1 Use __DIR__ instead of dirname( __FILE__ )
We can now do this since we finally switched to PHP 5.3 for MW 1.20 and get rid of the silly dirname(__FILE__) stuff :)

Change-Id: Id9b2c9cd2e678197aa81c78adced5d1d31ff57b1
2012-08-27 21:45:00 +02:00
Alexandre Emsenhuber
a9bb27bf11 Pass the full context to the ApiMain instance from api.php.
Passing only the WebRequest instance is not the best
thing when it accepts a complete context.

Change-Id: If02148c850b395a2382f87cbeafbc25887ce8728
2012-07-06 19:04:50 +02:00
Catrope
29625efc2b Reimplement CORS properly, addressing Tim's concerns
Tim's concerns (listed at
https://bugzilla.wikimedia.org/show_bug.cgi?id=20814#c6) were:
* Lack of Vary: Origin breaks Squid caching
* Vary: Origin on everything would be disastrous, so add an origin param
* Origin header is space-separated list, wasn't treated as such

This commit:
* Remove CORS code from api.php and reimplement it in ApiMain.php
* Add 'origin' parameter to ApiMain
* If 'origin' parameter doesn't match Origin header, send a 403
* If origin is whitelisted, set CORS headers and set Vary: Origin
* Add https?:// to wildcard matching logic, wasn't there but is needed

CORS now works :) you can test it locally as follows:
Set $wgCrossSiteAJAXdomains[] = '*.wikipedia.org';
Log into MediaWiki on localhost
Go to Wikipedia, open a JS console, and run:
$.ajax( {
	'url': 'http://localhost/w/api.php',
	'data': {
		'action': 'query',
		'meta': 'userinfo',
		'format': 'json',
		'origin': 'https://en.wikipedia.org'
		// or whichever domain you're on; must be correct!
	},
	'xhrFields': {
		'withCredentials': true
	},
	'success': function( data ) {
		alert( 'Foreign user ' + data.query.userinfo.name +
			' (ID ' + data.query.userinfo.id + ')' );
	}
} );

Change-Id: I725ce176866d7c81dd9ad6d7bc4a86b7160f2458
2012-07-05 21:31:11 +01:00
Alexandre Emsenhuber
f27ff698fb Added missing GPLv2 headers in some places.
Also made file documentation more consistent.

Change-Id: I30e124514396f110a572467b94ca06cefd5f7b46
2012-05-23 13:41:30 +02:00
Reedy
f1bec81eba Various updates needed to bump min php version to 5.3.2
Change-Id: I22015387e4ac5839a907059086d787f352746886
2012-04-16 15:38:22 +01:00
Platonides
6813a55665 API: trunk/phase3 is now mediawiki/core
e7544995a0 follow-up.

Change-Id: Ic0c82e0a54cefded24fc3aa260ddc051e30e8ab5
2012-03-23 17:43:50 +01:00
Sam Reed
27665d27ae Update some deprecated code
Documentation

Fix "/*" comments to "/**"

Flesh out some missing returns, change some return types
2011-10-14 21:18:38 +00:00
Roan Kattouw
4a0c3c1fa8 Revert r96715 per committer's (Chad's) CR comment 2011-09-14 13:43:06 +00:00
Sam Reed
a0fbb287ae Fix documentation, document return type 2011-09-13 12:37:05 +00:00
Chad Horohoe
f15ec7bb07 Add a comment about something I noticed while spelunking the code 2011-09-10 06:47:37 +00:00
Alexandre Emsenhuber
77a3987052 Moved wfGetIP() to WebRequest::getIP():
* Changed all calls in core to the latter
* Also marked wfGetForwardedFor() as deprecated
* Moved wfGetIP() tests to WebRequestTest
2011-08-18 20:03:30 +00:00
Chad Horohoe
b91ace27d9 Clean up the mess that is wfDie (resolves r85918). wfDie() doesn't exist anymore, so don't use it.
The only two usages left since r91590 are php version checks for index/load/api.php, and $wgAPIEnabled check in api.php. Consolidate all of the "bailing for invalid version" into PHPVersionError.php. Leaving $wgAPIEnabled as the only user was silly, so just echo and die like wfDie() would've done
2011-07-06 21:01:12 +00:00
Tim Starling
97ff30ddb4 (bug 28840) If the query string hits bug 28235, redirect to a safer URL instead of showing an unhelpful error message. IE 6 will only use the extension of the final destination for its cache filename. 2011-06-03 05:32:51 +00:00
Tim Starling
ff1dc8a175 HipHop improvements:
* Added the ability to compile extensions. The build process is bootstrapped by running MediaWiki in interpreted mode. Extension setup file inclusions are slightly modified in a way that makes them register themselves for compilation. Then the same LocalSettings.php uses the compiled extension setup file when the compiled binary runs.
* Tested with Cite and ParserFunctions. The code which lets you have an extensions directory in a place other than $IP/../extensions is untested.
* Simplified WebStart.php slightly by using a custom $_SERVER variable to mark compiled mode. It will break if you don't use the supplied server.conf, but that will break a lot of things so don't do that.
* Fixed the core web entry points to include WebStart.php in compiled mode instead of interpreted.
* Made the build directory configurable. This is mostly so that I can grep the source tree without seeing loads of generated C++.
* In server.conf, added a rewrite rule allowing a /wiki/$1 article path.
* Removed server.conf log file location "/dev/stdout", breaks when you switch user
* Disable static content cache, breaks horribly when you set SourceRoot to a directory containing 7GB of files.
* Rewrote the run-server script in PHP, mostly to support the configurable build directory feature.
* Added an option to the run-server script to allow running in interpreted (hphpi) mode.
2011-05-30 13:49:09 +00:00
Tim Starling
6fec4e3fde Revert r87635, r87637, r87639, r87643 (MW_MIN_PHP_VERSION etc.): breaks HipHop support. 2011-05-15 13:21:16 +00:00
Happy-melon
7055add799 Centralise the minimum-required-php-version in a MW_MIN_PHP_VERSION constant in Defines.php. This requires loading Defines.php before the PHP4 version checks, so include a big note reminding people not to include anything other than vanilla define() statements in there.
I have a sneaking suspicion that including Defines.php in the entry points might not play nicely with HipHop, but I can't test it (wrong OS).
2011-05-07 15:16:01 +00:00
Happy-melon
938a8eb347 Improvements to handling of 'catastrophic' errors, like unsupported PHP versions, no MySQL functions, no LocalSettings, etc.
* Fix parsing of the three major entry points (index.php, api.php, load.php) back to PHP 4.4.9.  We don't care what happens if you actually try to run these files on old versions, but the entry files need to parse correctly.
* consign /includes/templates/PHP4.php and /includes/templates/NoLocalSettings.php to the fiery pit of hell where they belong.
* Prevent loading of any other files for PHP < 5.  WebStart.php was rendered unparseable in PHP 4 by the introduction of try/catch blocks in r85327.
* Die outright with a pretty error message on PHP < 5.2.3 as well as PHP 4.  All versions of PHP below that throw parse errors of various sorts.
* Reimplement wfDie() to provide an entry-point-dependent die-with-readable-error-message function (for instance, we want a pretty human-readable page in index.php, something wrapped in CSS/JS /*...*/ comment block in load.php, etc).  
* Standardise the appearance of the catastrophic errors thrown at the top of the stack with the ones lower down (exception-within-exception, etc).  There isn't really a way to do this without duplication, AFAICT.
2011-04-12 20:38:16 +00:00
Tim Starling
3ef857fe4d Fix for bug 28235: IE6 looks for the file extension in the query string 2011-04-12 00:55:10 +00:00
Ilmari Karonen
75086e9f35 (bug 16019) Make WebRequest::interpolateTitle() do nothing when run from api.php 2010-12-10 22:39:17 +00:00
Derk-Jan Hartman
921619b119 Correct the address of the FSF in some of the GPL headers
59 Temple Place -> 51 Franklin Street
2010-06-21 13:13:32 +00:00
Roan Kattouw
3a953c8e30 API performance fixes: avoid unstubbing $wgContLang and $wgUser 2010-02-15 20:50:21 +00:00
Mark A. Hershberger
8b36a2b969 various eol whitespace now instead of when someone needs to do CR 2010-02-12 06:44:16 +00:00
Aryeh Gregor
3758769f0d stylize.php on API code
"I wouldn't object to stylizing the API code to bring it in line with
the rest of MW on principle, but I'm not gonna bother myself." --Roan
<http://www.mediawiki.org/wiki/Special:Code/MediaWiki/60657#c5108>

If you're seeing this commit in blames, tell your blame tool to ignore
whitespace, e.g., git blame -w or svn blame -x -w.
2010-01-11 15:55:52 +00:00
Roan Kattouw
d7f593a312 API: Add user-agent and method (GET/POST) to request logging, and only log the action= parameter for mustBePosted modules 2009-08-27 22:09:28 +00:00
Roan Kattouw
1378ce62d3 API: Add optional API request logging to a file or UDP; intending to use this on the cluster to get some data about API usage and things like which queries are expensive 2009-08-27 17:07:23 +00:00
Alex Z
b97ce20115 Tweak Access-Control-Allow-Origin stuff per comments on r54127.
Use a wildcard syntax rather than string/regex options
2009-08-21 00:22:08 +00:00
Tim Starling
07efbeb8ae * Fixed XSS vulnerability introduced by r49833. Only pre-release versions of MediaWiki were affected.
* Refactored the IE script entry point security check into WebRequest::isPathInfoBad(). Use the standard CGI variable PATH_INFO to do this check instead of the various potential non-standard solutions. Made the check fairly permissive to avoid a repeat of bug 13049 due to broken CGI setups especially with cgi.fix_pathinfo=0. This should theoretically be very portable and secure, but I have not tested it widely.
* Removed Chris Wrinn from the credits since his patch was wrong and has been removed.
* Made the error message more informative.
2009-08-17 13:23:45 +00:00
Alex Z
b54addda93 (bug 19907) Adds support for cross-domain AJAX requests to the API.
Uses the Access-Control-Allow-Origin header for browsers that support it.
<http://dev.w3.org/2006/waf/access-control/>
$wgCrossSiteAJAXdomains can be set to '*' to allow requests from any domain,
an array of domains to allow, or, if $wgCrossSiteAJAXdomainsRegex is true,
an array of regexes to match against the request origin
2009-07-31 21:56:34 +00:00
Roan Kattouw
798795e825 Followup to r50132: rename API define constant to MW_API, per comment on CR 2009-05-05 13:22:50 +00:00
Roan Kattouw
ea5b014e38 Followup to r50132: I guess I was smoking some pretty good stuff there 2009-05-02 15:03:02 +00:00
Roan Kattouw
5924eb85f0 API: Set $wgTitle to a dummy title in api.php, and introduce defined('API') as a check for API mode. This should fix errors about $wgTitle being null 2009-05-02 14:47:26 +00:00
Roan Kattouw
13d180553d API: (bug 13049) This'll hopefully fix the 403 Forbidden error in api.php for the setups that were getting them (most notably FastCGI and IIS). Patch by Chris Wrinn 2009-04-24 19:50:50 +00:00
Alexandre Emsenhuber
ce9c8bf686 Same as r48631; added "@file" when needed, also added doc in redirect.php and install-utils.inc 2009-03-21 16:48:09 +00:00
Tim Starling
7f42dcde82 -1 is not a valid exit code 2008-11-14 05:51:39 +00:00
Tim Starling
a4eaa89625 * Fix unlogged automatic user creation: run wfLBFactory()->shutdown() unconditionally in api.php. If you want to optimise it, do it in the database backend, since there's no way for the MW core to indicate to the web API that a write query has been performed. The previous code was also wrong in that it didn't commit transactions on foreign connections.
* Fixed debugging code left in (mustBePosted disabled).
2008-05-17 04:26:26 +00:00
Roan Kattouw
5162afcfb9 This is cleaner, thanks to ialex 2008-04-02 20:19:35 +00:00
Roan Kattouw
1fee715cea (bug 13587) Execute deferred updates in api.php 2008-04-02 18:04:54 +00:00
Brion Vibber
c8c176f7de * Security fix for API on MSIE 2008-01-23 23:45:46 +00:00
Yuri Astrakhan
ce91d949f7 API:
* Added full text search in titles and content (list=search)
* (bug 10684) Expanded list=allusers functionality
* Possible breaking change: prop=revisions no longer includes pageid for rvprop=ids
* Bug fix: proper search escaping for SQL LIKE queries.
2007-07-30 08:09:15 +00:00