-
-
Notifications
You must be signed in to change notification settings - Fork 825
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
dev/core#2369 - Change missing image fatal error to 404 #20447
dev/core#2369 - Change missing image fatal error to 404 #20447
Conversation
(Standard links)
|
There was some talk in the ticket of making it a 404. Right now it has response code 200. If it is desired to make it 404, which seems reasonable, then in the else clause you could do |
I had no clue how this would work @demeritcowboy Thanks for your suggestion. When I search the core code I see these examples of throwing a 404 Would the guzzle way be preferable you think? |
Good point. Looks like they all do the same thing. And it seems even when the header/code is missing either php or the browser figures it out and adds it if the other is present. So maybe |
a8298a2
to
11c4684
Compare
@demeritcowboy changed the PR to the header 404 version. Would you be able to test, review and approve? |
Ok cool. I don't think the |
tests have hung? |
test this please |
CRM/Contact/Page/ImageFile.php
Outdated
@@ -55,7 +55,8 @@ public function run() { | |||
CRM_Utils_System::civiExit(); | |||
} | |||
else { | |||
throw new CRM_Core_Exception(ts('Photo does not exist')); | |||
header("HTTP/1.0 404 Not Found"); | |||
return; |
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.
I would say rather than doing a return here we should call CRM_Utils_System::civiExit()
but this could also be a follow up to this 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.
Why would you suggest this a follow up? Or would more returns in civicrm code be candidates for CRM_Utils_System::civiExit() ?
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.
He might have just been politely trying to keep the PR from going on too long but if you want to update it now then you could pull the exit call out of the if
, which funnily enough, makes it look more like it did 7 years ago.
if ($cid) {
$config = CRM_Core_Config::singleton();
$fileExtension = strtolower(pathinfo($_GET['photo'], PATHINFO_EXTENSION));
$this->download(
$config->customFileUploadDir . $_GET['photo'],
'image/' . ($fileExtension == 'jpg' ? 'jpeg' : $fileExtension),
$this->ttl
);
}
else {
header("HTTP/1.0 404 Not Found");
}
CRM_Utils_System::civiExit();
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.
I pulled the exit outside of the if now. @demeritcowboy @seamuslee001 agree & approve?
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.
Can you squash the commits?
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.
yep, done
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.
Thanks. Looks good - have updated label.
jenkins retest this please (some kind of intermittent fail - rollover timing issue) |
@seamuslee001 |
@yashodha I can also adjust this PR and change the |
11c4684
to
255993e
Compare
ae87b17
to
1a662f3
Compare
Overview
A missing profile image results in a unnecessary fatal error
Before
Use a profile in order for users to be able to upload a profile image (image url field in contact table). Viewing the field while an image is missing results in a fatal error (user does not notice, it is only logged that way). Being a fatal error the report error extension would also notify us by email each time.
After
A missing image url field does not result in a fatal error being logged anymore. The regular 404 rules apply.
Technical Details
Removed the lines that would throw the error
Comments
The world will be a better place after this commit is merged
Issue can be found over here: https://lab.civicrm.org/dev/core/-/issues/2369