df7bf98ef1
- sync_translations_to_prod.py / sync_audio_to_prod.py / sync_carta_from_prod.py: migran de FEA_PROD_HOST/PASS (CDMON, password) a FEA_PROD_SSH_HOST/PASS + FEA_PROD_DOCKER_CONTAINER (Hetzner/Coolify, auth por clave), con wrapping docker exec y el fix del bug de redirecciones (wc -c/cat) resuelto en el host en vez de dentro del contenedor. - fea_translate_helper.php: subcomando clone_new para clonar en ID local nuevo cuando el ID de prod ya está ocupado localmente. - translate_post.py: --dry-run. - tts_produce.py: --allow-default-voice (voz Nico solo si se permite explícitamente para autores sin voz clonada) + fix voice_for_author. - minimax_tts.py: parámetro speed en t2a/_synth_chunk. - mirror-antiguo/deploy/nginx-mirror.conf: redirects de URLs históricas de catálogo y vista imprimible EFFA. - Importaciones humanas de Pagola (carta 738) + scripts/manifest de la fase A Enrique, y release_issue181_prod.sh / cdmon-retire-fewp1.sh. - .gitignore: excluye docs/backups/ (dumps SQL, mismo motivo que backups/*). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
51 lines
2.1 KiB
PHP
51 lines
2.1 KiB
PHP
<?php
|
|
/**
|
|
* Issue #62 — Reapunta foto_perfil de cada autor a su avatar nuevo.
|
|
* Crea un attachment por autor y guarda el foto_perfil antiguo en _foto_perfil_pre62 (revertible).
|
|
* Uso: wp eval-file import_avatars_62.php [--apply]
|
|
* sin --apply => dry run (no escribe nada).
|
|
*/
|
|
require_once ABSPATH . 'wp-admin/includes/image.php';
|
|
|
|
$apply = getenv('APPLY') === '1';
|
|
$mfile = getenv('MANIFEST') ?: 'manifest_62.json';
|
|
$updir = wp_get_upload_dir();
|
|
$manifest = json_decode(file_get_contents($updir['basedir'] . '/avatares/' . $mfile), true);
|
|
|
|
$done = $skip = $err = 0;
|
|
foreach ($manifest as $row) {
|
|
list($uid, $name, $orig, $kind, $old_attach) = $row;
|
|
if (!in_array($kind, ['initials','trim','logo','qs'], true)) { $skip++; continue; }
|
|
|
|
$rel = "avatares/autores/autor-{$uid}.png";
|
|
$abs = $updir['basedir'] . '/' . $rel;
|
|
if (!file_exists($abs)) { echo "MISSING file uid=$uid\n"; $err++; continue; }
|
|
|
|
// si foto_perfil ya apunta a este fichero, solo se ha sobrescrito el PNG: no crear attachment nuevo
|
|
$cur = (int) get_user_meta($uid, 'foto_perfil', true);
|
|
if ($cur && get_post_meta($cur, '_wp_attached_file', true) === $rel) {
|
|
if ($apply) wp_update_attachment_metadata($cur, wp_generate_attachment_metadata($cur, $abs));
|
|
$skip++; continue;
|
|
}
|
|
|
|
if (!$apply) { $done++; continue; }
|
|
|
|
// guardar foto_perfil antiguo una sola vez (idempotente)
|
|
if (get_user_meta($uid, '_foto_perfil_pre62', true) === '') {
|
|
update_user_meta($uid, '_foto_perfil_pre62', $old_attach);
|
|
}
|
|
|
|
$attach = [
|
|
'post_mime_type' => 'image/png',
|
|
'post_title' => "Avatar {$name}",
|
|
'post_status' => 'inherit',
|
|
'guid' => $updir['baseurl'] . '/' . $rel,
|
|
];
|
|
$aid = wp_insert_attachment($attach, $abs, 0, true);
|
|
if (is_wp_error($aid)) { echo "ERR insert uid=$uid: ".$aid->get_error_message()."\n"; $err++; continue; }
|
|
wp_update_attachment_metadata($aid, wp_generate_attachment_metadata($aid, $abs));
|
|
update_user_meta($uid, 'foto_perfil', $aid);
|
|
$done++;
|
|
}
|
|
echo ($apply ? "APLICADO" : "DRY-RUN") . ": procesados=$done omitidos=$skip errores=$err\n";
|