Vinod VT
Vinod VT

Reputation: 7159

Fatal error when moving pimcore from a server to local

I moved all my pimcore files plus the database from a server to my localhost and made the necessary changes in website/var/config/system.xml. Admin is working but the frond end is showing an error:

Fatal error: Call to a member function getFielddefinitions() on a non-object in /var/www/html/pimcore/pimcore/models/Object/Localizedfield/Resource.php on line 179

This line of code produces the error:

$this->model->getClass()->getFielddefinition("localizedfields")->getFielddefinitions()

The system requirements and file permissions are correct.

For testing purpose I installed a new pimcore project on my local system and it's working perfectly.

Can I make any changes in my Database? How can I run my project successfully on local?

Upvotes: 2

Views: 1834

Answers (4)

fuzin
fuzin

Reputation: 166

Pimcore uses database views for storing objects data. When exporting database, in views definitions there will be also SECURITY DEFINER.

/*!50013 DEFINER=`prod-user`@`%` SQL SECURITY DEFINER */

  1. OPTION: Vinot VT solution should work You can acchive same with running command:

php pimcore/cli/console.php deployment:classes-rebuild

  1. OPTION: Use same database username on your local env 'prod-user', which is useful if you will import prod database a lot

  2. OPTION: replace DEFINER=prod-user@% with DEFINER=local-user@% before importing database

Upvotes: 1

Vinod VT
Vinod VT

Reputation: 7159

The error is happen when there are already objects present using the class.

Solution

  1. Login to backend as Admin.
  2. Go to Settings > Object > Classes
  3. For each of the classes in the left tree, click on them and then hit Save in the bottom right. (If unable to save just create a new class by hit the button Add new class )

Now try to load the frondend. It will work.

Upvotes: 3

chluehr
chluehr

Reputation: 176

We need to see the actual error (as Vinod has already pointed out).

I could speculate, though:

Are the database credentials (aka the DB username) identical? If not you might need to remove the SECURITY DEFINER from the DB Dump. See: Remove DEFINER clause from MySQL Dumps for hints on how to do that.

Another source of error might be the cache. Are you using the default file-based Pimcore cache? If this is the case, try removing all files from website/var/cache and website/var/tmp

Let us know how that turned out.

Upvotes: 0

Rafal Gałka
Rafal Gałka

Reputation: 1030

You can:

  • set <debug>1</debug> in config.xml - this should show error

  • if it wasn't helped, check apache and/or php error log.

Upvotes: 0

Related Questions