[core,tests] even more types
This commit is contained in:
parent
2688843d80
commit
802ff336a2
16 changed files with 31 additions and 51 deletions
|
@ -82,7 +82,7 @@ abstract class Extension
|
|||
}
|
||||
}
|
||||
|
||||
public static function is_enabled(string $key): ?bool
|
||||
public static function is_enabled(string $key): bool
|
||||
{
|
||||
return in_array($key, self::$enabled_extensions);
|
||||
}
|
||||
|
|
|
@ -182,9 +182,6 @@ class Search
|
|||
}
|
||||
}
|
||||
}
|
||||
if (is_null($total)) {
|
||||
return 0;
|
||||
}
|
||||
return $total;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,10 +30,6 @@ class TagUsage
|
|||
{
|
||||
global $cache, $database;
|
||||
|
||||
if (!$search) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$search = strtolower($search);
|
||||
if (
|
||||
$search == '' ||
|
||||
|
|
|
@ -202,13 +202,9 @@ class User
|
|||
{
|
||||
global $database;
|
||||
$hash = password_hash($password, PASSWORD_BCRYPT);
|
||||
if (is_string($hash)) {
|
||||
$this->passhash = $hash;
|
||||
$database->execute("UPDATE users SET pass=:hash WHERE id=:id", ["hash" => $this->passhash, "id" => $this->id]);
|
||||
log_info("core-user", 'Set password for '.$this->name);
|
||||
} else {
|
||||
throw new SCoreException("Failed to hash password");
|
||||
}
|
||||
$this->passhash = $hash;
|
||||
$database->execute("UPDATE users SET pass=:hash WHERE id=:id", ["hash" => $this->passhash, "id" => $this->id]);
|
||||
log_info("core-user", 'Set password for '.$this->name);
|
||||
}
|
||||
|
||||
public function set_email(string $address): void
|
||||
|
|
|
@ -615,7 +615,7 @@ function _set_up_shimmie_environment(): void
|
|||
// The trace system has a certain amount of memory consumption every time it is used,
|
||||
// so to prevent running out of memory during complex operations code that uses it should
|
||||
// check if tracer output is enabled before making use of it.
|
||||
$tracer_enabled = constant('TRACE_FILE') !== null;
|
||||
$tracer_enabled = !is_null('TRACE_FILE');
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -605,7 +605,7 @@ class Artists extends Extension
|
|||
$i = 0;
|
||||
$urlsAsString = str_replace("\r\n", "\n", $urlsAsString);
|
||||
$urlsAsString = str_replace("\n\r", "\n", $urlsAsString);
|
||||
$urlsAsArray = is_null($urlsAsString) ? [] : explode("\n", $urlsAsString);
|
||||
$urlsAsArray = empty($urlsAsString) ? [] : explode("\n", $urlsAsString);
|
||||
$urlsIDsAsArray = is_null($urlsIDsAsString) ? [] : explode(" ", $urlsIDsAsString);
|
||||
while ($i < count($urlsAsArray)) {
|
||||
// if an URL was updated
|
||||
|
|
|
@ -31,10 +31,6 @@ class AutoComplete extends Extension
|
|||
{
|
||||
global $cache, $database;
|
||||
|
||||
if (!$search) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$search = strtolower($search);
|
||||
if (
|
||||
$search == '' ||
|
||||
|
|
|
@ -265,7 +265,6 @@ class DanbooruApi extends Extension
|
|||
private function api_add_post(): void
|
||||
{
|
||||
global $database, $user, $page;
|
||||
$danboorup_kludge = 1; // danboorup for firefox makes broken links out of location: /path
|
||||
|
||||
// Check first if a login was supplied, if it wasn't check if the user is logged in via cookie
|
||||
// If all that fails, it's an anonymous upload
|
||||
|
@ -331,9 +330,7 @@ class DanbooruApi extends Extension
|
|||
$page->set_code(409);
|
||||
$page->add_http_header("X-Danbooru-Errors: duplicate");
|
||||
$existinglink = make_link("post/view/" . $existing->id);
|
||||
if ($danboorup_kludge) {
|
||||
$existinglink = make_http($existinglink);
|
||||
}
|
||||
$existinglink = make_http($existinglink);
|
||||
$page->add_http_header("X-Danbooru-Location: $existinglink");
|
||||
return;
|
||||
}
|
||||
|
@ -356,9 +353,7 @@ class DanbooruApi extends Extension
|
|||
});
|
||||
|
||||
$newid = make_link("post/view/" . $newimg->id);
|
||||
if ($danboorup_kludge) {
|
||||
$newid = make_http($newid);
|
||||
}
|
||||
$newid = make_http($newid);
|
||||
|
||||
// Did we POST or GET this call?
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
|
|
|
@ -146,9 +146,7 @@ class GraphQL extends Extension
|
|||
private static function handle_upload(int $n, string $common_tags, string $common_source): array
|
||||
{
|
||||
if (!empty($_POST["url$n"])) {
|
||||
return ["error" => "URLs not handled yet"];
|
||||
$tmpname = "...";
|
||||
$filename = "...";
|
||||
throw new \Exception("URLs not handled yet");
|
||||
} else {
|
||||
$ec = $_FILES["data$n"]["error"];
|
||||
switch($ec) {
|
||||
|
|
|
@ -331,7 +331,7 @@ class OuroborosAPI extends Extension
|
|||
}
|
||||
}
|
||||
$meta = [];
|
||||
$meta['tags'] = is_array($post->tags) ? $post->tags : Tag::explode($post->tags);
|
||||
$meta['tags'] = Tag::explode($post->tags);
|
||||
$meta['source'] = $post->source;
|
||||
if (Extension::is_enabled(RatingsInfo::KEY) !== false) {
|
||||
$meta['rating'] = $post->rating;
|
||||
|
@ -365,7 +365,7 @@ class OuroborosAPI extends Extension
|
|||
if (!is_null($img)) {
|
||||
$handler = $config->get_string(ImageConfig::UPLOAD_COLLISION_HANDLER);
|
||||
if ($handler == ImageConfig::COLLISION_MERGE) {
|
||||
$postTags = is_array($post->tags) ? $post->tags : Tag::explode($post->tags);
|
||||
$postTags = Tag::explode($post->tags);
|
||||
$merged = array_merge($postTags, $img->get_tag_array());
|
||||
send_event(new TagSetEvent($img, $merged));
|
||||
|
||||
|
|
|
@ -737,19 +737,19 @@ class Pools extends Extension
|
|||
return;
|
||||
}
|
||||
|
||||
$images = " ";
|
||||
$images = [];
|
||||
foreach ($event->posts as $post_id) {
|
||||
if ($this->add_post($event->pool_id, $post_id, false)) {
|
||||
$images .= " " . $post_id;
|
||||
$images[] = $post_id;
|
||||
}
|
||||
}
|
||||
|
||||
if (!strlen($images) == 0) {
|
||||
if (count($images) > 0) {
|
||||
$count = (int)$database->get_one(
|
||||
"SELECT COUNT(*) FROM pool_images WHERE pool_id=:pid",
|
||||
["pid" => $event->pool_id]
|
||||
);
|
||||
$this->add_history($event->pool_id, 1, $images, $count);
|
||||
$this->add_history($event->pool_id, 1, implode(" ", $images), $count);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -104,9 +104,6 @@ class RotateImage extends Extension
|
|||
|
||||
$image_obj = Image::by_id($image_id);
|
||||
$hash = $image_obj->hash;
|
||||
if (is_null($hash)) {
|
||||
throw new ImageRotateException("Post does not have a hash associated with it.");
|
||||
}
|
||||
|
||||
$image_filename = warehouse_path(Image::IMAGE_DIR, $hash);
|
||||
if (file_exists($image_filename) === false) {
|
||||
|
|
|
@ -45,7 +45,11 @@ class StatsDInterface extends Extension
|
|||
$this->_stats("other");
|
||||
}
|
||||
|
||||
$this->send(StatsDInterface::$stats, 1.0);
|
||||
// @phpstan-ignore-next-line
|
||||
if (STATSD_HOST) {
|
||||
$this->send(STATSD_HOST, StatsDInterface::$stats, 1.0);
|
||||
}
|
||||
|
||||
StatsDInterface::$stats = [];
|
||||
}
|
||||
|
||||
|
@ -74,12 +78,8 @@ class StatsDInterface extends Extension
|
|||
return 99;
|
||||
}
|
||||
|
||||
private function send(array $data, float $sampleRate = 1)
|
||||
private function send(string $host, array $data, float $sampleRate = 1)
|
||||
{
|
||||
if (!STATSD_HOST) {
|
||||
return;
|
||||
}
|
||||
|
||||
// sampling
|
||||
$sampledData = [];
|
||||
|
||||
|
@ -99,7 +99,7 @@ class StatsDInterface extends Extension
|
|||
|
||||
// Wrap this in a try/catch - failures in any of this should be silently ignored
|
||||
try {
|
||||
$parts = explode(":", STATSD_HOST);
|
||||
$parts = explode(":", $host);
|
||||
$host = $parts[0];
|
||||
$port = (int)$parts[1];
|
||||
$fp = fsockopen("udp://$host", $port, $errno, $errstr);
|
||||
|
|
|
@ -160,7 +160,7 @@ class TagList extends Extension
|
|||
$results = $cache->get("tag_list_omitted_tags:".$tags_config);
|
||||
|
||||
if (is_null($results)) {
|
||||
$tags = explode(" ", $tags_config);
|
||||
$tags = Tag::explode($tags_config, false);
|
||||
|
||||
if (count($tags) == 0) {
|
||||
return [];
|
||||
|
|
|
@ -407,9 +407,6 @@ class Upload extends Extension
|
|||
if (count($event->images) == 0) {
|
||||
throw new UploadException("File type not supported: " . $event->mime);
|
||||
}
|
||||
if (count($event->images) == 0) {
|
||||
throw new UploadException("File type not supported: " . $event->mime);
|
||||
}
|
||||
return $event->images;
|
||||
});
|
||||
foreach($new_images as $image) {
|
||||
|
|
|
@ -8,3 +8,11 @@ parameters:
|
|||
- ../themes
|
||||
ignoreErrors:
|
||||
- '#Access to an undefined property Shimmie2\\Image::\$#'
|
||||
dynamicConstantNames:
|
||||
- DEBUG
|
||||
- SPEED_HAX
|
||||
- TRUSTED_PROXIES
|
||||
- TIMEZONE
|
||||
- BASE_HREF
|
||||
- STATSD_HOST
|
||||
- TRACE_FILE
|
||||
|
|
Reference in a new issue