我的php脚本中出现504网关超时错误,我该如何拆分该脚本或如何解决该错误
$mp3FilesOnServer = getDirContents($uploadsDir);
$newMp3FilesOnServer = array();
foreach ($mp3FilesOnServer as $fileFullPath) {
$fileName = preg_replace('#^.*?([\/\\\\]+wp-content.*)$#', '$1', $fileFullPath);
$fileName = str_replace('\\', '/', $fileName);
$query = $wpdb->prepare('SELECT COUNT(*) FROM ' . $wpdb->postmeta . '
LEFT JOIN ' . $wpdb->posts . ' ON ' . $wpdb->posts . '.ID = ' . $wpdb->postmeta . '.post_id
WHERE meta_key = "mp3file_name" AND meta_value LIKE %s AND ' . $wpdb->posts . '.post_status != "trash"', $fileName);
$isDb = (int) $wpdb->get_var($query);
if (!$isDb)
$newMp3FilesOnServer[] = array(
'fullPath' => $fileFullPath,
'name' => $fileName
);
}