wiki.techinc.nl/includes/killthread.php

47 lines
880 B
PHP
Raw Normal View History

<?php
/**
* Script to kill a MySQL thread after a specified timeout
* @package MediaWiki
*/
2004-02-11 13:15:16 +00:00
/**
*
*/
2004-10-14 02:13:12 +00:00
if( php_sapi_name() != 'cli' ) {
die('');
}
define( 'MEDIAWIKI', 1 );
2004-02-11 13:15:16 +00:00
$wgCommandLineMode = true;
unset( $IP );
ini_set( 'allow_url_fopen', 0 ); # For security...
2004-10-14 02:13:12 +00:00
require_once( '../LocalSettings.php' );
2004-02-11 13:15:16 +00:00
2004-10-14 02:13:12 +00:00
if( !$wgAllowSysopQueries ) {
die( "Queries disabled.\n" );
}
2004-02-11 13:15:16 +00:00
require_once( 'Setup.php' );
2004-02-11 13:15:16 +00:00
$wgTitle = Title::newFromText( wfMsgForContent( 'badtitle' ) );
2004-02-11 13:15:16 +00:00
$wgArticle = new Article($wgTitle);
if ( !$argv[1] || !$argv[2] ) {
exit();
}
$tid = (int)$argv[2];
# Wait for timeout (this process may be killed during this time)
$us = floor( $argv[1] * 1000000 ) % 1000000;
$s = floor( $argv[1] );
usleep( $us );
sleep( $s );
# Kill DB thread
$conn = Database::newFromParams( $wgDBserver, $wgDBsqluser, $wgDBsqlpassword, $wgDBname );
$conn->query( 'KILL '.$tid );
2004-02-11 13:15:16 +00:00
?>