-
Notifications
You must be signed in to change notification settings - Fork 484
Fix(phpfatalerror): fixed uncaught error to member function getRisk() #2997
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
Fix(phpfatalerror): fixed uncaught error to member function getRisk() #2997
Conversation
src/spdx/agent/spdx.php
Outdated
$filesProceeded += 1; | ||
if (($filesProceeded&2047)==0) { | ||
$this->heartbeat(0); | ||
$this->heartbeat($filesProceeded - 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ritankarsaha Can you explain why this change is required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @its-sushant, thanks for the review! with this change I am only passing the actual number of processed files instead of always sending 0
so that the agent can give more detailed feedback on it's work. Like for example if there were 100 files, and a job fails at the 20th file, then the user can see that it has failed at the 20th file and how much work had been done before it failed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ritankarsaha : for now this change is not needed can you please remove tis so that we can merged this branch ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure @shaheemazmalmmd will make the changes and push the new commit !
9b29f7e
to
cf27556
Compare
@shaheemazmalmmd done with the changes! fixed the code sniffer error, signed the commits, squashed them into one. |
|
Oh, I am looking into it and providing with a fix ASAP @its-sushant ! |
cf27556
to
a5281e7
Compare
Hello, @its-sushant I have pushed a new commit into the PR. I hope this aligns with the requirements now. Are there any other modifications that are needed to be made? |
Hey @its-sushant I was wondering if there is any command to fix the indentation errors and formatting errors all at once rather than fixing them manually? |
1db8969
to
9f05150
Compare
Hey @its-sushant fixed the codesniffer errors and pushed the new commit ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ritankarsaha Thank you for incorporating with the request. I have added few more suggestions. Please take a look!
src/spdx/agent/spdx.php
Outdated
if ($docLicense === null) { | ||
error_log("Warning: License with short name " . self::DATA_LICENSE . " not found in the database. Using fallback license."); | ||
$docLicense = new License(0, self::DATA_LICENSE, "Fallback License", "Unknown", "No license text available", "", "", ""); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need of this check. Also ideally we should not create any Fallback License for report and we can always expect the DATA_LICENSE
exist in database.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@its-sushant removed this check !!
src/spdx/agent/spdx.php
Outdated
if ($dataLic === null) { | ||
error_log( | ||
"spdx: warning: data‐license '" . self::DATA_LICENSE . "' not found; using fallback." | ||
); | ||
$dataLic = new \Fossology\Lib\Data\License( | ||
0, | ||
self::DATA_LICENSE, | ||
"Fallback Data License", | ||
"Unknown", | ||
"No license text available", | ||
"", "", "" | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check can also be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@its-sushant also removed this check !!
Yess @its-sushant updating them accordingly and pushing a new commit !! |
9f05150
to
74b890c
Compare
Hey @its-sushant removed the blocks, and pushed a new commit into the PR. :)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ritankarsaha We can simply fail the agent when main license is not found in Database. I have added few suggestions. Hopefully this will be last 😄
error_log("Warning: License ID " . $originLicenseId . " not found in the database."); | ||
continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error_log("Warning: License ID " . $originLicenseId . " not found in the database."); | |
continue; | |
error_log("Error: License ID " . $originLicenseId . " not found in the database."); | |
exit; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated this @its-sushant !
src/spdx/agent/spdx.php
Outdated
"spdx: warning: main license ID {$reportedLicenseId} not found; skipping." | ||
); | ||
continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"spdx: warning: main license ID {$reportedLicenseId} not found; skipping." | |
); | |
continue; | |
"spdx: Error: main license ID {$reportedLicenseId} not found." | |
); | |
exit; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated this as well @its-sushant
Sure @its-sushant will make these modifications and add a new commit !! |
74b890c
to
d772683
Compare
Hey @its-sushant I have made the necessary updates and pushed the new commit :)). Also apologies for the delay, I actually have my end-sems going ! |
Hello @its-sushant is the implementation of the PR now alright and in accordance or are there some other modifications that I need to make as well to this ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested. LGTM! Thank you for the contribution @ritankarsaha
Thank You !! @its-sushant 🙃 |
Hey @its-sushant @shaheemazmalmmd is the PR alright or does it need any more updates? Should I rebase the branch from base once more ? |
changes Signed-off-by: Ritankar Saha <[email protected]> php space fixes Signed-off-by: Ritankar Saha <[email protected]> fix(phpfatalerror): fixes uncaught error Signed-off-by: Ritankar Saha <[email protected]> fix(phpfatalerror): fixed uncaught error Signed-off-by: Ritankar Saha <[email protected]> feat(phpfatalerror): fixed indentation errors Signed-off-by: Ritankar Saha <[email protected]> fix(phpfatalerror): fixed uncaught error Signed-off-by: Ritankar Saha <[email protected]> fix(phpfatalerror): fixed uncaught error to member function Signed-off-by: Ritankar Saha <[email protected]>
d772683
to
ffa55f7
Compare
This PR fixes the issue #2833
Description
To implement this issue I have added graceful fallback and null-checks
This ensures that subsequent methods liked getId() or getText() can be made safely on the fallback object and the report generation continues without a fatal error.
Changes
Null-Check in LicenseMainGetter.php:
Added a check for null after retrieving the license object. If it’s missing, the code logs a warning and skips processing that license instead of calling methods on a null object.
Fallback License in spdx.php:
Added a null-check , If it isn’t found, a fallback License object is created with default values so that subsequent method calls (like getId() and getText()) succeed.
Testing
tail -f /var/log/fossology/fossology.log
) for a warning message