Skip to content
Snippets Groups Projects
Commit 956957c1 authored by Moritz Strohm's avatar Moritz Strohm
Browse files

fix for BIESt #1077

Merge request studip/studip!645
parent cb8947e7
No related branches found
No related tags found
No related merge requests found
......@@ -9,6 +9,8 @@ class BlubberController extends AuthenticatedController
parent::before_filter($action, $args);
PageLayout::setTitle(_('Blubber'));
$this->threads_more_down = 0;
}
public function index_action($thread_id = null)
......
......@@ -18,6 +18,8 @@ class Course_MessengerController extends AuthenticatedController
}
$this->threads = BlubberThread::findByContext(Context::get()->id, true, Context::getType());
$this->thread = null;
$this->threads_more_down = 0;
if (!$thread_id) {
$thread_id = $GLOBALS['user']->cfg->BLUBBER_DEFAULT_THREAD;
......
......@@ -7,7 +7,9 @@ class BlubberFormat extends StudipFormat
private static $blubber_rules = [
'hashtags' => [
'start' => self::REGEXP_HASHTAG,
'callback' => 'BlubberFormat::markupHashtags'
'end' => '',
'callback' => 'BlubberFormat::markupHashtags',
'before' => null
]
];
......
......@@ -110,12 +110,12 @@ class Config implements ArrayAccess, Countable, IteratorAggregate
/**
* returns metadata for config entry
* @param srting $field
* @param string $field
* @return array
*/
public function getMetadata($field)
{
return $this->metadata[$field];
return $this->metadata[$field] ?? [];
}
/**
......
......@@ -175,7 +175,7 @@ class RangeConfig extends Config
// Otherwise convert it to an appropriate format and store it
$metadata = Config::get()->getMetadata($field);
$entry->value = $this->convertForDatabase($metadata['type'], $value, $field);
$entry->value = $this->convertForDatabase($metadata['type'] ?? 'string', $value, $field);
$ret = $entry->store();
if ($ret) {
......
......@@ -22,10 +22,20 @@
*/
class SQLQuery
{
public $settings = ['joins' => []];
public $name = null;
public $settings = [
'table' => '',
'select' => [],
'joins' => [],
'where' => [],
'parameter' => [],
'having' => [],
'order' => '',
'limit' => []
];
public static function table($table, $query_name = null)
public $name = '';
public static function table(string $table, string $query_name = '')
{
$query = new self($table, $query_name);
return $query;
......@@ -36,7 +46,7 @@ class SQLQuery
* @param string $table : a database table
* @param string name :
*/
public function __construct($table, $query_name = null)
public function __construct(string $table, string $query_name = '')
{
$this->settings['table'] = $table;
$this->name = $query_name;
......@@ -95,12 +105,12 @@ class SQLQuery
unset($this->settings['where'][$name]);
} elseif ($parameter === null && $condition !== null) {
$this->settings['where'][$name] = $name;
$this->settings['parameter'] = array_merge((array) $this->settings['parameter'], $condition);
$this->settings['parameter'] = array_merge($this->settings['parameter'], $condition);
} elseif ($condition === null) {
$this->settings['where'][md5($name)] = $name;
} else {
$this->settings['where'][$name] = $condition;
$this->settings['parameter'] = array_merge((array) $this->settings['parameter'], $parameter);
$this->settings['parameter'] = array_merge($this->settings['parameter'], $parameter);
}
return $this;
}
......@@ -111,12 +121,12 @@ class SQLQuery
unset($this->settings['having'][$name]);
} elseif ($parameter === null && $condition !== null) {
$this->settings['having'][$name] = $name;
$this->settings['parameter'] = array_merge((array) $this->settings['parameter'], $condition);
$this->settings['parameter'] = array_merge($this->settings['parameter'], $condition);
} elseif ($condition === null) {
$this->settings['having'][md5($name)] = $name;
} else {
$this->settings['having'][$name] = $condition;
$this->settings['parameter'] = array_merge((array) $this->settings['parameter'], $parameter);
$this->settings['parameter'] = array_merge($this->settings['parameter'], $parameter);
}
return $this;
}
......@@ -129,7 +139,7 @@ class SQLQuery
public function parameter($param, $value = null)
{
if (is_array($param)) {
$this->settings['parameter'] = array_merge((array) $this->settings['parameter'], $param);
$this->settings['parameter'] = array_merge($this->settings['parameter'], $param);
} else {
$this->settings['parameter'][$param] = $value;
}
......@@ -196,7 +206,7 @@ class SQLQuery
{$this->getQuery()}
) AS counter_table";
$statement = DBManager::get()->prepare($sql);
$statement->execute((array) $this->settings['parameter']);
$statement->execute($this->settings['parameter']);
NotificationCenter::postNotification('SQLQueryDidExecute', $this);
return (int) $statement->fetchColumn();
......@@ -218,7 +228,7 @@ class SQLQuery
$sql = "SELECT `{$this->settings['table']}`.* ";
}
foreach ((array) $this->settings['select'] as $alias => $statement) {
foreach ($this->settings['select'] as $alias => $statement) {
$sql .= $statement ? "{$statement} AS {$alias} " : $alias;
}
......
......@@ -921,7 +921,7 @@ class BlubberThread extends SimpleORMap implements PrivacyObject
'user_id' => $user_id,
'html_id' => "blubberthread_".$this->getId()
]);
$this->last_visit[$user_id] = !$this->last_visit[$user_id]
$this->last_visit[$user_id] = empty($this->last_visit[$user_id])
? object_get_visit($this->getId(), "blubberthread", "last", "", $user_id)
: $this->last_visit[$user_id];
UserConfig::get($user_id)->store("BLUBBERTHREAD_VISITED_".$this->getId(), time());
......
......@@ -1819,6 +1819,7 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate
if ($this->applyCallbacks('before_store') === false) {
return false;
}
$ret = 0;
if (!$this->isDeleted() && ($this->isDirty() || $this->isNew())) {
if ($this->isNew()) {
if ($this->applyCallbacks('before_create') === false) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment