Update get_user_messages.php
This commit is contained in:
@@ -75,7 +75,22 @@ try {
|
|||||||
|
|
||||||
$conversations = $db->fetchAll($sql, $params);
|
$conversations = $db->fetchAll($sql, $params);
|
||||||
|
|
||||||
// Si no hay mensajes, devolver array vacío
|
// Si no hay mensajes, intentar fallback si se pidió paginación con 'before'
|
||||||
|
if (empty($conversations) && $before) {
|
||||||
|
error_log('get_user_messages.php - initial query returned empty, attempting fallback with inclusive <= for before param');
|
||||||
|
try {
|
||||||
|
$sqlFallback = str_replace('c.created_at < :before', 'c.created_at <= :before', $sql);
|
||||||
|
$conversationsFallback = $db->fetchAll($sqlFallback, $params);
|
||||||
|
if (!empty($conversationsFallback)) {
|
||||||
|
error_log('get_user_messages.php - fallback query returned ' . count($conversationsFallback) . ' rows');
|
||||||
|
$conversations = $conversationsFallback;
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
error_log('get_user_messages.php - fallback query failed: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Si todavía no hay mensajes, devolver array vacío
|
||||||
if (empty($conversations)) {
|
if (empty($conversations)) {
|
||||||
echo json_encode(['success' => true, 'data' => [], 'has_more' => false], JSON_UNESCAPED_UNICODE | JSON_PARTIAL_OUTPUT_ON_ERROR);
|
echo json_encode(['success' => true, 'data' => [], 'has_more' => false], JSON_UNESCAPED_UNICODE | JSON_PARTIAL_OUTPUT_ON_ERROR);
|
||||||
exit;
|
exit;
|
||||||
|
|||||||
Reference in New Issue
Block a user