Update media-url.php
This commit is contained in:
@@ -14,9 +14,44 @@ ini_set('log_errors', '1');
|
||||
ini_set('error_log', __DIR__ . '/media-url_error.log');
|
||||
|
||||
function media_log($msg) {
|
||||
@file_put_contents(__DIR__ . '/media-url_debug.log', date('[Y-m-d H:i:s] ') . $msg . PHP_EOL, FILE_APPEND | LOCK_EX);
|
||||
static $triedInit = false;
|
||||
$path = __DIR__ . '/media-url_debug.log';
|
||||
$dir = dirname($path);
|
||||
$entry = date('[Y-m-d H:i:s] ') . $msg . PHP_EOL;
|
||||
$ok = false;
|
||||
|
||||
// Intentar crear directorio si es necesario
|
||||
if (!is_dir($dir) && !file_exists($dir)) {
|
||||
@mkdir($dir, 0755, true);
|
||||
}
|
||||
|
||||
// Intentar abrir y escribir
|
||||
$fp = @fopen($path, 'a');
|
||||
if ($fp) {
|
||||
if (@fwrite($fp, $entry) !== false) {
|
||||
$ok = true;
|
||||
}
|
||||
@fclose($fp);
|
||||
}
|
||||
|
||||
// Si falla, fallback a error_log y marcar bandera
|
||||
if (!$ok) {
|
||||
@error_log("media-url (fallback): " . $msg);
|
||||
global $log_write_failed;
|
||||
$log_write_failed = true;
|
||||
}
|
||||
|
||||
// Intento inicial de escritura para detectar permisos temprano
|
||||
if (!$triedInit) {
|
||||
$triedInit = true;
|
||||
if (isset($log_write_failed) && $log_write_failed) {
|
||||
// escribir un pequeño aviso también en error_log
|
||||
@error_log('media-url: debug log write failed, check permissions on ' . $dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$log_write_failed = false;
|
||||
$resolvedFromGraph = false;
|
||||
$decoded = null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user