fixes for mysql
This commit is contained in:
parent
f90c8cee3c
commit
831906681e
7 changed files with 24 additions and 21 deletions
|
@ -66,7 +66,7 @@ class MySQL extends DBEngine
|
|||
public function set_timeout(PDO $db, int $time): void
|
||||
{
|
||||
// These only apply to read-only queries, which appears to be the best we can to mysql-wise
|
||||
$db->exec("SET SESSION MAX_EXECUTION_TIME=".$time.";");
|
||||
// $db->exec("SET SESSION MAX_EXECUTION_TIME=".$time.";");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -768,14 +768,6 @@ function create_tables(Database $db)
|
|||
<p>{$e->getMessage()}</p>",
|
||||
3
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
throw new InstallerException(
|
||||
"Unknown Error:",
|
||||
"<p>An unknown error occurred while trying to insert data into the database.</p>
|
||||
<p>Please check the server log files for more information.</p>
|
||||
<p>{$e->getMessage()}</p>",
|
||||
4
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
<?php declare(strict_types=1);
|
||||
class ImageBanTest extends ShimmiePHPUnitTestCase
|
||||
{
|
||||
private $hash = "feb01bab5698a11dd87416724c7a89e3";
|
||||
|
||||
public function testBan()
|
||||
{
|
||||
$this->log_in_as_admin();
|
||||
$hash = "feb01bab5698a11dd87416724c7a89e3";
|
||||
|
||||
// Post image
|
||||
$image_id = $this->post_image("tests/pbx_screenshot.jpg", "pbx");
|
||||
|
@ -12,8 +13,8 @@ class ImageBanTest extends ShimmiePHPUnitTestCase
|
|||
$this->assertEquals(200, $page->code);
|
||||
|
||||
// Ban & delete
|
||||
send_event(new AddImageHashBanEvent($hash, "test hash ban"));
|
||||
send_event(new ImageDeletionEvent(Image::by_id($image_id)));
|
||||
send_event(new AddImageHashBanEvent($this->hash, "test hash ban"));
|
||||
send_event(new ImageDeletionEvent(Image::by_id($image_id), true));
|
||||
|
||||
// Check deleted
|
||||
$page = $this->get_page("post/view/$image_id");
|
||||
|
@ -28,11 +29,16 @@ class ImageBanTest extends ShimmiePHPUnitTestCase
|
|||
}
|
||||
|
||||
// Remove ban
|
||||
send_event(new RemoveImageHashBanEvent($hash));
|
||||
send_event(new RemoveImageHashBanEvent($this->hash));
|
||||
|
||||
// Can repost
|
||||
$image_id = $this->post_image("tests/pbx_screenshot.jpg", "pbx");
|
||||
$page = $this->get_page("post/view/$image_id");
|
||||
$this->assertEquals(200, $page->code);
|
||||
}
|
||||
|
||||
public function onNotSuccessfulTest(\Throwable $t): void {
|
||||
send_event(new RemoveImageHashBanEvent($this->hash));
|
||||
parent::onNotSuccessfulTest($t); // TODO: Change the autogenerated stub
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ class IPBanTest extends ShimmiePHPUnitTestCase
|
|||
'42.42.42.42',
|
||||
'block',
|
||||
'unit testing',
|
||||
'2099-01-01'
|
||||
'2030-01-01'
|
||||
));
|
||||
|
||||
// Check added
|
||||
|
|
|
@ -193,12 +193,14 @@ class Relationships extends Extension
|
|||
// WHERE id = :pid
|
||||
// ", ["pid"=>$parentID]);
|
||||
|
||||
$children = $database->get_one(
|
||||
"SELECT COUNT(*) FROM images WHERE parent_id=:pid",
|
||||
["pid"=>$parent_id]
|
||||
);
|
||||
$database->execute(
|
||||
"UPDATE images
|
||||
SET has_children = EXISTS (
|
||||
SELECT 1 FROM images WHERE parent_id = :pid
|
||||
) WHERE id = :pid",
|
||||
["pid"=>$parent_id]
|
||||
SET has_children = :has_children WHERE id = :pid",
|
||||
["has_children"=>$database->scoresql_value_prepare($children>0), "pid"=>$parent_id]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,7 +82,10 @@ class RelationshipsTest extends ShimmiePHPUnitTestCase
|
|||
[$image_1, $image_2, $image_3] = $imgs;
|
||||
|
||||
global $database;
|
||||
$database->execute("UPDATE images SET parent_id=NULL, has_children=:false", ["false"=>false]);
|
||||
$database->execute(
|
||||
"UPDATE images SET parent_id=NULL, has_children=:false",
|
||||
["false"=>$database->scoresql_value_prepare(false)]
|
||||
);
|
||||
// FIXME: send_event(new ImageRelationshipSetEvent($image_2->id, null));
|
||||
|
||||
// refresh data from database
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
chdir(dirname(dirname(__FILE__)));
|
||||
require_once "vendor/autoload.php";
|
||||
require_once "tests/defines.php";
|
||||
|
@ -67,7 +67,7 @@ abstract class ShimmiePHPUnitTestCase extends \PHPUnit\Framework\TestCase
|
|||
self::log_out();
|
||||
|
||||
foreach ($database->get_col("SELECT id FROM images") as $image_id) {
|
||||
send_event(new ImageDeletionEvent(Image::by_id($image_id)));
|
||||
send_event(new ImageDeletionEvent(Image::by_id((int)$image_id), true));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue