I am learning symfony2 and atfer creating some Doctrine Entities in a bundle, I wanted to move them.
However, after moving, and changing any instances of them being referenced, I was getting errors when trying to run my application.
I moved them back, and everything was fine.
Now I am just tyring to remove them completly, but again, I get errors when doing so.
Any help on removing Entities entirely?
I did exactly the same thing that Mr Pablo did, but for a bundle : I moved a bundle (renamed) and modified all calls to it.
I have the same error :
ErrorException: Catchable Fatal Error: Object of class __PHP_Incomplete_Class could not be converted to string in /Volumes/Data/home/timi/Sites/symfony2/vendor/symfony/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php line 70
in /Volumes/Data/home/timi/Sites/symfony2/vendor/symfony/src/Symfony/Component/HttpKernel/Debug/ErrorHandler.php line 65
at ErrorHandler->handle() in /Volumes/Data/home/timi/Sites/symfony2/vendor/symfony/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php line 70
at AbstractToken->getUsername() in /Volumes/Data/home/timi/Sites/symfony2/vendor/symfony/src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php line 56
at SecurityDataCollector->collect() in /Volumes/Data/home/timi/Sites/symfony2/vendor/symfony/src/Symfony/Component/HttpKernel/Profiler/Profiler.php line 174
at Profiler->collect() in /Volumes/Data/home/timi/Sites/symfony2/vendor/symfony/src/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php line 90
at ProfilerListener->onKernelResponse()
at call_user_func() in /Volumes/Data/home/timi/Sites/symfony2/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Debug/TraceableEventDispatcher.php line 82
at TraceableEventDispatcher->doDispatch() in /Volumes/Data/home/timi/Sites/symfony2/app/cache/dev/classes.php line 3678
at EventDispatcher->dispatch() in /Volumes/Data/home/timi/Sites/symfony2/app/cache/dev/classes.php line 4754
at ContainerAwareEventDispatcher->dispatch() in /Volumes/Data/home/timi/Sites/symfony2/app/cache/dev/classes.php line 3904
at HttpKernel->filterResponse() in /Volumes/Data/home/timi/Sites/symfony2/app/cache/dev/classes.php line 3896
at HttpKernel->handleRaw() in /Volumes/Data/home/timi/Sites/symfony2/app/cache/dev/classes.php line 3846
at HttpKernel->handle() in /Volumes/Data/home/timi/Sites/symfony2/app/cache/dev/classes.php line 4791
at HttpKernel->handle() in /Volumes/Data/home/timi/Sites/symfony2/app/bootstrap.php.cache line 547
at Kernel->handle() in /Volumes/Data/home/timi/Sites/symfony2/web/app_dev.php line 20
Some help will be very welcomed :)
EDIT:
Well I solved the problem, Adam Stacey had heard it well :)
Before changing anything, I was logged in the website, by using FOSUserBundle firewall.
By changing the name of the bundle, it fooled the firewall and it was stuck at line 70 of ./vendor/symfony/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php
Here is the function :
public function getUsername()
{
if ($this->user instanceof UserInterface) {
return $this->user->getUsername();
}
return (string) $this->user;
}
So I commented out the line return (string) $this->user;, reloaded the webpage, logged out, than reverted the comment. And voilĂ !
What kind of errors were you getting?
Make sure you:
Clear cache
Rebuild database
Don't have any entity relationships with it
Don't have any code based on the entities
Like Inori mentioned have you tried rebuilding your entities?
If not try this from the CLI:
php app/console doctrine:generate:entities Acme
php app/console doctrine:schema:update --force
Replace "Acme" with your name, company name or whatever you have used in your bundles.
The other thing you may have to do is remove any instances where you have used the entities.
For example, you may have some entities in the controllers that look like this:
use Acme\BundleName\Entity\SomeEntity;
use Acme\BundleName\Entity\AnotherEntity;
They will need to be removed.
If you have the details of the particular errors that are coming up let me know what they are and I will try and help you further.
I have heard that this can also sometimes be to do with sessions. Are you using any bundles for authentication or anything like that?
In your php.ini file do you have your set to:
session.auto_start = Off
This may be way off, but worth a go. Let me know.
On a separate note. Did your server setup pass the checks in the app/check.php file that you can run via CLI?
Related
I am working with a code that was not written by me. It is a Laravel 3 application, it is giving me the following error:
PHP Warning: in_array() expects parameter 2 to be array, null given in /Users/use/Documents/project/laravel/error.php on line 87
Can you give me pointers on how to debug it? It is giving error in the file which was included in the framework. Also I using the php's inbuilt server to run the application. Does that cause problems? Any pointers are helpful.
PS: I am on a mac.
After looking at the source code it appears that you are getting the error from this file:
// laravel/error.php
// line 86
if (in_array($code, Config::get('error.ignore')))
{
return static::log($exception);
}
The method appears to be looking for the error.ignore config variable:
// application/config/error.php
// line 16
'ignore' => array(),
Check the application/config/error.php file, make sure that 'ignore' is set to an array. If it already is, then you likely have an error in one of the other config files which is corrupting the array.
Hopefully this helps and shows the steps you can take in tracking down the source of an error.
You can get this also if you're using composer and the required files have not been installed after a fresh checkout of the project. To resolve:
$ composer install
Or similar. To actually get a head on this information I had to throw $exception in the error.php file around line 87, then I saw the reason in the Apache error logs.
Most of this errors is about of parameters definition bug.
for example sometimes coder write
protected $guarded = 'title';
instead of
protected $guarded = ['title'];
That makes the paroblem
I am creating a Symfony2 application, all works well, but when i try to execute my behat tests or clear the cache, i got this error:
Error: Call to undefined method
Symfony\Bundle\FrameworkBundle\Templating\Loader\TemplateLocator::isFresh() in
[...]/vendor/symfony/assetic-
bundle/Symfony/Bundle/AsseticBundle/Factory/Resource/FileResource.php line 49
TemplateLocator does not even implements LoaderInterface, as required in FileResource construct.
Anyone has a clue ?
I figured out where the problem came from, but without understanding it.
It appeared that somewhere in my application I called
$this->container->get('twig')->render("Bundle:View:action.html.twig")
I changed to
$this->container->get('templating')->render("Bundle:View:action.html.twig")
twig service is a Twig_Environment instance, and template is a DelegatingEngine instance, both allowing to render a template.
And all works great again.
If someone could explain me what happened, I'll appreciate :)
So my Evo site stopped working the other day - just got a 500 error. I got my host to check the logs and found this:
[error] PHP Fatal error: Cannot redeclare insert_metka() (previously declared in
/home/mysite/public_html/manager/includes/document.parser.class.inc.php(790) : eval()'d code:2)
in /home/mysite/public_html/manager/includes/document.parser.class.inc.php(790) : eval()'d code on line 12
I have tired commenting out the offending line and removing the entire file to no avail. Does anyone know what this means and how to fix it?
EDIT: the code at line 790:
eval ($pluginCode);
Looks like a bad plugin has broken your site. Disable all your plugins and reinstate them one at a time until it breaks again, then you know which one is the culprit.
Once you've done that, post the plugin code here and we can help you debug it further. You shouldn't ever need to modify the MODX source code.
The problem is likely to be solved by wrapping the insert_metka() declaration like this:
if(!function_exists('insert_metka')) {
function insert_metka() {
// function code
}
}
http://wiki.modxcms.com/index.php/Creating_Snippets#Wrap_functions_inside_.21function_exists_conditional_if_the_resource_is_needed_to_run_more_than_once_on_a_page
That appears like a very simple problem. You are declaring insert_metka() two times. Remove it from one of the mentioned files. Once it is declared in saved file and apparently second time you are trying to declare it with the help of eval()
Cannot redeclare insert_metka() says that you are declaring a function twice (may be with your evals).
You should check on your included files.
To be sure to not include more than one time, you can use include_once or requiere_once instead of include and requiere
Accoring to document.parser.class.inc.php this line i guess you are using OOP.
So what you can do is create instantiation class for above class and then overwrite it.
There are other things too. you might declaring same function inside of same class.
I use sphinx php api as a service in a symfony2 project when I want to search a term in an index i got this warning
Warning: Invalid argument supplied for foreach() in /var/www/domain.com/Symfony2/src/project/myBundle/services/SphinxClient.php line 997
this is the line 997
foreach ( $this->_weights as $weight )
so I added a test befor foreach() like this if(!empty($this->_weights))
the same error appaires in each foreach so I added the same test.
then an other error appaires
Notice: Undefined property: prject\MyBundle\services\SphinxClient::$_socket in in /var/www/domain.com/Symfony2/src/project/myBundle/services/SphinxClient.php line 563
I was loking for the problem origin for hours.
thanks for your help in advance.
In sphinxapi.php file used old constructor.
Delete string ( near 430 )
function SphinxClient()
and write:
public function __construct()
and all very well.
Don't forget to set namespace in file (I renamed sphinxapi.php to SphinxClient.php) and write in begin it:
namespace Acme\MyBundle\Sphinx;
Your path may be something else.
Without seeing the source of the file, not a lot can do to help.
IN the standard sphinxapi.php class that comes with sphinx the varaiables are all class variables, so $this->_weigths is an array. Maybe that was missed when it was poted to Symfony
if (class_exists('PhpThumb')) {
$pt = PhpThumb::getInstance();
$pt->registerPlugin('GdReflectionLib', 'gd');
}
if (in_array('PhpThumb', get_declared_classes())) {
$pt = PhpThumb::getInstance();
$pt->registerPlugin('GdReflectionLib', 'gd');
}
Either of these codes blocks throw the following error: "PHP Fatal error: Class 'PhpThumb' not found"
Can anyone explain why? Is this a bug in PHP?
I've encountered the same bug. In my case problem was due to mixed Russian and English letters in class name which looks similar.
I had a legacy code running under a newer version of PHP (5.3.10). I had some require_once() statements that was not doing their job. As I could change, I changed them do include() and it worked again.
I guess it have something to do with the PHP version, because running under a previous version the website was ok.
This happened for me when I was requiring a file not needed by a phpunit class I was running. The file was there, but I got the error.
Yet for a test that does need that class, the same include call works.
My work around was to have 2 config files, where 1 requires that class file and the 2nd file doesn't. So when not needed, I use the latter.
A little clunky with 1 extra small file (that I shouldn't have to create .. cse' la vie), but unblocks the issue here
After spending few hours on practicing with this mistakefullish fatal error...I've admitted that this function doesn't work with SPL autoload! And I've finally found a solution :
I replace 'class_exists()' by 'file_exists()' with a little bit more process to find out the real path of the class file (my classes have the same name as their filename).
Hope it helps.