2025-11-04
This commit is contained in:
parent
e4eaf6404a
commit
c986904382
1626 changed files with 5641 additions and 1921 deletions
42
scripts/pull-container-images.ts
Normal file
42
scripts/pull-container-images.ts
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import { BunFile, YAML } from "bun";
|
||||
import { Array, Console, Effect, Option, pipe, Record, Schema } from "effect";
|
||||
import { type UnknownException } from "effect/Cause";
|
||||
import { type ParseError } from "effect/ParseResult";
|
||||
import { type ReadonlyRecord } from "effect/Record";
|
||||
|
||||
const COMPOSE_PATH = "compose.yaml";
|
||||
|
||||
const getServicesKey = (
|
||||
yaml: ReadonlyRecord<string | symbol, any>,
|
||||
): Option.Option<ReadonlyArray<string>> =>
|
||||
pipe(
|
||||
Record.get("services")(yaml),
|
||||
Option.andThen(yaml => Record.keys(yaml)),
|
||||
);
|
||||
|
||||
const getComposeYaml = <A, I, R>(
|
||||
filePath: string,
|
||||
schema: Schema.Schema<A, I, R>,
|
||||
): Effect.Effect<A, UnknownException | ParseError, R> =>
|
||||
pipe(
|
||||
Effect.try(() => Bun.file(filePath)),
|
||||
Effect.andThen((file: BunFile) => Effect.tryPromise(() => file.text())),
|
||||
Effect.andThen((text: string) => Effect.try(() => YAML.parse(text))),
|
||||
Effect.andThen((yaml: unknown) => Schema.decodeUnknown(schema)(yaml)),
|
||||
);
|
||||
|
||||
const programEffect: Effect.Effect<ReadonlyArray<string>> = Effect.gen(function*() {
|
||||
return yield* pipe(
|
||||
// Récupère le contenu du fichier compose.yaml sous forme de Record.
|
||||
getComposeYaml(COMPOSE_PATH, Schema.Record({ key: Schema.String, value: Schema.Unknown })),
|
||||
// Récupère la clé des services.
|
||||
Effect.andThen((yaml: ReadonlyRecord<string | symbol, unknown>) => getServicesKey(yaml)),
|
||||
// Retire la clé de l'image WordPress.
|
||||
Effect.andThen((keys: ReadonlyArray<string>) => Array.filter(keys, key => key !== "wordpress")),
|
||||
Effect.orElseSucceed(() => [""]),
|
||||
// Exécute la commande podman.
|
||||
Effect.tap(services => Bun.spawn({ cmd: ["podman", "compose", "pull", ...services], timeout: 10000 })),
|
||||
);
|
||||
});
|
||||
|
||||
Effect.runFork(programEffect).pipe(Effect.tapErrorCause(Console.error));
|
||||
|
|
@ -1,47 +1,43 @@
|
|||
<?php
|
||||
|
||||
require_once "web/wp/wp-load.php";
|
||||
require_once 'web/wp/wp-load.php';
|
||||
|
||||
ini_set("max_execution_time", 3600);
|
||||
ini_set('max_execution_time', 3600);
|
||||
set_time_limit(3600);
|
||||
|
||||
$pdo = new PDO("mysql:dbname=haiku_atelier;host=localhost", "haiku_utilisateur", "spNFx5EAYwvF7o7XFMjiHpNPYJimDtmKWv");
|
||||
|
||||
/**
|
||||
* replace _wp_attached_file meta_key
|
||||
**/
|
||||
$pdo = new PDO('mysql:dbname=haiku_atelier;host=localhost', 'haiku_utilisateur', 'spNFx5EAYwvF7o7XFMjiHpNPYJimDtmKWv');
|
||||
|
||||
// replace _wp_attached_file meta_key
|
||||
global $wpdb;
|
||||
$wp_postmeta = $wpdb->prefix . "postmeta";
|
||||
$wp_postmeta = "{$wpdb->prefix}postmeta";
|
||||
|
||||
try {
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); //Error Handling
|
||||
|
||||
$sql = "UPDATE $wp_postmeta SET meta_value = REPLACE(meta_value,'-scaled.jpg','.jpg') WHERE meta_key='_wp_attached_file' AND meta_value LIKE '%-scaled.jpg%'";
|
||||
$result = $pdo->exec($sql);
|
||||
print_r($result);
|
||||
} catch (PDOException $e) {
|
||||
print_r($e->getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* replace _wp_attachment_metadata meta_key
|
||||
**/
|
||||
|
||||
$image_metas = [];
|
||||
try {
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); //Error Handling
|
||||
$sql = "SELECT * FROM $wp_postmeta WHERE meta_value LIKE '%-scaled.jpg%' AND meta_key='_wp_attachment_metadata'";
|
||||
$statement = $pdo->query($sql);
|
||||
$image_metas = $statement->fetchAll();
|
||||
foreach ($image_metas as $meta) {
|
||||
$meta_value = unserialize($meta["meta_value"]);
|
||||
$file = $meta_value["file"];
|
||||
$meta_value["file"] = str_replace("-scaled.jpg", ".jpg", $file);
|
||||
update_post_meta($meta["post_id"], $meta["meta_key"], $meta_value);
|
||||
$result = get_post_meta($meta["post_id"], $meta["meta_key"]);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
// Error Handling
|
||||
$sql = "UPDATE {$wp_postmeta} SET meta_value = REPLACE(meta_value,'-scaled.jpg','.jpg') WHERE meta_key='_wp_attached_file' AND meta_value LIKE '%-scaled.jpg%'";
|
||||
$result = $pdo->exec($sql);
|
||||
print_r($result);
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
print_r($e->getMessage());
|
||||
print_r($e->getMessage());
|
||||
}
|
||||
|
||||
// replace _wp_attachment_metadata meta_key.
|
||||
$image_metas = [];
|
||||
|
||||
try {
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
// Error Handling
|
||||
$sql = "SELECT * FROM {$wp_postmeta} WHERE meta_value LIKE '%-scaled.jpg%' AND meta_key='_wp_attachment_metadata'";
|
||||
$statement = $pdo->query($sql);
|
||||
$image_metas = $statement->fetchAll();
|
||||
foreach ($image_metas as $meta) {
|
||||
$meta_value = unserialize($meta['meta_value']);
|
||||
$file = $meta_value['file'];
|
||||
$meta_value['file'] = str_replace('-scaled.jpg', '.jpg', $file);
|
||||
update_post_meta($meta['post_id'], $meta['meta_key'], $meta_value);
|
||||
$result = get_post_meta($meta['post_id'], $meta['meta_key']);
|
||||
print_r($result);
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
print_r($e->getMessage());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue