aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2021-03-11 17:51:14 +0000
committerMario <mario@mariovavti.com>2021-03-11 17:51:14 +0000
commitce9b01ce842389ebafa19cbee0c947ed21868fee (patch)
tree22a6fc52286b26ac7ff631c74f79aa576cb456c6
parentf980c2e3de0339536d58c9ba91799106074b239e (diff)
parent024b489af9b5fadc776aa51b135cd6ed306b07b6 (diff)
downloadvolse-hubzilla-ce9b01ce842389ebafa19cbee0c947ed21868fee.tar.gz
volse-hubzilla-ce9b01ce842389ebafa19cbee0c947ed21868fee.tar.bz2
volse-hubzilla-ce9b01ce842389ebafa19cbee0c947ed21868fee.zip
Merge branch 'php8fixes' into 'dev'
Stricter item array checks See merge request hubzilla/core!1925
-rw-r--r--include/items.php38
1 files changed, 19 insertions, 19 deletions
diff --git a/include/items.php b/include/items.php
index a4b026e2e..26d009b55 100644
--- a/include/items.php
+++ b/include/items.php
@@ -1206,10 +1206,10 @@ function encode_item($item,$mirror = false,$zap_compat = false) {
else
$x['comment_scope'] = $c_scope;
- if($item['term'])
- $x['tags'] = encode_item_terms($item['term'],$mirror);
+ if(! empty($item['term']))
+ $x['tags'] = encode_item_terms($item['term'],$mirror);
- if($item['iconfig']) {
+ if(! empty($item['iconfig'])) {
if ($zap_compat) {
for ($y = 0; $y < count($item['iconfig']); $y ++) {
if (preg_match('|^a:[0-9]+:{.*}$|s', $item['iconfig'][$y]['v'])) {
@@ -1217,7 +1217,7 @@ function encode_item($item,$mirror = false,$zap_compat = false) {
}
}
}
- $x['meta'] = encode_item_meta($item['iconfig'],$mirror);
+ $x['meta'] = encode_item_meta($item['iconfig'],$mirror);
}
logger('encode_item: ' . print_r($x,true), LOGGER_DATA);
@@ -2832,11 +2832,11 @@ function tag_deliver($uid, $item_id) {
* Now we've got those out of the way. Let's see if this is a post that's tagged for re-delivery
*/
- $terms = array_merge(get_terms_oftype($item['term'],TERM_MENTION),get_terms_oftype($item['term'],TERM_FORUM));
-
- if($terms)
+ $terms = [];
+ if (array_key_exists('term', $item)) {
+ $terms = array_merge(get_terms_oftype($item['term'],TERM_MENTION),get_terms_oftype($item['term'],TERM_FORUM));
logger('Post mentions: ' . print_r($terms,true), LOGGER_DATA);
-
+ }
$max_forums = get_config('system','max_tagged_forums',2);
$matched_forums = 0;
@@ -2845,7 +2845,7 @@ function tag_deliver($uid, $item_id) {
$link = normalise_link($u[0]['xchan_url']);
- if($terms) {
+ if(count($terms) > 0) {
foreach($terms as $term) {
if(! link_compare($term['url'],$link)) {
continue;
@@ -4235,9 +4235,9 @@ function list_post_dates($uid, $wall, $mindate) {
$start_month = datetime_convert('','',$dstart,'Y-m-d');
$end_month = datetime_convert('','',$dend,'Y-m-d');
$str = day_translate(datetime_convert('','',$dnow,'F'));
- if(! $ret[$dyear])
- $ret[$dyear] = array();
- $ret[$dyear][] = array($str,$end_month,$start_month);
+ if(! isset($ret[$dyear]))
+ $ret[$dyear] = [];
+ $ret[$dyear][] = [ $str, $end_month, $start_month ];
$dnow = datetime_convert('','',$dnow . ' -1 month', 'Y-m-d');
}
@@ -4316,17 +4316,17 @@ function fetch_post_tags($items, $link = false) {
foreach($tags as $t) {
if(($link) && ($t['ttype'] == TERM_MENTION))
$t['url'] = chanlink_url($t['url']);
- if(array_key_exists('item_id',$items[$x])) {
+ if(array_key_exists('item_id', $items[$x])) {
if($t['oid'] == $items[$x]['item_id']) {
- if(! is_array($items[$x]['term']))
- $items[$x]['term'] = array();
+ if(array_key_exists('term', $items[$x]) && ! is_array($items[$x]['term']))
+ $items[$x]['term'] = [];
$items[$x]['term'][] = $t;
}
}
else {
if($t['oid'] == $items[$x]['id']) {
- if(! is_array($items[$x]['term']))
- $items[$x]['term'] = array();
+ if(array_key_exists('term', $items[$x]) && ! is_array($items[$x]['term']))
+ $items[$x]['term'] = [];
$items[$x]['term'][] = $t;
}
}
@@ -4344,8 +4344,8 @@ function fetch_post_tags($items, $link = false) {
}
else {
if($i['iid'] == $items[$x]['id']) {
- if(! is_array($items[$x]['iconfig']))
- $items[$x]['iconfig'] = array();
+ if(array_key_exists('iconfig', $items[$x]) && ! is_array($items[$x]['iconfig']))
+ $items[$x]['iconfig'] = [];
$i['v'] = ((preg_match('|^a:[0-9]+:{.*}$|s',$i['v'])) ? unserialize($i['v']) : $i['v']);
$items[$x]['iconfig'][] = $i;
}