diff options
| author | Moritz Strohm <strohm@data-quest.de> | 2022-05-04 14:18:41 +0000 |
|---|---|---|
| committer | Moritz Strohm <strohm@data-quest.de> | 2022-05-04 14:18:41 +0000 |
| commit | 0d95625c2ab0eabe98e724ab79be0087093cc35b (patch) | |
| tree | f911e16bfb52f4aceacf9e9ad4c8d31923e26a6e /lib/classes | |
| parent | e1f835675363c17fbf5d269f6d1d1f84b6727886 (diff) | |
fix for BIESt #957
Merge request studip/studip!554
Diffstat (limited to 'lib/classes')
| -rw-r--r-- | lib/classes/Assets.class.php | 2 | ||||
| -rw-r--r-- | lib/classes/Avatar.class.php | 2 | ||||
| -rw-r--r-- | lib/classes/Log.php | 6 | ||||
| -rw-r--r-- | lib/classes/NotificationCenter.class.php | 9 | ||||
| -rw-r--r-- | lib/classes/PageLayout.php | 2 | ||||
| -rw-r--r-- | lib/classes/RangeConfig.class.php | 4 | ||||
| -rw-r--r-- | lib/classes/Request.class.php | 2 | ||||
| -rw-r--r-- | lib/classes/SemBrowse.class.php | 2 | ||||
| -rw-r--r-- | lib/classes/SkipLinks.php | 16 | ||||
| -rw-r--r-- | lib/classes/Smiley.php | 2 | ||||
| -rw-r--r-- | lib/classes/StudipPDO.class.php | 2 | ||||
| -rw-r--r-- | lib/classes/StudipPDOStatement.php | 2 | ||||
| -rw-r--r-- | lib/classes/URLHelper.php | 10 | ||||
| -rw-r--r-- | lib/classes/Widget.php | 2 | ||||
| -rw-r--r-- | lib/classes/WidgetContainer.php | 16 | ||||
| -rw-r--r-- | lib/classes/calendar/CalendarScheduleModel.php | 2 | ||||
| -rw-r--r-- | lib/classes/helpbar/Helpbar.php | 4 | ||||
| -rw-r--r-- | lib/classes/sidebar/LinkElement.php | 2 | ||||
| -rw-r--r-- | lib/classes/sidebar/SidebarWidget.php | 2 |
19 files changed, 57 insertions, 32 deletions
diff --git a/lib/classes/Assets.class.php b/lib/classes/Assets.class.php index 1d9c23f..dd82073 100644 --- a/lib/classes/Assets.class.php +++ b/lib/classes/Assets.class.php @@ -145,7 +145,7 @@ class Assets $parts = explode('/', $source); - $size = $opt['size']; + $size = $opt['size'] ?? null; $opt = Assets::parse_attributes($opt); diff --git a/lib/classes/Avatar.class.php b/lib/classes/Avatar.class.php index b355a8a..dab3f75 100644 --- a/lib/classes/Avatar.class.php +++ b/lib/classes/Avatar.class.php @@ -244,7 +244,7 @@ class Avatar { $opt['class'] = $this->getCssClass($size); } - if (is_string($opt['title']) && $opt['title'] !== html_entity_decode($opt['title'])) { + if (isset($opt['title']) && $opt['title'] !== html_entity_decode($opt['title'])) { // Decode already htmlready encoded titles (which were used until // all attributes were encoded inside this method) $opt['title'] = html_entity_decode($opt['title']); diff --git a/lib/classes/Log.php b/lib/classes/Log.php index 22c9f6c..335572d 100644 --- a/lib/classes/Log.php +++ b/lib/classes/Log.php @@ -119,9 +119,7 @@ class Log public static function set($name = '', $log_handler = null) { $name = mb_strlen($name) ? $name : 0; - if (isset(self::$instances[$name])) { - $old = self::$instances[$name]; - } + $old = self::$instances[$name] ?? null; self::$instances[$name] = new Log($log_handler); return $old; } @@ -255,4 +253,4 @@ class Log } throw new BadMethodCallException('Unknown method called: ' . $name); } -}
\ No newline at end of file +} diff --git a/lib/classes/NotificationCenter.class.php b/lib/classes/NotificationCenter.class.php index dce878e..aaaa9e8 100644 --- a/lib/classes/NotificationCenter.class.php +++ b/lib/classes/NotificationCenter.class.php @@ -57,6 +57,8 @@ class NotificationCenter $event = ''; } + $predicate = null; + if ($object) { $predicate = is_callable($object) ? $object @@ -65,9 +67,10 @@ class NotificationCenter }; } - self::$observers[$event][] = - ['predicate' => $predicate ?: NULL, - 'observer' => [$observer, $method]]; + self::$observers[$event][] = [ + 'predicate' => $predicate, + 'observer' => [$observer, $method] + ]; } /** diff --git a/lib/classes/PageLayout.php b/lib/classes/PageLayout.php index e40b22b..a8f3ffa 100644 --- a/lib/classes/PageLayout.php +++ b/lib/classes/PageLayout.php @@ -463,7 +463,7 @@ class PageLayout */ public static function isHeaderEnabled() { - return self::$display_header && !$GLOBALS['_NOHEADER']; + return self::$display_header && empty($GLOBALS['_NOHEADER']); } /** diff --git a/lib/classes/RangeConfig.class.php b/lib/classes/RangeConfig.class.php index c384661..fc90434 100644 --- a/lib/classes/RangeConfig.class.php +++ b/lib/classes/RangeConfig.class.php @@ -52,7 +52,7 @@ class RangeConfig extends Config $range_id = $range_id->getRangeId(); } - if (static::$instances[$range_id] === null) { + if (!isset(static::$instances[$range_id])) { static::$instances[$range_id] = new static($range_id); } return static::$instances[$range_id]; @@ -121,7 +121,7 @@ class RangeConfig extends Config } while ($row = $statement->fetch(PDO::FETCH_ASSOC)) { $this->data[$row['field']] = $this->convertFromDatabase( - $this->metadata[$row['field']]['type'], + $this->metadata[$row['field']]['type'] ?? 'string', $row['value'], $row['field'] ); diff --git a/lib/classes/Request.class.php b/lib/classes/Request.class.php index 410a74f..71c593e 100644 --- a/lib/classes/Request.class.php +++ b/lib/classes/Request.class.php @@ -114,7 +114,7 @@ class Request implements ArrayAccess, IteratorAggregate { $host = $_SERVER['SERVER_NAME']; $port = $_SERVER['SERVER_PORT']; - $ssl = $_SERVER['HTTPS'] == 'on'; + $ssl = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on'; if ($ssl && $port != 443 || !$ssl && $port != 80) { $host .= ':' . $port; diff --git a/lib/classes/SemBrowse.class.php b/lib/classes/SemBrowse.class.php index 1bc822b..82b683f 100644 --- a/lib/classes/SemBrowse.class.php +++ b/lib/classes/SemBrowse.class.php @@ -1168,7 +1168,7 @@ class SemBrowse { if (!$option['visible'] || $option['target'] != $target) { return null; } - if (!$option['url']) { + if (empty($option['url'])) { switch ($option_name) { case 'courses': case 'semtree': diff --git a/lib/classes/SkipLinks.php b/lib/classes/SkipLinks.php index c5738b2..e2744b9 100644 --- a/lib/classes/SkipLinks.php +++ b/lib/classes/SkipLinks.php @@ -101,4 +101,20 @@ class SkipLinks } return $GLOBALS['template_factory']->render('skiplinks', compact('navigation')); } + + /** + * Checks if there is another link at the same position and if it is overwritable. + * + * @return boolean true if the link at the same position is overwritable + */ + private static function checkOverwrite($link) + { + if (isset(self::$position[$link['position']])) { + return false; + } + if (empty($link['overwrite'])) { + self::$position[$link['position']] = true; + } + return true; + } } diff --git a/lib/classes/Smiley.php b/lib/classes/Smiley.php index 803a5f4..8d37e4f 100644 --- a/lib/classes/Smiley.php +++ b/lib/classes/Smiley.php @@ -224,7 +224,7 @@ class Smiley */ public static function getShort() { - if (class_exists('DBManager') && !$GLOBALS['SMILEY_NO_DB']) { + if (class_exists('DBManager') && empty($GLOBALS['SMILEY_NO_DB'])) { if (self::$shortnames === null) { $query = "SELECT short_name, smiley_name FROM smiley WHERE short_name != ''"; self::$shortnames = DBManager::get()->query($query)->fetchGrouped(PDO::FETCH_COLUMN); diff --git a/lib/classes/StudipPDO.class.php b/lib/classes/StudipPDO.class.php index c73bb7e..8e67c34 100644 --- a/lib/classes/StudipPDO.class.php +++ b/lib/classes/StudipPDO.class.php @@ -43,7 +43,7 @@ class StudipPDO extends PDO // method that is executed on every call to the database) $this->query_count += 1; - if ($GLOBALS['DEBUG_ALL_DB_QUERIES']) { + if (!empty($GLOBALS['DEBUG_ALL_DB_QUERIES'])) { $trace = debug_backtrace(); $classes = []; diff --git a/lib/classes/StudipPDOStatement.php b/lib/classes/StudipPDOStatement.php index 51972ed..5aab1cc 100644 --- a/lib/classes/StudipPDOStatement.php +++ b/lib/classes/StudipPDOStatement.php @@ -118,6 +118,8 @@ class StudipPDOStatement implements IteratorAggregate } // emulate prepared statement if necessary + $emulate_prepare = false; + foreach ($this->params as $key => $param) { if ($param['type'] === StudipPDO::PARAM_ARRAY || $param['type'] === StudipPDO::PARAM_COLUMN || diff --git a/lib/classes/URLHelper.php b/lib/classes/URLHelper.php index a36cc10..ae83022 100644 --- a/lib/classes/URLHelper.php +++ b/lib/classes/URLHelper.php @@ -169,8 +169,14 @@ class URLHelper { $link_params = $ignore_registered_params ? [] : self::$params; - list($url, $fragment) = explode('#', $url); - list($url, $query) = explode('?', $url); + // Separate the query and the fragment parts (if any) from the main part of the URL + if (strpos($url, '#') !== false) { + list($url, $fragment) = explode('#', $url); + } + + if (strpos($url, '?') !== false) { + list($url, $query) = explode('?', $url); + } if ($url !== '') { $url = self::resolveURL($url); diff --git a/lib/classes/Widget.php b/lib/classes/Widget.php index 90f3d56..f2dd3f0 100644 --- a/lib/classes/Widget.php +++ b/lib/classes/Widget.php @@ -231,7 +231,7 @@ class Widget public function __get($offset) { - return $this->template_variables[$offset]; + return $this->template_variables[$offset] ?? null; } public function __set($offset, $value) diff --git a/lib/classes/WidgetContainer.php b/lib/classes/WidgetContainer.php index 5287305..1b0578e 100644 --- a/lib/classes/WidgetContainer.php +++ b/lib/classes/WidgetContainer.php @@ -24,12 +24,12 @@ abstract class WidgetContainer public static function Get() { $class = get_called_class(); - if (static::$instances[$class] === null) { + if (!isset(static::$instances[$class])) { static::$instances[$class] = new static; } return static::$instances[$class]; } - + /** * Private constructor to ensure that the singleton Get() method is always * used. @@ -39,12 +39,12 @@ abstract class WidgetContainer protected function __construct() { } - + /** * Contains the widgets of the container */ protected $widgets = []; - + /** * Add a widget to the container. * @@ -75,9 +75,9 @@ abstract class WidgetContainer public function insertWidget(Widget $widget, $before_index, $index = null) { $index = $index ?: $this->guessIndex($widget); - + $inserted = false; - + $widgets = []; foreach ($this->widgets as $idx => $wdgt) { if ($idx === $before_index) { @@ -96,7 +96,7 @@ abstract class WidgetContainer } $this->widgets = $widgets; - + return $widget; } @@ -151,7 +151,7 @@ abstract class WidgetContainer * * @param String $index Index/name of the widget to remove. * @throws Exception if the specified position is invalid - */ + */ public function removeWidget($index) { if (!isset($this->widgets[$index])) { diff --git a/lib/classes/calendar/CalendarScheduleModel.php b/lib/classes/calendar/CalendarScheduleModel.php index 20f66c5..04c44b7 100644 --- a/lib/classes/calendar/CalendarScheduleModel.php +++ b/lib/classes/calendar/CalendarScheduleModel.php @@ -789,7 +789,7 @@ class CalendarScheduleModel $view = new CalendarWeekView($entries, 'schedule'); - $view->setHeight(40 + (20 * $schedule_settings['zoom'])); + $view->setHeight(40 + (20 * ($schedule_settings['zoom'] ?? 0))); $view->setRange($schedule_settings['glb_start_time'], $schedule_settings['glb_end_time']); $view->setInsertFunction("function (entry, column, hour, end_hour) { STUDIP.Schedule.newEntry(entry, column, hour, end_hour) diff --git a/lib/classes/helpbar/Helpbar.php b/lib/classes/helpbar/Helpbar.php index d2161fa..e01ad56 100644 --- a/lib/classes/helpbar/Helpbar.php +++ b/lib/classes/helpbar/Helpbar.php @@ -31,9 +31,9 @@ class Helpbar extends WidgetContainer $route = get_route(); $help_content = HelpContent::getContentByRoute(); foreach ($help_content as $row) { - $this->addPlainText($row['label'] ?: '', + $this->addPlainText('', $this->interpolate($row['content'], $this->variables), - $row['icon'] ? Icon::create($row['icon'], 'info_alt') : null, + null, URLHelper::getURL('dispatch.php/help_content/edit/'.$row['content_id'], ['from' => $route]), URLHelper::getURL('dispatch.php/help_content/delete/'.$row['content_id'], ['from' => $route])); } diff --git a/lib/classes/sidebar/LinkElement.php b/lib/classes/sidebar/LinkElement.php index b38a145..8b20dbe 100644 --- a/lib/classes/sidebar/LinkElement.php +++ b/lib/classes/sidebar/LinkElement.php @@ -151,7 +151,7 @@ class LinkElement extends WidgetElement implements ArrayAccess */ public function addClass($class) { - $this->attributes['class'] = $this->attributes['class'] + $this->attributes['class'] = isset($this->attributes['class']) ? $this->attributes['class'] . " " . $class : $class; return $this; diff --git a/lib/classes/sidebar/SidebarWidget.php b/lib/classes/sidebar/SidebarWidget.php index 026ca0c..00735ac 100644 --- a/lib/classes/sidebar/SidebarWidget.php +++ b/lib/classes/sidebar/SidebarWidget.php @@ -91,7 +91,7 @@ class SidebarWidget extends Widget */ public function render($variables = []) { - if ($this->id) { + if (!empty($this->id)) { $this->template_variables['id'] = $this->id; } return parent::render($variables); |
