Skip to content

Prevent handle invalid output - #14

Merged
jeidison merged 1 commit into
masterfrom
bugfix/prevent-handle-invalid-output
Oct 27, 2022
Merged

Prevent handle invalid output#14
jeidison merged 1 commit into
masterfrom
bugfix/prevent-handle-invalid-output

Conversation

@vitormattos

@vitormattos vitormattos commented Oct 22, 2022

Copy link
Copy Markdown
Contributor

Prevent to handle $output var with invalid value.
If $output is empty or haven't version string, will return empty version.

I identified maybe a specific scenario with exec command when the $ouput get a delay to get the output of command and in this case the $output will be empty.

I thought about putting a delay like the follow code to prevent this problem. But, I did this with success, this looked like a more strange workaround to solve the problem. Because of this, I did the more simple, only checking if $output have the expected value.

\exec($command, $output);
$loop = 0;
while (empty($output) && $loop < 5) {
    usleep(500000);
    $loop++;
}

Maybe, the suggested code here can solve definitively the problem. Waiting for opinions from code review.

Still in time, the scenario in that I found this edge case was in a setup flow when I download the JSignPdf and with other process I do a loop waiting for finish download to check the downloaded version.

Signed-off-by: Vitor Mattos <vitor@php.rio>
@vitormattos vitormattos added bug Something isn't working enhancement New feature or request labels Oct 22, 2022
@vitormattos
vitormattos requested a review from jeidison October 22, 2022 16:43
vitormattos added a commit to LibreSign/libresign that referenced this pull request Oct 22, 2022
vitormattos added a commit to LibreSign/libresign that referenced this pull request Oct 22, 2022
JSignPdf/jsignpdf-php#14
Signed-off-by: Vitor Mattos <vitor@php.rio>
backportbot-libresign Bot pushed a commit to LibreSign/libresign that referenced this pull request Oct 22, 2022
JSignPdf/jsignpdf-php#14
Signed-off-by: Vitor Mattos <vitor@php.rio>
vitormattos added a commit to LibreSign/libresign that referenced this pull request Oct 22, 2022
JSignPdf/jsignpdf-php#14
Signed-off-by: Vitor Mattos <vitor@php.rio>
vitormattos added a commit to LibreSign/libresign that referenced this pull request Oct 23, 2022
JSignPdf/jsignpdf-php#14
Signed-off-by: Vitor Mattos <vitor@php.rio>
vitormattos added a commit to LibreSign/libresign that referenced this pull request Oct 23, 2022
JSignPdf/jsignpdf-php#14
Signed-off-by: Vitor Mattos <vitor@php.rio>
vitormattos added a commit to LibreSign/libresign that referenced this pull request Oct 23, 2022
JSignPdf/jsignpdf-php#14
Signed-off-by: Vitor Mattos <vitor@php.rio>
@jeidison
jeidison merged commit 18d298b into master Oct 27, 2022
@vitormattos
vitormattos deleted the bugfix/prevent-handle-invalid-output branch August 4, 2025 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants