Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory Issue PdfDataExtractor #30

Open
solverat opened this issue Jun 20, 2023 · 0 comments
Open

Memory Issue PdfDataExtractor #30

solverat opened this issue Jun 20, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@solverat
Copy link
Member

Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no

If you're dealing with hundreds/thousands of asset documents (PDF), the asset method getLocalFile will fail ([PHP Warning: exec() unable to fork because a lot of resource streams will be processed.

$cmd = sprintf('%s "%s" "%s"', $verboseCommand, $data->getLocalFile(), $tmpFile);
exec($pdfToTextBin . ' ' . $cmd);

Fetching the full path like in the example below could be a solution, but it won't work if the assets are stored on an asset storage server for example.

$tmpFile = sprintf('%s%s%s.text', $assetTmpDir, DIRECTORY_SEPARATOR, uniqid('t2p-', false));
$verboseCommand = !\Pimcore::inDebugMode() ? '-q' : '';
$cmd = sprintf('%s "%s/public/var/assets%s" "%s"', $verboseCommand, $this->projectDir, $data->getRealFullPath(), $tmpFile);

try {
    exec($pdfToTextBin . ' ' . $cmd);
} catch (\Exception $e) {
    return null;
}
@solverat solverat added the bug Something isn't working label Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant