diff --git a/app/controllers/blubber.php b/app/controllers/blubber.php index 35a8d7e573d2dd3d8467d6642b47bb009649cb80..4341b73576e5a9b3d71329685f6cda81460c5635 100644 --- a/app/controllers/blubber.php +++ b/app/controllers/blubber.php @@ -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) diff --git a/app/controllers/course/messenger.php b/app/controllers/course/messenger.php index 0bfd3f5e2c3516c8291adbbc2e3f9d6d51e9bbdb..42f313d926186daacfba3b4633e7db921c06d6eb 100644 --- a/app/controllers/course/messenger.php +++ b/app/controllers/course/messenger.php @@ -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; diff --git a/lib/classes/BlubberFormat.php b/lib/classes/BlubberFormat.php index 4a52286d39c0f08fcd07cae713a27d78690765e9..bd8ba5c5c64c898c0b46a7e7f052a4aaad703d9a 100644 --- a/lib/classes/BlubberFormat.php +++ b/lib/classes/BlubberFormat.php @@ -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 ] ]; diff --git a/lib/classes/Config.class.php b/lib/classes/Config.class.php index f5afaab3ebd17bba6de8f178eadb36a52a4b93eb..a36bde9874e8d515304a14981fd1a45c08a9c297 100644 --- a/lib/classes/Config.class.php +++ b/lib/classes/Config.class.php @@ -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] ?? []; } /** diff --git a/lib/classes/RangeConfig.class.php b/lib/classes/RangeConfig.class.php index fc90434cf68002d42e502b9f455d98e0412958ed..a1e1bb9b300bdf795695ca7f680039358b6059a1 100644 --- a/lib/classes/RangeConfig.class.php +++ b/lib/classes/RangeConfig.class.php @@ -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) { diff --git a/lib/classes/SQLQuery.php b/lib/classes/SQLQuery.php index a6539fb171b0c9dfccb4afc205c50fd2c884fd53..3a09fd9568b814b74254861c62939eb1788c1b12 100755 --- a/lib/classes/SQLQuery.php +++ b/lib/classes/SQLQuery.php @@ -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; } diff --git a/lib/models/BlubberThread.php b/lib/models/BlubberThread.php index 430950fdcccdddb96f113839e3c0cf228fd87eb6..1ff28bea999d2823e87686aeb4fbb91779d5f8d5 100644 --- a/lib/models/BlubberThread.php +++ b/lib/models/BlubberThread.php @@ -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()); diff --git a/lib/models/SimpleORMap.class.php b/lib/models/SimpleORMap.class.php index 16eeadf711c4391045329c406a723862af9a9d2b..3a28ebd94bb75332e5fbcd43f2127d6d058fa22f 100644 --- a/lib/models/SimpleORMap.class.php +++ b/lib/models/SimpleORMap.class.php @@ -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) {