This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function killConnection(string $event): void | |
{ | |
if ($this->killerEnabled && ($this->killerEnabled === $event)) { | |
$this->serviceConnection->exec('KILL ' . $this->pid); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$options = [ | |
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, | |
PDO::MYSQL_ATTR_LOCAL_INFILE => true, | |
]; | |
$pdo = new TaintedPDO($dsn, $user, $password, $options); | |
$pdo->setOnEvent([$this, 'killConnection']); | |
$pdo->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); | |
$pdo->setAttribute( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Keboola\DbExtractor\Tests; | |
class TaintedPDOStatement extends \PDOStatement | |
{ | |
/** | |
* @var callable | |
*/ | |
private $callback; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Keboola\DbExtractor\Tests; | |
class TaintedPDO extends \PDO | |
{ | |
private $callback; | |
public function setOnEvent($callback) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function testNetworkKillerQuery(): void | |
{ | |
ErrorHandler::register(null, true); | |
$this->pdo->query('KILL SELECT CONNECTION_ID()'); | |
self::expectException(\ErrorException::class); | |
self::expectExceptionMessage('Warning: PDO::query(): MySQL server has gone away'); | |
$this->pdo->query('SELECT NOW();'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function testNetworkKillerExecute() | |
{ | |
$this->setupLargeTable(); | |
$conn = $this->getConnection(); | |
// sleep 5 seconds before killing, then kill it for 10 seconds | |
exec('php killNetwork.php 5 10 > /dev/null &'); | |
ErrorHandler::register(null, true); | |
// sleep a while to make sure the connection is terminated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function testNetworkKillerExecute() | |
{ | |
$conn = $this->getConnection(); | |
// sleep 1 second before killing, then kill it for 3 seconds | |
exec('php killNetwork.php 1 3 > /dev/null &'); | |
ErrorHandler::register(null, true); | |
// sleep a while to make sure the connection is terminated | |
sleep(2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function testNetworkKillerQuery() | |
{ | |
$conn = $this->getConnection(); | |
// sleep 1 second before killing, then kill it for 3 seconds | |
exec('php killNetwork.php 1 3 > /dev/null &'); | |
ErrorHandler::register(null, true); | |
// sleep a while to make sure the connection is terminated | |
sleep(2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
sleep((int) $argv[1]); | |
$client = new \Aws\Rds\RdsClient([ | |
'credentials' => [ | |
'key' => getenv('TEST_RDS_ACCESS_KEY'), | |
'secret' => getenv('TEST_RDS_ACCESS_SECRET'), | |
], | |
'region' => 'us-east-1', | |
'version' => '2014–10–31', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
sleep((int) $argv[1]); | |
exec('cports /close * * * 3600'); |