![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/domains/soundstudiopro.com/public_html/ |
<?php
/**
* Check Jabëla's Tracks for Variation Issues
* Specifically checks the 2 tracks created to see why one doesn't show variation button
*/
require_once 'config/database.php';
$pdo = getDBConnection();
// Find Jabëla's user ID
$stmt = $pdo->prepare("SELECT id, name FROM users WHERE name LIKE '%Jab%' OR name LIKE '%jab%' LIMIT 5");
$stmt->execute();
$artists = $stmt->fetchAll(PDO::FETCH_ASSOC);
if (empty($artists)) {
die("Could not find Jabëla in database");
}
echo "<h2>Checking Jabëla's Recent Tracks</h2>";
echo "<hr>";
foreach ($artists as $artist) {
echo "<h3>Artist: {$artist['name']} (ID: {$artist['id']})</h3>";
// Get recent tracks (last 5)
$stmt = $pdo->prepare("
SELECT
mt.id,
mt.task_id,
mt.title,
mt.status,
mt.created_at,
mt.variations_count as stored_variations_count,
(SELECT COUNT(*) FROM audio_variations WHERE track_id = mt.id) as actual_variations_count,
COALESCE(vars.variation_count, 0) as ui_variation_count
FROM music_tracks mt
LEFT JOIN (
SELECT track_id, COUNT(*) as variation_count
FROM audio_variations
GROUP BY track_id
) vars ON mt.id = vars.track_id
WHERE mt.user_id = ?
AND mt.status = 'complete'
ORDER BY mt.created_at DESC
LIMIT 5
");
$stmt->execute([$artist['id']]);
$tracks = $stmt->fetchAll(PDO::FETCH_ASSOC);
if (empty($tracks)) {
echo "<p>No complete tracks found.</p>";
continue;
}
echo "<table border='1' cellpadding='10' style='border-collapse: collapse; width: 100%;'>";
echo "<tr style='background: #f0f0f0;'>";
echo "<th>Track ID</th><th>Task ID</th><th>Title</th><th>Created</th>";
echo "<th>Stored Count</th><th>Actual Count</th><th>UI Count</th><th>Button Shows?</th><th>Issues</th>";
echo "</tr>";
foreach ($tracks as $track) {
$buttonShows = $track['ui_variation_count'] > 0;
$issues = [];
if ($track['stored_variations_count'] != $track['actual_variations_count']) {
$issues[] = "Count mismatch";
}
if ($track['actual_variations_count'] == 0 && $track['stored_variations_count'] > 0) {
$issues[] = "Variations missing";
}
if (!$buttonShows && $track['stored_variations_count'] > 0) {
$issues[] = "Button should show";
}
$rowColor = '';
if (!empty($issues)) {
$rowColor = "style='background: #ffe6e6;'";
} elseif (!$buttonShows) {
$rowColor = "style='background: #fff3cd;'";
}
echo "<tr {$rowColor}>";
echo "<td><a href='debug_variation_button.php?track_id={$track['id']}' target='_blank'>{$track['id']}</a></td>";
echo "<td>{$track['task_id']}</td>";
echo "<td>" . ($track['title'] ?: '<em>Untitled</em>') . "</td>";
echo "<td>" . date('Y-m-d H:i', strtotime($track['created_at'])) . "</td>";
echo "<td>{$track['stored_variations_count']}</td>";
echo "<td>{$track['actual_variations_count']}</td>";
echo "<td><strong>{$track['ui_variation_count']}</strong></td>";
echo "<td>" . ($buttonShows ? "✅ YES" : "❌ NO") . "</td>";
echo "<td>" . (!empty($issues) ? implode(', ', $issues) : '✅ OK') . "</td>";
echo "</tr>";
}
echo "</table>";
// Check for variations with wrong track_id (orphaned variations)
echo "<h4>Checking for Orphaned Variations (wrong track_id):</h4>";
$stmt = $pdo->prepare("
SELECT
av.track_id,
av.variation_index,
mt.id as actual_track_id,
mt.task_id
FROM audio_variations av
LEFT JOIN music_tracks mt ON av.track_id = mt.id
WHERE av.track_id IN (SELECT id FROM music_tracks WHERE user_id = ?)
AND mt.id IS NULL
");
$stmt->execute([$artist['id']]);
$orphaned = $stmt->fetchAll(PDO::FETCH_ASSOC);
if (!empty($orphaned)) {
echo "<p style='color: red;'>❌ Found " . count($orphaned) . " orphaned variation(s) (track_id doesn't exist in music_tracks)</p>";
foreach ($orphaned as $orphan) {
echo "<p>Variation index {$orphan['variation_index']} with track_id {$orphan['track_id']} (track doesn't exist)</p>";
}
} else {
echo "<p style='color: green;'>✅ No orphaned variations found</p>";
}
// Check callback logs for errors
echo "<h4>Recent Callback Activity:</h4>";
$logFile = __DIR__ . "/callback_log.txt";
if (file_exists($logFile)) {
$logContent = file_get_contents($logFile);
$logLines = explode("\n", $logContent);
$recentLines = array_slice($logLines, -100); // Last 100 lines
foreach ($tracks as $track) {
$taskId = $track['task_id'];
$foundInLog = false;
$errors = [];
foreach ($recentLines as $line) {
if (strpos($line, $taskId) !== false) {
$foundInLog = true;
if (stripos($line, 'error') !== false || stripos($line, 'failed') !== false || stripos($line, '❌') !== false) {
$errors[] = htmlspecialchars(substr($line, 0, 200));
}
}
}
if ($foundInLog) {
echo "<p><strong>Track {$track['id']} (Task: {$taskId}):</strong> ";
if (!empty($errors)) {
echo "<span style='color: red;'>Found " . count($errors) . " error(s) in log</span>";
echo "<details><summary>View errors</summary><pre>" . implode("\n", array_slice($errors, 0, 5)) . "</pre></details>";
} else {
echo "<span style='color: green;'>✅ Found in log, no errors</span>";
}
echo "</p>";
} else {
echo "<p><strong>Track {$track['id']} (Task: {$taskId}):</strong> <span style='color: orange;'>⚠️ Not found in recent log entries</span></p>";
}
}
} else {
echo "<p>Callback log file not found</p>";
}
echo "<hr>";
}
echo "<h3>Next Steps:</h3>";
echo "<ol>";
echo "<li>Click on a track ID to see detailed debug info</li>";
echo "<li>Check if variations exist in audio_variations table but with wrong track_id</li>";
echo "<li>Check callback logs for errors during variation storage</li>";
echo "<li>Run fix_missing_title_and_variations.php to repair if needed</li>";
echo "</ol>";