-
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 !!
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