From 4ebb2fa09108d2b6a5e72686cfd813f84b5f9e3a Mon Sep 17 00:00:00 2001 From: Olivier Crouzet Date: Sat, 3 Jun 2023 11:02:30 +0200 Subject: [PATCH] SQL error when no idtype is defined before running alphabetSpec loop In this case, jointure with entities table should be included through ${table} placeholder but $context['table'] is set instead in the sql2 request. We get the following kind of request that provokes an error : SELECT COUNT(titreoeuvre) as nbresults FROM textes WHERE status > 0 AND SUBSTRING(titreoeuvre,1,1) = 'A' --- lodel/scripts/loops.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lodel/scripts/loops.php b/lodel/scripts/loops.php index 980fc81c2..a08d824a0 100644 --- a/lodel/scripts/loops.php +++ b/lodel/scripts/loops.php @@ -851,8 +851,7 @@ function loop_alphabetSpec($context, $funcname) } $status = C::get('editor', 'lodeluser') ? ' status > -64 ' : ' status > 0 '; - $sql2 = lq("SELECT COUNT({$context['field']}) as nbresults FROM #_TP_{$context['table']} WHERE {$whereCount} {$status} AND SUBSTRING({$context['field']},1,1) = "); - + $sql2 = lq("SELECT COUNT({$context['field']}) as nbresults FROM #_TP_{$table} WHERE {$whereCount} {$status} AND SUBSTRING({$context['field']},1,1) = "); $whereSelect .= !empty($whereSelect) ? ' AND '.$status : 'WHERE '.$status; $sql = "SELECT DISTINCT(SUBSTRING({$context['field']},1,1)) as l FROM #_TP_{$table}