Skip to content

Commit

Permalink
hotfix: prevent call other autoload before libresign
Browse files Browse the repository at this point in the history
  • Loading branch information
vitormattos committed Feb 3, 2025
1 parent a06b836 commit b2ec5b6
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lib/Handler/FooterHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function getFooter(File $file, FileEntity $fileEntity): string {

$htmlFooter = $this->getRenderedHtmlFooter();
$metadata = $this->getMetadata();
$this->loadLibreSignFirst();
foreach ($metadata['d'] as $dimension) {
if (!isset($pdf)) {
$pdf = new Mpdf([
Expand Down Expand Up @@ -85,6 +86,25 @@ public function getFooter(File $file, FileEntity $fileEntity): string {
return $pdf->Output('', 'S');
}

private function loadLibreSignFirst(): void {
$loaders = \Composer\Autoload\ClassLoader::getRegisteredLoaders();
$systemConfig = \OC::$server->getSystemConfig();
$appsPaths = $systemConfig->getValue('apps_paths');
$paths = array_column($appsPaths, 'path');
foreach ($loaders as $loader) {
$reflection = new \ReflectionClass($loader);
$propriedade = $reflection->getProperty('vendorDir');
$propriedade->setAccessible(true);
$vendorDir = $propriedade->getValue($loader);
foreach ($paths as $path) {
if (str_starts_with($vendorDir, $path) && !str_contains($vendorDir, 'libresign')) {
$loader->unregister();
$loader->register();
}
}
}
}

private function getMetadata(): array {
$metadata = $this->fileEntity->getMetadata();
if (!is_array($metadata) || !isset($metadata['d'])) {
Expand Down

0 comments on commit b2ec5b6

Please sign in to comment.