* (bug 1754) Patch by Anders Wegge Jakobsen: Both Atom and RSS were using the
[lhc/web/wiklou.git] / includes / killthread.php
1 <?php
2 /**
3 * Script to kill a MySQL thread after a specified timeout
4 * @package MediaWiki
5 */
6
7 /**
8 *
9 */
10 if( php_sapi_name() != 'cli' ) {
11 die('');
12 }
13
14 define( 'MEDIAWIKI', 1 );
15 $wgCommandLineMode = true;
16
17 unset( $IP );
18 ini_set( 'allow_url_fopen', 0 ); # For security...
19 require_once( '../LocalSettings.php' );
20
21 if( !$wgAllowSysopQueries ) {
22 die( "Queries disabled.\n" );
23 }
24
25 require_once( 'Setup.php' );
26
27 $wgTitle = Title::newFromText( wfMsgForContent( 'badtitle' ) );
28 $wgArticle = new Article($wgTitle);
29
30 if ( !$argv[1] || !$argv[2] ) {
31 exit();
32 }
33
34 $tid = (int)$argv[2];
35
36 # Wait for timeout (this process may be killed during this time)
37 $us = floor( $argv[1] * 1000000 ) % 1000000;
38 $s = floor( $argv[1] );
39 usleep( $us );
40 sleep( $s );
41
42 # Kill DB thread
43 $conn = Database::newFromParams( $wgDBserver, $wgDBsqluser, $wgDBsqlpassword, $wgDBname );
44 $conn->query( 'KILL '.$tid );
45
46 ?>