Fossil SCM
A proposed solution to the problem of /setup_ulist fails for repos with no subscriber table. Reported in [forum:e2b0008592f6a776|forum post e2b0008592f6a776].
Commit
e50a5aac379e7002ce78fcb88f2d0c557c488874336055ab2dbbd312b1360d89
Parent
b8351f0cbf488a3…
1 file changed
+19
-15
+19
-15
| --- src/setupuser.c | ||
| +++ src/setupuser.c | ||
| @@ -41,21 +41,22 @@ | ||
| 41 | 41 | Stmt s; |
| 42 | 42 | double rNow; |
| 43 | 43 | const char *zWith = P("with"); |
| 44 | 44 | int bUnusedOnly = P("unused")!=0; |
| 45 | 45 | int bUbg = P("ubg")!=0; |
| 46 | + int bHaveAlerts; | |
| 46 | 47 | |
| 47 | 48 | login_check_credentials(); |
| 48 | 49 | if( !g.perm.Admin ){ |
| 49 | 50 | login_needed(0); |
| 50 | 51 | return; |
| 51 | 52 | } |
| 52 | - | |
| 53 | + bHaveAlerts = alert_tables_exist(); | |
| 53 | 54 | style_submenu_element("Add", "setup_uedit"); |
| 54 | 55 | style_submenu_element("Log", "access_log"); |
| 55 | 56 | style_submenu_element("Help", "setup_ulist_notes"); |
| 56 | - if( alert_tables_exist() ){ | |
| 57 | + if( bHaveAlerts ){ | |
| 57 | 58 | style_submenu_element("Subscribers", "subscribers"); |
| 58 | 59 | } |
| 59 | 60 | style_set_current_feature("setup"); |
| 60 | 61 | style_header("User List"); |
| 61 | 62 | if( (zWith==0 || zWith[0]==0) && !bUnusedOnly ){ |
| @@ -147,31 +148,34 @@ | ||
| 147 | 148 | zWith = mprintf( |
| 148 | 149 | " AND login NOT IN (" |
| 149 | 150 | "SELECT user FROM event WHERE user NOT NULL " |
| 150 | 151 | "UNION ALL SELECT euser FROM event WHERE euser NOT NULL%s)" |
| 151 | 152 | " AND uid NOT IN (SELECT uid FROM rcvfrom)", |
| 152 | - alert_tables_exist() ? | |
| 153 | + bHaveAlerts ? | |
| 153 | 154 | " UNION ALL SELECT suname FROM subscriber WHERE suname NOT NULL":""); |
| 154 | 155 | }else if( zWith && zWith[0] ){ |
| 155 | 156 | zWith = mprintf(" AND fullcap(cap) GLOB '*[%q]*'", zWith); |
| 156 | 157 | }else{ |
| 157 | 158 | zWith = ""; |
| 158 | 159 | } |
| 159 | 160 | db_prepare(&s, |
| 160 | - "SELECT uid, login, cap, info, date(user.mtime,'unixepoch')," /* 0..4 */ | |
| 161 | - " lower(login) AS sortkey, " /* 5 */ | |
| 162 | - " CASE WHEN info LIKE '%%expires 20%%'" | |
| 161 | + /*0-4*/"SELECT uid, login, cap, info, date(user.mtime,'unixepoch')," | |
| 162 | + /* 5 */"lower(login) AS sortkey, " | |
| 163 | + /* 6 */"CASE WHEN info LIKE '%%expires 20%%'" | |
| 163 | 164 | " THEN substr(info,instr(lower(info),'expires')+8,10)" |
| 164 | - " END AS exp," /* 6 */ | |
| 165 | - "atime," /* 7 */ | |
| 166 | - " subscriber.ssub, subscriber.subscriberId," /* 8, 9 */ | |
| 167 | - " user.mtime AS sorttime," /* 10 */ | |
| 168 | - " subscriber.semail" /* 11 */ | |
| 169 | - " FROM user LEFT JOIN lastAccess ON login=uname" | |
| 170 | - " LEFT JOIN subscriber ON login=suname" | |
| 171 | - " WHERE login NOT IN ('anonymous','nobody','developer','reader') %s" | |
| 172 | - " ORDER BY sorttime DESC", zWith/*safe-for-%s*/ | |
| 165 | + " END AS exp," | |
| 166 | + /* 7 */"atime," | |
| 167 | + /*8,9*/"%s," | |
| 168 | + /* 10*/"user.mtime AS sorttime," | |
| 169 | + /* 11*/"%s" | |
| 170 | + " FROM user LEFT JOIN lastAccess ON login=uname" | |
| 171 | + " LEFT JOIN subscriber ON login=suname" | |
| 172 | + " WHERE login NOT IN ('anonymous','nobody','developer','reader') %s" | |
| 173 | + " ORDER BY sorttime DESC", | |
| 174 | + bHaveAlerts ? "subscriber.ssub, subscriber.subscriberId" : "null, null", | |
| 175 | + bHaveAlerts ? "subscriber.semail" : "null", | |
| 176 | + zWith/*safe-for-%s*/ | |
| 173 | 177 | ); |
| 174 | 178 | rNow = db_double(0.0, "SELECT julianday('now');"); |
| 175 | 179 | while( db_step(&s)==SQLITE_ROW ){ |
| 176 | 180 | int uid = db_column_int(&s, 0); |
| 177 | 181 | const char *zLogin = db_column_text(&s, 1); |
| 178 | 182 |
| --- src/setupuser.c | |
| +++ src/setupuser.c | |
| @@ -41,21 +41,22 @@ | |
| 41 | Stmt s; |
| 42 | double rNow; |
| 43 | const char *zWith = P("with"); |
| 44 | int bUnusedOnly = P("unused")!=0; |
| 45 | int bUbg = P("ubg")!=0; |
| 46 | |
| 47 | login_check_credentials(); |
| 48 | if( !g.perm.Admin ){ |
| 49 | login_needed(0); |
| 50 | return; |
| 51 | } |
| 52 | |
| 53 | style_submenu_element("Add", "setup_uedit"); |
| 54 | style_submenu_element("Log", "access_log"); |
| 55 | style_submenu_element("Help", "setup_ulist_notes"); |
| 56 | if( alert_tables_exist() ){ |
| 57 | style_submenu_element("Subscribers", "subscribers"); |
| 58 | } |
| 59 | style_set_current_feature("setup"); |
| 60 | style_header("User List"); |
| 61 | if( (zWith==0 || zWith[0]==0) && !bUnusedOnly ){ |
| @@ -147,31 +148,34 @@ | |
| 147 | zWith = mprintf( |
| 148 | " AND login NOT IN (" |
| 149 | "SELECT user FROM event WHERE user NOT NULL " |
| 150 | "UNION ALL SELECT euser FROM event WHERE euser NOT NULL%s)" |
| 151 | " AND uid NOT IN (SELECT uid FROM rcvfrom)", |
| 152 | alert_tables_exist() ? |
| 153 | " UNION ALL SELECT suname FROM subscriber WHERE suname NOT NULL":""); |
| 154 | }else if( zWith && zWith[0] ){ |
| 155 | zWith = mprintf(" AND fullcap(cap) GLOB '*[%q]*'", zWith); |
| 156 | }else{ |
| 157 | zWith = ""; |
| 158 | } |
| 159 | db_prepare(&s, |
| 160 | "SELECT uid, login, cap, info, date(user.mtime,'unixepoch')," /* 0..4 */ |
| 161 | " lower(login) AS sortkey, " /* 5 */ |
| 162 | " CASE WHEN info LIKE '%%expires 20%%'" |
| 163 | " THEN substr(info,instr(lower(info),'expires')+8,10)" |
| 164 | " END AS exp," /* 6 */ |
| 165 | "atime," /* 7 */ |
| 166 | " subscriber.ssub, subscriber.subscriberId," /* 8, 9 */ |
| 167 | " user.mtime AS sorttime," /* 10 */ |
| 168 | " subscriber.semail" /* 11 */ |
| 169 | " FROM user LEFT JOIN lastAccess ON login=uname" |
| 170 | " LEFT JOIN subscriber ON login=suname" |
| 171 | " WHERE login NOT IN ('anonymous','nobody','developer','reader') %s" |
| 172 | " ORDER BY sorttime DESC", zWith/*safe-for-%s*/ |
| 173 | ); |
| 174 | rNow = db_double(0.0, "SELECT julianday('now');"); |
| 175 | while( db_step(&s)==SQLITE_ROW ){ |
| 176 | int uid = db_column_int(&s, 0); |
| 177 | const char *zLogin = db_column_text(&s, 1); |
| 178 |
| --- src/setupuser.c | |
| +++ src/setupuser.c | |
| @@ -41,21 +41,22 @@ | |
| 41 | Stmt s; |
| 42 | double rNow; |
| 43 | const char *zWith = P("with"); |
| 44 | int bUnusedOnly = P("unused")!=0; |
| 45 | int bUbg = P("ubg")!=0; |
| 46 | int bHaveAlerts; |
| 47 | |
| 48 | login_check_credentials(); |
| 49 | if( !g.perm.Admin ){ |
| 50 | login_needed(0); |
| 51 | return; |
| 52 | } |
| 53 | bHaveAlerts = alert_tables_exist(); |
| 54 | style_submenu_element("Add", "setup_uedit"); |
| 55 | style_submenu_element("Log", "access_log"); |
| 56 | style_submenu_element("Help", "setup_ulist_notes"); |
| 57 | if( bHaveAlerts ){ |
| 58 | style_submenu_element("Subscribers", "subscribers"); |
| 59 | } |
| 60 | style_set_current_feature("setup"); |
| 61 | style_header("User List"); |
| 62 | if( (zWith==0 || zWith[0]==0) && !bUnusedOnly ){ |
| @@ -147,31 +148,34 @@ | |
| 148 | zWith = mprintf( |
| 149 | " AND login NOT IN (" |
| 150 | "SELECT user FROM event WHERE user NOT NULL " |
| 151 | "UNION ALL SELECT euser FROM event WHERE euser NOT NULL%s)" |
| 152 | " AND uid NOT IN (SELECT uid FROM rcvfrom)", |
| 153 | bHaveAlerts ? |
| 154 | " UNION ALL SELECT suname FROM subscriber WHERE suname NOT NULL":""); |
| 155 | }else if( zWith && zWith[0] ){ |
| 156 | zWith = mprintf(" AND fullcap(cap) GLOB '*[%q]*'", zWith); |
| 157 | }else{ |
| 158 | zWith = ""; |
| 159 | } |
| 160 | db_prepare(&s, |
| 161 | /*0-4*/"SELECT uid, login, cap, info, date(user.mtime,'unixepoch')," |
| 162 | /* 5 */"lower(login) AS sortkey, " |
| 163 | /* 6 */"CASE WHEN info LIKE '%%expires 20%%'" |
| 164 | " THEN substr(info,instr(lower(info),'expires')+8,10)" |
| 165 | " END AS exp," |
| 166 | /* 7 */"atime," |
| 167 | /*8,9*/"%s," |
| 168 | /* 10*/"user.mtime AS sorttime," |
| 169 | /* 11*/"%s" |
| 170 | " FROM user LEFT JOIN lastAccess ON login=uname" |
| 171 | " LEFT JOIN subscriber ON login=suname" |
| 172 | " WHERE login NOT IN ('anonymous','nobody','developer','reader') %s" |
| 173 | " ORDER BY sorttime DESC", |
| 174 | bHaveAlerts ? "subscriber.ssub, subscriber.subscriberId" : "null, null", |
| 175 | bHaveAlerts ? "subscriber.semail" : "null", |
| 176 | zWith/*safe-for-%s*/ |
| 177 | ); |
| 178 | rNow = db_double(0.0, "SELECT julianday('now');"); |
| 179 | while( db_step(&s)==SQLITE_ROW ){ |
| 180 | int uid = db_column_int(&s, 0); |
| 181 | const char *zLogin = db_column_text(&s, 1); |
| 182 |