Skip to content

Commit

Permalink
Bug fix: global categories were not loading
Browse files Browse the repository at this point in the history
- After changing cat_owner from an empty string to a NULL, they were not being loaded
  • Loading branch information
craigk5n committed Feb 10, 2025
1 parent 8e9c5ef commit b21f2f5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2471,7 +2471,7 @@ function get_categories_by_id ( $id, $user, $asterisk = false ) {

$res = dbi_execute ( 'SELECT wc.cat_name, wc.cat_id, wec.cat_owner
FROM webcal_categories wc, webcal_entry_categories wec WHERE wec.cal_id = ?
AND wec.cat_id = wc.cat_id AND ( wc.cat_owner = ? OR wc.cat_owner = \'\' )
AND wec.cat_id = wc.cat_id AND ( wc.cat_owner = ? OR (wc.cat_owner = \'\' OR wc.cat_owner IS NULL) )
ORDER BY wec.cat_order', [$id, ( empty ( $user ) ? $login : $user )] );
while ( $row = dbi_fetch_row ( $res ) ) {
$categories[ ( empty ( $row[2] ) ? - $row[1] : $row[1] ) ] = $row[0]
Expand Down Expand Up @@ -4207,10 +4207,11 @@ function load_user_categories ( $ex_global = '' ) {
$query_params = [];
$query_params[] = ( ( ! empty ( $user ) && strlen ( $user ) ) &&
( $is_assistant || $is_admin ) ? $user : $login );
$rows = dbi_get_cached_rows ( 'SELECT cat_id, cat_name, cat_owner, cat_color, cat_icon_mime
$sql = 'SELECT cat_id, cat_name, cat_owner, cat_color, cat_icon_mime
FROM webcal_categories WHERE ( cat_owner = ? ) ' . ( $ex_global == ''
? 'OR ( cat_owner = \'\' ) ORDER BY cat_owner,' : 'ORDER BY' )
. ' cat_name', $query_params );
? 'OR ( cat_owner = \'\' OR cat_owner IS NULL ) ORDER BY cat_owner,' : 'ORDER BY' )
. ' cat_name';
$rows = dbi_get_cached_rows ($sql, $query_params);
if ( $rows ) {
for ( $i = 0, $cnt = count ( $rows ); $i < $cnt; $i++ ) {
$row = $rows[$i];
Expand Down

0 comments on commit b21f2f5

Please sign in to comment.