Laravel adds php notices to response content [duplicate] - php

This question already has answers here:
Notice: Unknown: file created in the system's temporary directory in Unknown on line 0
(5 answers)
Closed 9 months ago.
I have the issue that laravel (version 8) adds php notices I get to the response as html string. This is really annoying because the response should be json and now I have string that contains html and json.
This is how the response looks:
<br />\n<b>Notice</b>: Unknown: file created in the system's temporary directory in <b>Unknown</b> on line <b>0</b><br />
{\"type\":[\"The type field is required.\"]}
Any idea how to disable this behaviour ?
I already tried using phps error_reporting() function.
Even with APP_DEBUG=false this occurs.

I just hit this too, I fixed it by setting the php display_errors runtime config value to off. See https://www.php.net/manual/en/errorfunc.configuration.php#ini.display-errors
More specifically, on my macos/Brew PHP setup it was by editing
/usr/local/etc/php/8.0/php-fpm.d/www.conf
and removing the commenting-semicolon on this line
;php_flag[display_errors] = off
and restarting the php#8.0 service
brew services restart php#8.0
On other platforms like Ubuntu, it might be found by grepping under /etc/php for display_errors

Related

How to fix intermittent PHP Fatal error: Unknown: Cannot find save handler '/var/lib/php/session' [duplicate]

This question already has an answer here:
Warning : session_start(): Cannot find save handler 's' - session startup failed
(1 answer)
Closed 3 years ago.
Very intermittently and rarely my Centos7 httpd 2.4.41 and php 5.6.40 server will half load a page. The PHP loads, but the CSS and JS includes get the error 'Connection Reset' in chrome and dump this error into the php error log.
PHP Fatal error: Unknown: Cannot find save handler '/var/lib/php/session'
I have checked permissions on the session files, and the server has plenty of space, the fact that it works most of the time makes my scratch my head.
I've tried switching to memcached but same issue.
Can anyone share any light on whats causing this error?
Or perhaps a way to stacktrace the httpd PID after the fatal error?
Thanks in advance guys.
This issue might be related to your session save path. If you are not precious on where to save the sessions.
edit your php.ini and change the following
we are using the /tmp directory here.
session.save_path = /tmp
more information can be found here
http://www.php.net/manual/en/session.configuration.php#ini.session.save-path

PHP Error Log - why am I getting so many openbase_dir issues?

Firstly, apologies for the vague title. Not sure how best to word it. I'll start off with a copy of my php logs.
[25-Jun-2019 12:21:44] WARNING: [pool corrigansni.ivech.co.uk] child 58505 said into stderr: "NOTICE: PHP message: PHP Warning: Unknown: open_basedir restriction in effect. File(C:\Inetpub\vhosts\ivech.co.uk\logs\php_errors\choicerentals.ivech.co.uk\php_error.log) is not within the allowed path(s): (/var/www/vhosts/ivech.co.uk/:/tmp/) in Unknown on line 0"
[25-Jun-2019 12:21:44] WARNING: [pool corrigansni.ivech.co.uk] child 58504 said into stderr: "NOTICE: PHP message: PHP Warning: Unknown: open_basedir restriction in effect. File(C:\Inetpub\vhosts\ivech.co.uk\logs\php_errors\choicerentals.ivech.co.uk\php_error.log) is not within the allowed path(s): (/var/www/vhosts/ivech.co.uk/:/tmp/) in Unknown on line 0"
[25-Jun-2019 12:21:45] WARNING: [pool corrigansni.ivech.co.uk] child 58499 said into stderr: "NOTICE: PHP message: PHP Warning: Unknown: open_basedir restriction in effect. File(C:\Inetpub\vhosts\ivech.co.uk\logs\php_errors\choicerentals.ivech.co.uk\php_error.log) is not within the allowed path(s): (/var/www/vhosts/ivech.co.uk/:/tmp/) in Unknown on line 0"
[25-Jun-2019 12:21:45] WARNING: [pool corrigansni.ivech.co.uk] child 58456 said into stderr: "NOTICE: PHP message: PHP Warning: Unknown: open_basedir restriction in effect. File(C:\Inetpub\vhosts\ivech.co.uk\logs\php_errors\choicerentals.ivech.co.uk\php_error.log) is not within the allowed path(s): (/var/www/vhosts/ivech.co.uk/:/tmp/) in Unknown on line 0"
That's just a small section of my logs. I'm assuming I have programming errors which are trying to write to the logs but this is happening on every page load of roughly 60 subdomains. I've only become aware of it due to some major speed issues recently. The server load is fine however the speed of running multiple ajax scripts has decreased dramatically recently. I'm hoping this is all related and by fixing this problem the speed issues will fix.
My main issue is that irrelevant of the php errors, they're not able to write because of the openbase_dir problem. However, as you can see from the logs it's not even trying to write to a related folder.
subdomain: corrigansni is trying to write to the log folder for choicerentals even though they aren't related and choicerentals subdomain no longer exists. I'm also not being told which script is trying to write the logs.
Can anyone answer the following:
where the setting may be to change where it is writing the logs?
why i'm getting unknown on line 0 instead of a script location
why every single page load and ajax call may be causing this to happen.
Just as a side note, I've tried changing the PHP version I'm using, still get the same issues.
Thanks in advance
EDIT: A few people have suggested a similar question elsewhere. It's not really the same. That questions asks how to relax openbase_dir, I don't want to do that.
My question has a few parts:
Firstly; it's trying to access a folder within the directory which is not relevant. How do I change that location.
Secondly; my openbase_dir settings appear to be correct so why would it not be able to access it.
Thirdly. What would cause it to attempt to write to an error_log file but from an unknown location.
Your PHP settings have an incorrect value for the error_log setting, which points to a directory you've told PHP it shouldn't write to. This is causing a Warning during the startup of every request, as PHP processes your settings files, before it's reached the first line of your PHP code. Since it can't write to the log file specified, it falls back to the default, which is to echo to "standard error", which is eventually picked up and put in the generic log file you're seeing.
There are several places a configuration variable can be set, discussed in the Runtime Configuration chapter of the PHP manual; for instance, there may be one or more php.ini files, and settings passed in from Apache configuration files. Either the setting has been copied incorrectly from one site to another, or it is being set in a global configuration file which is used by both sites.
The peculiar path logged (C:\Inetpub\vhosts\ivech.co.uk\logs\php_errors\choicerentals.ivech.co.uk\php_error.log) suggests that the setting is incorrect anyway, apart from mentioning the wrong site; possibly it is specifying a relative path rather than an absolute one (starting with C:\).
As pointed out in comments, it looks like the open_basedir setting is wrong as well, as it appears to be in Linux format, whereas the log message suggests you're running on Windows.
For anyone that ever finds this I found my problem. I had a silly little file called .user.ini in my folder structure which was setting the windows path. Must have been there from an old windows server we used to use.

Azure - "PHP Warning: session_start(): Cannot find save handler 'wincache'" after already being loaded

I've got a webjob running on my Azure app service that starts off with the session_start(); command.
At first - I was getting this error:
PHP Warning: session_start(): Cannot find save handler 'wincache' -
session startup failed in
D:\local\Temp\jobs\triggered\myCron\a4ypumbv.4i2\MyCron\myCron.php on
line 3
What I ended up doing was going to my App Service -> Application Settings, and I set a custom setting of PHP_INI_SCAN_DIR set to D:\home\site, like so:
Then, inside the D:\home\site directory, I uploaded a file titled phpconfig.ini, and inside I placed this:
extension=D:\home\site\ext\php_wincache.dll
I went to https://www.iis.net/downloads/microsoft/wincache-extension and downloaded the appropriate WinCache version - WinCache 1.3 for PHP 5.6 from SourceForge. After unpacking the .exe file, I copied the php_wincache.dll file into my D:\home\site\ext folder.
Now, when I run the webjob, I get this same error but also another error message right before it saying the wincache file was already loaded:
PHP Warning: Module 'wincache' already loaded in Unknown on line 0
PHP Warning: session_start(): Cannot find save handler 'wincache' -
session startup failed in
D:\local\Temp\jobs\triggered\myCron\a4ypumbv.4i2\MyCron\myCron.php on
line 3
How can I make these warnings go away completely? Has anyone run into the same problem before?
wincache has been already installed and enabled in Azure App Service.
In this case, you no longer need to call session_start() manually, Azure would start sessions on each page automatically.

Php error in curl function [duplicate]

This question already has answers here:
PHP Fatal error: Call to undefined function curl_init()
(24 answers)
Closed 5 years ago.
i got this error while running php code
Call to undefined function curl_init() in C:\wamp\www\OTP\process.php
on line 25 Call Stack # Time Memory Function Location
1 0.0030 151192 {main}( ) ..\process.php:0
how to resolve this
Try following steps:
Click wamp icon. and go to php -> php extension and check "PHP_CURL" is ticked or not.
If not checked then click it and restart wamp.
if you not understand in above then follow below instructions.
Go to your php.ini file and remove the ; mark from the beginning of the following line:
;extension=php_curl.dll
After you have saved the file you must restart your HTTP server software (e.g. Apache) before this can take effect.
"do not forgot to restart server"

PHP escapeshellarg() Issue, with CodeIgniter [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
escapeshellarg() has been disabled for security reasons
I've created an image upload system with PHP and it all works but I still get a warning:
A PHP Error was encountered
Severity: Warning
Message: escapeshellarg() has been disabled for security reasons
Filename: libraries/Upload.php
Line Number: 1066
Does anyone know how to get rid of this without contacting Hosting provider?
You can't. You will have to contact your sys admin to enable that function for you, or use something else (that does not involve executing shell commands) for what you are trying to accomplish.
Try replacing escapeshellarg with #escapeshellarg.
Because, then you'd be suppressing any warning that function call gives.
Since
it all works
Doing that shouldn't be a problem to your working code.
Note: using # to suppress warnings or errors is not recommended.

Categories