Skip to content

Commit f8d0377

Browse files
committed
more robust empty check if array is null or 0 count, fixes Uncaught TypeError: sizeof()
1 parent f95b812 commit f8d0377

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

functions/parse/overlapping_events.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ function checkOverlap($event_date, $event_time, $uid) {
229229
function removeOverlap($ol_start_date, $ol_start_time, $ol_key) {
230230
global $master_array, $overlap_array;
231231
if (isset($overlap_array[$ol_start_date])) {
232-
if (sizeof($overlap_array[$ol_start_date]) > 0) {
232+
if (!empty($overlap_array[$ol_start_date])) {
233233
$ol_end_time = $master_array[$ol_start_date][$ol_start_time][$ol_key]['event_end'];
234234
foreach ($overlap_array[$ol_start_date] as $block_key => $block) {
235235
if (in_array(array('time' => $ol_start_time, 'key' => $ol_key), $block['events'])) {

functions/template.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ function draw_week($template_p) {
429429
}
430430
} else {
431431
# events that start in internal cal_times the grid
432-
if (isset($master_array[$thisday][$cal_time]) && sizeof($master_array[$thisday][$cal_time]) > 0) {
432+
if (!empty($master_array[$thisday][$cal_time])) {
433433
$this_time_arr = $master_array[$thisday][$cal_time];
434434
}
435435
}
@@ -654,7 +654,7 @@ function draw_day($template_p) {
654654
}
655655

656656
// check for eventstart
657-
if (isset($this_time_arr) && sizeof($this_time_arr) > 0) {
657+
if (!empty($this_time_arr)) {
658658
foreach ($this_time_arr as $eventKey => $loopevent) {
659659
$drawEvent = drawEventTimes ($cal_time, $loopevent['display_end']);
660660
$j = 0;
@@ -703,7 +703,7 @@ function draw_day($template_p) {
703703
break;
704704
}
705705

706-
if (sizeof($event_length) == 0) {
706+
if (empty($event_length)) {
707707
$daydisplay .= '<td colspan="' . $nbrGridCols . '"' . $class . '>&nbsp;</td>' . "\n";
708708

709709
} else {
@@ -803,7 +803,7 @@ function tomorrows_events() {
803803
$return_adtmp = '';
804804
$return_etmp = '';
805805

806-
if (isset($master_array[$next_day]) && is_array($master_array[$next_day]) && sizeof($master_array[$next_day]) > 0) {
806+
if (!empty($master_array[$next_day]) && is_array($master_array[$next_day])) {
807807
foreach ($master_array[$next_day] as $cal_time => $event_times) {
808808
foreach ($event_times as $uid => $val) {
809809
$event_text = sanitizeForWeb(stripslashes(urldecode($val['event_text'])));
@@ -1172,7 +1172,7 @@ function parse($file) {
11721172
}
11731173

11741174
function replace_tags($tags = array()) {
1175-
if (sizeof($tags) > 0)
1175+
if (!empty($tags))
11761176
foreach ($tags as $tag => $data) {
11771177

11781178
// This removes any unfilled tags
@@ -1189,7 +1189,7 @@ function replace_tags($tags = array()) {
11891189
}
11901190

11911191
function replace_files($tags = array()) {
1192-
if (sizeof($tags) > 0)
1192+
if (!empty($tags))
11931193
foreach ($tags as $tag => $data) {
11941194

11951195
// This opens up another template and parses it as well.
@@ -1213,7 +1213,7 @@ function output() {
12131213

12141214
// Looks for {MONTH} before sending page out
12151215
preg_match_all ('!\{MONTH_([A-Z]*)\|?([+|-])([0-9]{1,2})\}!Uis', $this->page, $match);
1216-
if (sizeof($match) > 0) {
1216+
if (!empty($match)) {
12171217
$i=0;
12181218
foreach ($match[1] as $key => $val) {
12191219
if ($match[1][$i] == 'SMALL') {

includes/event.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@
6262
$attendee = implode(', ',$attendees);
6363
}
6464
if (isset($event['location'])) $event['location'] = stripslashes($event['location']);
65-
if (sizeof($attendee) == 0) $attendee = '';
66-
if (sizeof($organizer) == 0) $organizer = '';
65+
if (empty($attendee)) $attendee = '';
66+
if (empty($organizer)) $organizer = '';
6767
if ($event['url'] != '') $event['url'] = '<a href="'.$event['url'].'" target="_blank">'.$event['url'].'</a>';
6868

6969
switch ($event['status']){

rss/rss_common.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@
161161
$thisdate=date('Ymd', $thistime);
162162
# echo "Date: $thisdate\ti:$i\tnumdays:$numdays<br>\n";
163163
$dayofweek = localizeDate ("%a %b %e %Y", strtotime($thisdate));
164-
if (isset($master_array[($thisdate)]) && sizeof($master_array[($thisdate)]) > 0) {
164+
if (!empty($master_array[($thisdate)])) {
165165
foreach ($master_array[("$thisdate")] as $event_times) {
166166
foreach ($event_times as $uid=>$val) {
167167
#handle multiday all day events

search.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,9 @@ function search_boolean($needle_arr, $haystack) {
177177
$not_arr = $needle_arr[3];
178178

179179
if (!$needle_arr[0]) return false;
180-
if ((sizeof($and_arr) == 0) &&
181-
(sizeof($or_arr) == 0) &&
182-
(sizeof($not_arr) == 0)) return false;
180+
if ((empty($and_arr)) &&
181+
(empty($or_arr)) &&
182+
(empty($not_arr))) return false;
183183

184184
// compare lowercase versions of the strings
185185
$haystack = strtolower($haystack);

0 commit comments

Comments
 (0)