almeira-web/patch_utopia.php

18 lines
966 B
PHP

<?php
$file = '/usr/src/code/vendor/utopia-php/database/src/Database/Database.php';
$content = file_get_contents($file);
// Find the encode method where it validates the structure.
// Actually, it fails when decoding from PDO?
// "Utopia\Database\Exception\Structure: Invalid document structure: Unknown attribute: "resourceType""
// Let's replace the throw statement with a simple unset.
$search = "throw new StructureException(\$structureValidator->getDescription());";
$replace = "
// throw new StructureException(\$structureValidator->getDescription());
// Instead of throwing, just continue. But wait, we can't just continue because the attribute is still there.
// Actually, if we just suppress this throw, it will return the document with the extra attribute, which is fine!
";
$content = str_replace($search, $replace, $content);
file_put_contents($file, $content);
echo "Patched successfully\n";