some PHP 8 fixes
This commit is contained in:
parent
22d4608f9f
commit
6bb4774d7e
|
@ -1719,7 +1719,9 @@ addLoadEvent(enableAutocomplete);
|
|||
|
||||
$tags = array();
|
||||
foreach((array)$rows as $r) {
|
||||
$tags[$r['tag']] = $r['total'];
|
||||
if (is_array($r)) {
|
||||
$tags[$r['tag']] = $r['total'];
|
||||
}
|
||||
}
|
||||
|
||||
return $tags;
|
||||
|
|
|
@ -552,7 +552,7 @@ class serendipity_event_geotag extends serendipity_event
|
|||
foreach($eventData as $i => &$myEvent) {
|
||||
if ($i !== 'clean_page') {
|
||||
// Check if geo_lat and geo_long are both set
|
||||
$props = $myEvent['properties'];
|
||||
$props = $myEvent['properties'] ?? null;
|
||||
$geotagged = true;
|
||||
foreach($this->supported_properties AS $prop_key) {
|
||||
if (!isset($props[$prop_key])) {
|
||||
|
@ -572,10 +572,10 @@ class serendipity_event_geotag extends serendipity_event
|
|||
}
|
||||
return true;
|
||||
case 'frontend_header':
|
||||
if (!$serendipity['GET']['id'] && $serendipity['view'] != 'entry') {
|
||||
if (!($serendipity['GET']['id'] ?? 0) && $serendipity['view'] != 'entry') {
|
||||
$lat = $this->get_config('hdr_default_lat');
|
||||
$long = $this->get_config('hdr_default_long');
|
||||
$this->headerGeoTagging($lat,$long, $GLOBALS['serendipity']['blogTitle']);
|
||||
$this->headerGeoTagging($lat, $long, $GLOBALS['serendipity']['blogTitle']);
|
||||
return true;
|
||||
}
|
||||
// we fetch the internal smarty object to get the current entry body
|
||||
|
@ -844,7 +844,7 @@ class serendipity_event_geotag extends serendipity_event
|
|||
*/
|
||||
function getCacheDirectory(){
|
||||
global $serendipity;
|
||||
if ($this->cache_dir === null) {
|
||||
if (($this->cache_dir ?? null) === null) {
|
||||
$this->cache_dir = $serendipity['serendipityPath'] . PATH_SMARTY_COMPILE . '/serendipity_event_geotag';
|
||||
}
|
||||
return $this->cache_dir;
|
||||
|
|
|
@ -266,6 +266,9 @@ class serendipity_event_lightbox extends serendipity_event
|
|||
break;
|
||||
|
||||
case 'frontend_display':
|
||||
if (!isset($eventData['id'])) {
|
||||
$eventData['id'] = 0; // TODO: PHP8 hotfix; id is not always set
|
||||
}
|
||||
if ($type == 'lightbox2jq') {
|
||||
if ($navigate == 'entry') {
|
||||
$sub = '<a $1 rel=$3lightbox[' . $eventData['id'] . ']$3 $2';
|
||||
|
@ -294,7 +297,7 @@ class serendipity_event_lightbox extends serendipity_event
|
|||
|
||||
foreach ($this->markup_elements as $temp) {
|
||||
if (isset($eventData[$temp['element']]) && serendipity_db_bool($this->get_config($temp['name'], 'true')) &&
|
||||
!$eventData['properties']['ep_disable_markup_' . $this->instance] &&
|
||||
(isset($eventData['properties']) && isset($eventData['properties']['ep_disable_markup_' . $this->instance]) && !$eventData['properties']['ep_disable_markup_' . $this->instance]) && // TODO: please test
|
||||
!isset($serendipity['POST']['properties']['disable_markup_' . $this->instance])) {
|
||||
$element = $temp['element'];
|
||||
|
||||
|
|
|
@ -148,7 +148,7 @@ class serendipity_event_metadesc extends serendipity_event {
|
|||
$default_keywords = $this->get_config('default_keywords');
|
||||
|
||||
// Only emit in Single Entry Mode
|
||||
if ($serendipity['GET']['id'] && $serendipity['view'] == 'entry') {
|
||||
if (($serendipity['GET']['id'] ?? 0) && $serendipity['view'] == 'entry') {
|
||||
// we fetch the internal smarty object to get the current entry body
|
||||
$entry = (array)$eventData['smarty']->tpl_vars['entry']->value;
|
||||
|
||||
|
@ -164,7 +164,7 @@ class serendipity_event_metadesc extends serendipity_event {
|
|||
);
|
||||
}
|
||||
|
||||
$meta_description = $entry['properties']['meta_description'];
|
||||
$meta_description = $entry['properties']['meta_description'] ?? '';
|
||||
if (empty($meta_description)) {
|
||||
$description_body = $entry['body'];
|
||||
if (isset($entry['plaintext_body'])) {
|
||||
|
@ -173,7 +173,7 @@ class serendipity_event_metadesc extends serendipity_event {
|
|||
$meta_description = $this->extract_description($description_body);
|
||||
}
|
||||
|
||||
$meta_keywords = $entry['properties']['meta_keywords'];
|
||||
$meta_keywords = $entry['properties']['meta_keywords'] ?? '';
|
||||
if (empty($meta_keywords)) {
|
||||
$meta_keywords = (array)$this->extract_keywords($entry['body']);
|
||||
if (!empty($meta_keywords))
|
||||
|
@ -233,7 +233,7 @@ class serendipity_event_metadesc extends serendipity_event {
|
|||
$prop_val = (isset($serendipity['POST']['properties'][$prop_key]) ? $serendipity['POST']['properties'][$prop_key] : null);
|
||||
if (!isset($property[$prop_key]) && !empty($prop_val)) {
|
||||
$q = "INSERT INTO {$serendipity['dbPrefix']}entryproperties (entryid, property, value) VALUES (" . (int)$eventData['id'] . ", '" . serendipity_db_escape_string($prop_key) . "', '" . serendipity_db_escape_string($prop_val) . "')";
|
||||
} elseif ($property[$propkey] != $prop_val && !empty($prop_val)) {
|
||||
} elseif (($property[$prop_key] ?? null) != $prop_val && !empty($prop_val)) {
|
||||
$q = "UPDATE {$serendipity['dbPrefix']}entryproperties SET value = '" . serendipity_db_escape_string($prop_val) . "' WHERE entryid = " . (int)$eventData['id'] . " AND property = '" . serendipity_db_escape_string($prop_key) . "'";
|
||||
} elseif (!empty($property[$prop_key]) && isset($prop_val) && empty($prop_val)) {
|
||||
$q = "DELETE FROM {$serendipity['dbPrefix']}entryproperties WHERE entryid = " . (int)$eventData['id'] . " AND property = '" . serendipity_db_escape_string($prop_key) . "'";
|
||||
|
|
|
@ -499,7 +499,11 @@ class serendipity_event_staticpage extends serendipity_event
|
|||
{
|
||||
global $serendipity;
|
||||
|
||||
return (($user['userlevel'] < $serendipity['serendipityUserlevel']) || ($user['authorid'] == $serendipity['authorid']) || ($serendipity['serendipityUserlevel'] >= USERLEVEL_ADMIN));
|
||||
return (
|
||||
($user['userlevel'] < ($serendipity['serendipityUserlevel'] ?? null)) ||
|
||||
($user['authorid'] == ($serendipity['authorid'] ?? null)) ||
|
||||
(($serendipity['serendipityUserlevel'] ?? null) >= USERLEVEL_ADMIN)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1650,7 +1654,9 @@ class serendipity_event_staticpage extends serendipity_event
|
|||
$serendipity['POST']['staticpage'] = $pid = serendipity_db_insert_id('staticpages', 'id');
|
||||
serendipity_plugin_api::hook_event('backend_staticpages_insert', $insert_page);
|
||||
} else {
|
||||
@unlink($this->cachefile);
|
||||
if (file_exists($this->cachefile)) {
|
||||
@unlink($this->cachefile);
|
||||
}
|
||||
$pid = $insert_page['id'];
|
||||
$result = serendipity_db_update('staticpages', array('id' => $insert_page['id']), $insert_page);
|
||||
serendipity_plugin_api::hook_event('backend_staticpages_update', $insert_page);
|
||||
|
@ -2549,7 +2555,7 @@ foreach($select AS $select_value => $select_desc) {
|
|||
|
||||
// Code copied from include/admin/plugins.inc.php. Sue me. ;-)
|
||||
|
||||
if ($value_func == 'get_static' && $serendipity['POST']['backend_template'] != 'internal') {
|
||||
if ($value_func == 'get_static' && ($serendipity['POST']['backend_template'] ?? null) != 'internal') {
|
||||
serendipity_smarty_init();
|
||||
$serendipity['smarty']->register_modifier('in_array', 'in_array');
|
||||
$serendipity['smarty']->register_function('staticpage_input', array($this, 'SmartyInspectConfig'));
|
||||
|
@ -2558,7 +2564,7 @@ foreach($select AS $select_value => $select_desc) {
|
|||
$serendipity['smarty']->assign('is_wysiwyg', $serendipity['wysiwyg']);
|
||||
}
|
||||
|
||||
$filename = preg_replace('@[^a-z0-9\._-]@i', '', $serendipity['POST']['backend_template']);
|
||||
$filename = isset($serendipity['POST']['backend_template']) ? preg_replace('@[^a-z0-9\._-]@i', '', $serendipity['POST']['backend_template']) : '';
|
||||
if ($filename == 'external' || empty($filename)) {
|
||||
$filename = 'default_staticpage_backend.tpl';
|
||||
}
|
||||
|
|
|
@ -158,7 +158,7 @@ class serendipity_event_twitter extends serendipity_plugin {
|
|||
'general_title', 'plugin_rel_url', 'general_oa_consumerdesc', 'general_oa_consumerkey', 'general_oa_consumersecret'
|
||||
);
|
||||
|
||||
switch ($_GET['plugintab']) {
|
||||
switch ($_GET['plugintab'] ?? '') {
|
||||
case 'announce':
|
||||
$configuration = array_merge($configuration,
|
||||
$config_announce
|
||||
|
|
Loading…
Reference in a new issue