* (bug 1477) hide details of SQL error messages by default
[mediawiki.git] / includes / killthread.php
blob669a7ce7d49798e24e9e48bf395314044de0c94b
1 <?php
2 /**
3 * Script to kill a MySQL thread after a specified timeout
4 * @package MediaWiki
5 */
7 /**
9 */
10 if( php_sapi_name() != 'cli' ) {
11 die('');
14 define( 'MEDIAWIKI', 1 );
15 $wgCommandLineMode = true;
17 unset( $IP );
18 ini_set( 'allow_url_fopen', 0 ); # For security...
19 require_once( '../LocalSettings.php' );
21 if( !$wgAllowSysopQueries ) {
22 die( "Queries disabled.\n" );
25 require_once( 'Setup.php' );
27 $wgTitle = Title::newFromText( wfMsgForContent( 'badtitle' ) );
28 $wgArticle = new Article($wgTitle);
30 if ( !$argv[1] || !$argv[2] ) {
31 exit();
34 $tid = (int)$argv[2];
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 );
42 # Kill DB thread
43 $conn = Database::newFromParams( $wgDBserver, $wgDBsqluser, $wgDBsqlpassword, $wgDBname );
44 $conn->query( 'KILL '.$tid );