Laravel: Carbon stop working after several hours - php

I've faced very strange behavior of Laravel 5.3 on PHP7/Apache (Windows).
My application is working perfect for several hours, but in unpredictable moment site crashes with errors like:
- Symfony\Component\Debug\Exception\FatalThrowableError: Call to
undefined method DateTime::format() in
C:\site\telemed\bootstrap\cache\compiled.php:14049
- Symfony\Component\Debug\Exception\FatalThrowableError: Call to
undefined method Carbon\Carbon::modify() in
C:\site\telemed\vendor\nesbot\carbon\src\Carbon\Carbon.php:1806
- and so on...
Also found in Apache Error Log:
Cannot make non static method DateTime::b\x10Y7I\xc0\xf1\xbdff() static in class DateTime
It looks like PHP forgets about some part of system code... Carbon stops working even in Monolog.
After Apache restart things get normal. Or sometimes it can get normal without any actions after ~30mins.
Any ideas what is happening?
Thank you in advance!
UPDATE:
After composer update and php upgrade to latest 7.1 things get even more weird of 4 hours of normal work:
Symfony\Component\Debug\Exception\FatalErrorException: Allowed memory size of 838860800 bytes exhausted (tried to allocate 8083526415852724616 bytes) in C:\site\telemed\vendor\nesbot\carbon\src\Carbon\Carbon.php:1112 Stack trace: #0 {main}

Related

Fatal error related to magic_quotes in PHP

So I'm trying to figure out a website error for my friend. Unfortunately, I'm not that good at PHP and unfortunately his website is...ancient. I tried referring to other questions here, but as my code example looks a tad different, I'm worried about messing something up.
Right now, the site is permanently down with the following error:
Fatal error: Uncaught Error: Call to undefined function
set_magic_quotes_runtime() in
/customers/1/f/7/WEBSITEDOMAIN.COM/httpd.www/includes/framework.php:21 Stack
trace: #0 /customers/1/f/7/WEBSITEDOMAIN.COM/httpd.www/index.php(22):
require_once() #1 {main} thrown in
/customers/1/f/7/WEBSITEDOMAIN.COM/httpd.www/includes/framework.php on line 21
So, I referred to the website files, oddly enough, there are four framework.php files but I assume some of them might be irrelevant. All of them contain the following code somewhere around line 21:
#set_magic_quotes_runtime( 0 );
#ini_set('zend.ze1_compatibility_mode', '0');
So, my idea is, remove it all, or just the first line as the error message refers to. This is what the other questions on SO hinted at, as the first line is completely irrelevant with the newest php version. However, as this is a business website I'm also hesitant to mess around, even more so as the owner understands nothing about code.
Any pointers for a complete newbie? (Websitedomain.com is an example address)
Thanks

cakephp cli throws PHP fatal error

The original installation was on Ubuntu 14.04 with PHP 5.5.9 and CakePHP 5.4.1. After migrating to Ubuntu 16.04 with PHP 7.0.30 I updated CakePHP to 2.10.4 mainly by exchanging the lib folder. Everything works fine in the web interface, even the memory consuming tasks of the application.
But the CLI is broken. Every call to 'app/Console/cake' throws a 'PHP Fatal error'.
root#watt18:/var/www_external/app# Console/cake bake
PHP Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to allocate 8192 bytes) in /var/www_external/lib/Cake/Console/ConsoleOptionParser.php on line 510
PHP Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to allocate 32768 bytes) in /var/www_external/lib/Cake/I18n/I18n.php on line 1
The 'in' part changes from call to call. Searching the web I could not find any comparable topic. I checked the persmissions on all the folders inside 'app' but could not find any differences to the original installation. I tried to debug but couldn't get really far yet. Up to the line return ShellDispatcher::run($argv); in Console/cake.php everything is fine.
I get the same result when making a call inside the original cakephp folder from a fresh download.
I have no idea where all the memory gets lost.I would be happy about any hint to what might cause the problem or how to continue with debuging.
set memory_limit = -1 in your php.ini
but this is not a good solution , you may have a memory leake somewhere
please double check your statements , specialy if there is a loop with many memory usage

Laravel 5.1 random timeout in ExcludeDirectoryFilterIterator

I'm seeing quite a few timeout errors on a big laravel 5.1 site:
[2018-05-23 17:02:35] production.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Maximum execution time of 30 seconds exceeded' in /var/www/vhosts/{site}/httpdocs/bootstrap/cache/compiled.php:16501
Stack trace:
0 {main}
Looking into the compiled.php file on that line number leads me to: ExcludeDirectoryFilterIterator#hasChildren
This function is from symfony/finder (version v2.7.47)
https://github.com/symfony/finder/blob/34226a3aa279f1e356ad56181b91acfdc9a2525c/Iterator/ExcludeDirectoryFilterIterator.php#L73
I've used debug_backtrace on this function to see what's calling it and it looks to be laravel when loading the configuration from storage (local disk).
Does anybody know of any issue with this? Is the server disk getting hit hard at some times during the day causing loading the config to timeout?
Any help/suggestions much appreciated.

Drupal - Fatal error sessionhandler

I am receiving following errors when I try to access pages and the site becomes inaccessible(error 500).
PHP Fatal error: Class Drupal\Core\Database\Statement contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Drupal\Core\Database\StatementInterface::fetchObject) in /projects/core/lib/Drupal/Core/Database/Statement.php on line 16
PHP Fatal error: Class Drupal\Core\Session\SessionHandler contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (SessionHandlerInterface::read) in /projects/core/lib/Drupal/Core/Session/SessionHandler.php on line 15
Restarting server will solve the issue for a limited time. Just found it was a memory issue. changed the memory_limit to 128, 256 and 512 but really seems to have happen randomly while browsing my website
Apache/2.4.29, PHP 7.0.26
Hey just need to delete cache or run drupal cron. for more details, please go to following the link.
https://www.drupal.org/project/drupal/issues/2668564
Hope it will useful for you.

Laravel memory exception 'Database/Connection.php:301'

I got a strange bug going down here, sometimes select queries dies from a memory exception. The big problem here is that I've never been able to see the error by myself. I know its existence from users and the laravel.log file that contains things like :
[2015-03-05 11:46:07] production.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Allowed memory size of 134217728 bytes exhausted (tried to allocate 196605 bytes)' in [...]/vendor/laravel/framework/src/Illuminate/Database/Connection.php:301
Stack trace:
#0 [internal function]: Illuminate\Exception\Handler->handleShutdown()
#1 {main} [] []
My questions are :
How to debug the issue (find oud what is the query that blows everything up)
Or if there's a known workaround for this, what is it ?
I already tried to DB::disableQueryLog(); within my start/artisan.php
Main issue is:
The PHP process is running out of memory, aka hitting the memory_limit set in your php.ini. The cause may be various, i.e infinite loops, large select statements; so to say: anything that requires PHP to store information in memory during processing.
My specific Issue & Solution:
I had this issue due to long running php processes, i.e Queue workers.
Solved it by setting up a cron job that does a php artisan queue:restart every 20 mins.
As the error message said, the error was about a certain database query. But I also asked how I could traceback the faulty query. I used an error tracking service called Rollbar to find out which API call died. Pretty sure it isn't the best way to figure this out but it worked...

Categories