diff --git a/core/_install.php b/core/_install.php
index 1b78499e..bf99bc21 100644
--- a/core/_install.php
+++ b/core/_install.php
@@ -364,19 +364,10 @@ function insert_defaults()
function build_dirs()
{ // {{{
- // *try* and make default dirs. Ignore any errors --
- // if something is amiss, we'll tell the user later
- if (!file_exists("data")) {
- @mkdir("data");
- }
- if (!is_writable("data")) {
- @chmod("data", 0755);
- }
+ $data_exists = file_exists("data") || mkdir("data");
+ $data_writable = is_writable("data") || chmod("data", 0755);
- // Clear file status cache before checking again.
- clearstatcache();
-
- if (!file_exists("data") || !is_writable("data")) {
+ if (!$data_exists || !$data_writable) {
print "
Shimmie Installer
diff --git a/core/database.php b/core/database.php
index 124d7c31..24d8bd47 100644
--- a/core/database.php
+++ b/core/database.php
@@ -203,7 +203,8 @@ class Database
$stmt = $this->db->prepare(
"-- " . str_replace("%2F", "/", urlencode(@$_GET['q'])). "\n" .
$query
- );
+ )
+ assert(!is_bool($stmt));;
// $stmt = $this->db->prepare($query);
if (!array_key_exists(0, $args)) {
foreach ($args as $name=>$value) {
@@ -308,10 +309,12 @@ class Database
public function get_last_insert_id(string $seq): int
{
if ($this->engine->name == DatabaseDriver::PGSQL) {
- return $this->db->lastInsertId($seq);
+ $id = $this->db->lastInsertId($seq);
} else {
- return $this->db->lastInsertId();
+ $id = $this->db->lastInsertId();
}
+ assert(is_numeric($id));
+ return (int)$id;
}
/**
diff --git a/core/extension.php b/core/extension.php
index d09170cf..30468135 100644
--- a/core/extension.php
+++ b/core/extension.php
@@ -225,12 +225,12 @@ abstract class ExtensionInfo
protected function __construct()
{
- assert (!empty($this->key), "key field is required");
- assert (!empty($this->name), "name field is required for extension $this->key");
- assert (empty($this->visibility) || in_array($this->visibility, self::VALID_VISIBILITY), "Invalid visibility for extension $this->key");
- assert (is_array($this->db_support), "db_support has to be an array for extension $this->key");
- assert (is_array($this->authors), "authors has to be an array for extension $this->key");
- assert (is_array($this->dependencies), "dependencies has to be an array for extension $this->key");
+ assert(!empty($this->key), "key field is required");
+ assert(!empty($this->name), "name field is required for extension $this->key");
+ assert(empty($this->visibility) || in_array($this->visibility, self::VALID_VISIBILITY), "Invalid visibility for extension $this->key");
+ assert(is_array($this->db_support), "db_support has to be an array for extension $this->key");
+ assert(is_array($this->authors), "authors has to be an array for extension $this->key");
+ assert(is_array($this->dependencies), "dependencies has to be an array for extension $this->key");
}
public function is_enabled(): bool