ratings works with sqlite (unit tests pass, at least)
This commit is contained in:
parent
aa1637d128
commit
41ce16f1b8
3 changed files with 6 additions and 6 deletions
|
@ -22,5 +22,4 @@ class RatingsInfo extends ExtensionInfo
|
||||||
<li>rating=sq -- safe and questionable images
|
<li>rating=sq -- safe and questionable images
|
||||||
</ul>
|
</ul>
|
||||||
</ul>";
|
</ul>";
|
||||||
//public $db_support = [DatabaseDriver::MYSQL, DatabaseDriver::PGSQL];
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,16 +225,16 @@ class Ratings extends Extension
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if (is_null($event->term)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$matches = [];
|
$matches = [];
|
||||||
if (is_null($event->term) && $this->no_rating_query($event->context)) {
|
if (is_null($event->term) && $this->no_rating_query($event->context)) {
|
||||||
$set = Ratings::privs_to_sql(Ratings::get_user_default_ratings($user));
|
$set = Ratings::privs_to_sql(Ratings::get_user_default_ratings($user));
|
||||||
$event->add_querylet(new Querylet("rating IN ($set)"));
|
$event->add_querylet(new Querylet("rating IN ($set)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_null($event->term)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (preg_match($this->search_regexp, strtolower($event->term), $matches)) {
|
if (preg_match($this->search_regexp, strtolower($event->term), $matches)) {
|
||||||
$ratings = $matches[1] ? $matches[1] : $matches[2][0];
|
$ratings = $matches[1] ? $matches[1] : $matches[2][0];
|
||||||
|
|
||||||
|
@ -420,7 +420,6 @@ class Ratings extends Extension
|
||||||
return $ratings;
|
return $ratings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function get_user_class_privs(User $user): array
|
public static function get_user_class_privs(User $user): array
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
|
|
|
@ -29,6 +29,8 @@ class RatingsTest extends ShimmiePHPUnitTestCase
|
||||||
|
|
||||||
public function testRatingExplicit()
|
public function testRatingExplicit()
|
||||||
{
|
{
|
||||||
|
global $config;
|
||||||
|
$config->set_array("ext_rating_anonymous_privs", ["s", "q"]);
|
||||||
$this->log_in_as_user();
|
$this->log_in_as_user();
|
||||||
$image_id = $this->post_image("tests/pbx_screenshot.jpg", "pbx");
|
$image_id = $this->post_image("tests/pbx_screenshot.jpg", "pbx");
|
||||||
$image = Image::by_id($image_id);
|
$image = Image::by_id($image_id);
|
||||||
|
|
Reference in a new issue