I recently got a job in a web newspaper. In the website, we have a very old and important Symfony Application, written for an older developer, long time gone.
That application is sacred: is the blood of the newspapers revenues. The problem is we have no backup, no developer installation, nothing, only the production installation
When I came here, I was very surprise for this risky decision. I week ago, the apps started to fail. I have zero experience in Symfony (i'm a rails developer), and that old apps was the "old and loyal dog who nothing will fail", but started to fail, and everyone is freaking out!
So, I need the help of the symfony developers of this site to find a "quick" solution meanwhile I try to convince my bosses that we need a more professional aproach (and the times and resources to do it)
The problem is this
Every time the people use the app, this message appear
fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 17106016 bytes) in /path/to/symfony/config_core_compile.yml.php on line 3366
The lines is in the middle of this function
public function shutdown()
{
if (!is_null($this->cache) && $this->cacheChanged)
{
$this->cacheChanged = false;
$this->cache->set('symfony.routing.data', serialize($this->cacheData));
}
}
I looked at google but only found people with the same problem, no solution... Please, anyone who could help me, Help me please!
I would try to first clear the cache in the app as the cache may just be massive.
in the symfony root folder run this command
php symfony clear:cache
If that does not solve the problem, I would up the memory limit until the root of the problem is fixed
So inside the index.php file add this before any symfony loading occurs
ini_set('memory_limit', '256M');
The best way to debug the app is to use the built-in dev environment. Add a file to the symfony web root that has the following:
// this check prevents access to debug front controllers that are deployed by accident to production servers.
// feel free to remove this, extend it or make something more sophisticated.
if (!in_array(#$_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1', 'YOUR IP ADDRESS HERE')))
{
die('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.<!-- ' . $_SERVER['REMOTE_ADDR'] . ' -->');
}
require_once(dirname(__FILE__).'/../config/ProjectConfiguration.class.php');
$configuration = ProjectConfiguration::getApplicationConfiguration('[app name]', 'dev', true);
sfContext::createInstance($configuration)->dispatch();
Don't forget to add your IP address in the third line so that you have access to view the dev environment data.
The app name is the name of the application that is in your %symfony root%/apps folder
I think the problems is the size of the cache of PHP, not symfony. The fastest way to overcome this issue is giving more memory to php. For your description you have 128MB of memory size, try giving 256 (for example). If you're on linux check this to change de memory size.
Know this is a patch, not a base solution.
And maybe it's working on debug mode. Check in the front controller /index.php the line
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', true);
It should be
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', false);
Related
I tried to implement the simplesamlphp library into my web application. But when I call the requireAuth() function I get a PHP fatal error message. Uncaught Exception: Loader: Illegal character in filename.....
It seems like he can't resolve the Class SimpleSAML\Module\saml\Auth\Source\SP
But I don't know why.
Does anyone have a idea how to fix this?
I already deleted the whole simplesamlphp installation and reinstalled it.
I use the following code:
require 'var/www/simplesamlphp/lib/_autoload.php';
$lAuthSrc = new \SimpleSAML\Auth\Simple('default-sp');
if (!$lAuthSrc->isAuthenticated()) {
$lAuthSrc->requireAuth();
}
$lAttributes = $lAuthSrc -> getAttributes();
foreach($lAttributes as $lAttribute) {
print_r($lAttribute);
}
Some additional informations:
The configured authentication source test works fine. If I login via the configured authentication source, everything works fine and I don't get any error messages (the requireAuth() function don't get called in this case).
I use the latest version of simplesamlphp v.1.18.3
If you need any more information, please let me know.
Honestly it looks like your path is messed up on the require... are you sure you should be using:
require 'var/www/simplesamlphp/lib/_autoload.php';
and not
require '/var/www/simplesamlphp/lib/_autoload.php';
Do you really have a 'var/www' subdirectory relative to the location of the script? That looks wrong to me. If you include that first / before var it makes that path absolute to the typical install location for SSP.
Thank you all for your help. I discovered this morning the issue. The issue was the autoloader which I use for my own application. I registered the application autoloader in another file which gets executed before the code you see above. And simplesamlphp uses some conditions like:
if (!class_exists($className))
And beacuse I registered my application autoloader before the function class_exists checked if the class exists in my application. In my application I don't use namespaces and this was the issue.
To fix this issue, I unregistered my application autoloader before using the simplesamlphp code and registered the autoloader again after the simplesamlphp code.
I hope this will save some of you headaches.
hope you're good
I was trying to add a profile table to my Laravel 5.6 project, and I'm also using the spatie\Laravel-Permission package. It was working fine, but after I ran some migrations (that have nothing to do with users), it started failing on the login. The curious thing is that, if I register a new user, it gets logged in properly, but never with the /login route (I'm using the Laravel's Auth scaffolding).
After debugging the project, I came up with the method that's failing, it's something reading the sessions:
MyProject\vendor\laravel\framework\src\Illuminate\Filesystem\Filesystem.php
<?php
namespace Illuminate\Filesystem;
use ErrorException;
use FilesystemIterator;
use Symfony\Component\Finder\Finder;
use Illuminate\Support\Traits\Macroable;
use Illuminate\Contracts\Filesystem\FileNotFoundException;
class Filesystem{
// ...
public function get($path, $lock = false)
{
if ($this->isFile($path)) {
return $lock ? $this->sharedGet($path) : file_get_contents($path); // <-- The failing line
}
throw new FileNotFoundException("File does not exist at path {$path}");
}
// ...
}
Once it gets to that line, the debugger stops, the browser doesnt get a response, the dd() function does not get triggered... I also tried to debug the sharedGet($path) method, and it returns the value, but back to the method above, it stops.
Also, the php_error.log file gets absurdly increased on every request (up to 500MB/request), so much that none of the editors I use can open it (SublimeText, NetBeans).
My thoughts are that apache may be running out of memory when reading the files, but the session file barely weights 1k, so it wouldn't make much sense.
Can someone throw any clue? Thanks
--EDIT:
I tried installing a fresh laravel proyect with only the Auth module and the spatie/laravel-permission package, and I noticed the same behaviour: it registers and logs users, but after logging it out, I'm no longer able to log in with any user.
In case someonw gets to the same error:
I could manage to solve this by backing up all my projects/databases and reinstalling wampserver with the last version of php (by the moment of this answer, it is 7.2.4) and reinstalling Laravel (luckily the proyect was barely starting), which only updated vlucas/phpdotenv package from 2.4.0 to 2.5.0 and phpunittest.
Whith this update now I can log in users normally, now let's see if it works as it should with spatie/laravel-permission package and the profile table I need to add.
I recently created a new production deployment for a new Laravel-based system. Initially, I had a few permissions issues with the storage folder that I resolved pretty easily. Once I resolved those, I had the app running correctly, but upon my next deployment (with Envoyer), I ran into a different issue that I haven't been able to pin down.
I'm now getting a fatal PHP error that I wasn't getting before:
PHP Fatal error: Uncaught ReflectionException: Class view does not
exist in
/var/www/Core/releases/20170804125010/vendor/laravel/framework/src/Illuminate/Container/Container.php:719\nStack
trace:\n#0
/var/www/Core/releases/20170804125010/vendor/laravel/framework/src/Illuminate/Container/Container.php(719):
ReflectionClass->__construct('view')\n#1
/var/www/Core/releases/20170804125010/vendor/laravel/framework/src/Illuminate/Container/Container.php(598):
Illuminate\Container\Container->build('view')\n#2
/var/www/Core/releases/20170804125010/vendor/laravel/framework/src/Illuminate/Container/Container.php(567):
Illuminate\Container\Container->resolve('view')\n#3
/var/www/Core/releases/20170804125010/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(708):
Illuminate\Container\Container->make('view')\n#4
/var/www/Core/releases/20170804125010/vendor/laravel/framework/src/Illuminate/Container/Container.php(1139):
Illuminate\Foundation\Application->make('view')\n#5
/var/www/Core/releases/20170804125010/vendor/laravel/framewo in
/var/www/Core/releases/20170804125010/vendor/laravel/framework/src/Illuminate/Container/Container.php
on line 719
I've played around with various permissions, tried manually running composer install/update, npm install/etc. with no resolution. Any thoughts would be greatly appreciated.
After quite a bit of experimentation with no luck, I think I resolved it. The Ubuntu user that was set up for deployment with Envoyer was, by default, deploying everything with the 'envoyer' group permissions. This created a permissions conflict with the actual app permissions on Ubuntu. I updated the default group for the deploying user to 'www-data' and it seems that everything is cleared up now.
I've developed a small project on a machine, using CakePHP 3.0, and I need it to run on another machine. I've tried to install it on several other machines.
If I run the composer to install the CakePHP 3.0, then I copy my stuff to overwrite it, the project works. I've tried this on two machines and had no problem so far. If I don't run the composer, and just copy the stuff to the target machine, it gives me the following error. I've tried this on 3 machines, and every machine gives me this:
Fatal error: Class 'Locale' not found in /home/u113681897/public_html/vendor/cakephp/cakephp/src/I18n/I18n.php on line 229
Fatal error: Class 'Locale' not found in /home/u113681897/public_html/vendor/cakephp/cakephp/src/I18n/I18n.php on line 229
I've copied the whole project to this server to test.
I told you this because I thought it has something to do with my problem. The point is that I have to run this on a machine that is not mine, and I can't install composer on it. The /public_html/vendor/cakephp/cakephp/src/I18n/ has files related to internationalization and localization, but my project will never be translated, so a workaround to make the project ignore those files would be enough to solve my problem.
The following code is an excerpt from the (...)/I18n/I18n.php that might be relevant:
<?php
namespace Cake\I18n;
use Aura\Intl\FormatterLocator;
use Aura\Intl\PackageLocator;
use Aura\Intl\TranslatorFactory;
use Cake\I18n\Formatter\IcuFormatter;
use Cake\I18n\Formatter\SprintfFormatter;
use Locale;
class I18n {
// lots of code here
public static function defaultLocale() {
if (static::$_defaultLocale === null) {
static::$_defaultLocale = Locale::getDefault() ?: 'en_US';
// the line above is the Line 229
}
return static::$_defaultLocale;
}
// many code here too
}
I've checked that another file also tries to access this Locale class, but I don't know if there are other files trying to access it as well. Many files from everywhere inside the project tries to access methods from I18n.php. I need it running but I can't figure out how to make it run.
Any help will be greatly appreciated.
As I just found out, prior to CakePHP 3.0, the installation must be done by composer, as stated in the 3.0 migration guide:
CakePHP should be installed with Composer
Since CakePHP can no longer easily be installed via PEAR, or in a shared
directory, those options are no longer supported. Instead you should use
Composer to install CakePHP into your application.
So it won't run on regular free web hosting services.
I really need your help. Actually, my journey begin with the installation Drupal and some modules. After a couple of days I suddenly get an issue "500 Internal Server Error".
I asked my hosting provider why this happened, he said "That because of the file .htaccess and you should add to this file php display error". So i did this and I get a new issue :
"Fatal error: Call to undefined function menu_load() in ...
/public_html/includes/menu.inc on line 579."
By the way, that's line 579
else {$return = $function($value);}
P.S: I am a beginner in PHP. I like Drupal a lot and want to study Drupal in further and create cool sites, but this problem...
need to figure out what function it's trying to call first.
change the line
else {$return = $function($value);}
to
else {echo $function;exit;$return = $function($value);}
Here are few tips:
make sure your Drupal core has all the files in the right place (especially menu module),
make sure your imported database is in UTF-8 format,
upgrade your Drupal core to the latest version (drush fr && drush up drupal)
clear all your caches (drush -y cc all), including your memcached (killall memcached),
rebuild your registry by using [Registry Rebuild][1],
if you're using modules which are implementing drupal_bootstrap() (such as Secure Site), disable them,
try disabling your PHP cache engines (such as XCache, Zend optimizer) to see if that's the problem,
test it on different environment/machine,
eventually restore your database from the point where it was working before