Note about $wgCacheEpoch format ( `date +%Y%m%d%H%M%S` )
[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 * @subpackage Database
6 */
7
8 /**
9 *
10 */
11 if( php_sapi_name() != 'cli' ) {
12 die('');
13 }
14
15 define( 'MEDIAWIKI', 1 );
16 $wgCommandLineMode = true;
17
18 unset( $IP );
19 ini_set( 'allow_url_fopen', 0 ); # For security...
20 require_once( '../LocalSettings.php' );
21
22 if( !$wgAllowSysopQueries ) {
23 die( "Queries disabled.\n" );
24 }
25
26 require_once( 'Setup.php' );
27
28 $wgTitle = Title::newFromText( wfMsgForContent( 'badtitle' ) );
29 $wgArticle = new Article($wgTitle);
30
31 if ( !$argv[1] || !$argv[2] ) {
32 exit();
33 }
34
35 $tid = (int)$argv[2];
36
37 # Wait for timeout (this process may be killed during this time)
38 $us = floor( $argv[1] * 1000000 ) % 1000000;
39 $s = floor( $argv[1] );
40 usleep( $us );
41 sleep( $s );
42
43 # Kill DB thread
44 $conn = Database::newFromParams( $wgDBserver, $wgDBsqluser, $wgDBsqlpassword, $wgDBname );
45 $conn->query( 'KILL '.$tid );
46
47 ?>