Skip Navigation

[Gelöst] Error: Cannot redeclare class FieldFactory….

This support ticket is created vor 6 Jahre, 8 Monate. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 23 Antworten, has 3 Stimmen.

Last updated by John Johansen vor 6 Jahre, 7 Monate.

Assisted by: Minesh.

Author
Artikel
#565722

Tell us what you are trying to do?
Create an instance of a custom post type ("Firm").
Is there any documentation that you are following?
No.
I had installed the Toolset plugins once before, created some custom post types and some instances of them. I encountered some configuration problems with the plugins, so I deleted them. After re-installing the plugins, the instances of the various custom post types remained, and I deleted them. I then created new versions of some of the custom post types, but with different field structures.
When I tried to add an instance of one of the custom post types, I received the error.

Is there a similar example that we can see?
No.

What is the link to your site?
hidden link

#565730

I created a new custom post type that I had not created in the original installation of the plugins.
When I tried to create a new Field Group, I received the same error.

#565857

Minesh
Supporter

Languages: Englisch (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

First of all, Could you please send me debug information that will help us to investigate your issue.
=> https://toolset.com/faq/provide-debug-information-faster-support/

Where and how you are trying to create the new instance of the field could you please share step by step information you followed and how can I reproduce the issue.

#565959

I only had two other plugins (Akismet and Duplicator) installed. I deactivated both of them, but I still received the same error.
Then I deactivated the Layouts plugin, and I no longer see the error.
However, I still need the Layouts plugin to develop some reasonable complex user interfaces.

The debug information is below:
{"core":{"Wordpress":{"Multisite":"No","SiteURL":"https:\/\/gtagolfer.com\/wp","HomeURL":"https:\/\/gtagolfer.com\/wp","Version":"4.8.1","PermalinkStructure":"\/archives\/%post_id%","PostTypes":"post, page, attachment, revision, nav_menu_item, custom_css, customize_changeset, wp-types-group, wp-types-user-group, wp-types-term-group, cred-form, cred-user-form, view, view-template, job, firm","PostSatus":"publish, future, draft, pending, private, trash, auto-draft, inherit"},"Server":{"jQueryVersion":"1.12.4","PHPVersion":"5.2.17","MySQLVersion":"5.5.55","ServerSoftware":"Apache"},"PHP":{"MemoryLimit":"128M","UploadMax":"100M","PostMax":"50M","TimeLimit":"30","MaxInputVars":"1000"}},"plugins":{"active_plugins":{"cred-frontend-editor\/plugin.php":{"Name":"Toolset CRED","PluginURI":"https:\/\/toolset.com\/home\/toolset-components\/#cred","Version":"1.9.2","Author":"OnTheGoSystems","AuthorURI":"http:\/\/www.onthegosystems.com\/","TextDomain":"cred-frontend-editor","DomainPath":"","Network":false,"Title":"Toolset CRED","AuthorName":"OnTheGoSystems"},"types-access\/types-access.php":{"Name":"Toolset Access","PluginURI":"https:\/\/toolset.com\/home\/types-access\/?utm_source=accessplugin&utm_campaign=access&utm_medium=release-notes-plugins-list&utm_term=Visit plugin site","Version":"2.4.2","Author":"OnTheGoSystems","AuthorURI":"http:\/\/www.onthegosystems.com\/","TextDomain":"types-access","DomainPath":"","Network":false,"Title":"Toolset Access","AuthorName":"OnTheGoSystems"},"types\/wpcf.php":{"Name":"Toolset Types","PluginURI":"http:\/\/wordpress.org\/extend\/plugins\/types\/","Version":"2.2.16","Author":"OnTheGoSystems","AuthorURI":"http:\/\/www.onthegosystems.com","TextDomain":"types","DomainPath":"","Network":false,"Title":"Toolset Types","AuthorName":"OnTheGoSystems"},"wp-views\/wp-views.php":{"Name":"Toolset Views","PluginURI":"https:\/\/toolset.com\/?utm_source=viewsplugin&utm_campaign=views&utm_medium=plugins-list-full-version&utm_term=Visit plugin site","Version":"2.4.1","Author":"OnTheGoSystems","AuthorURI":"http:\/\/www.onthegosystems.com","TextDomain":"wp-views","DomainPath":"","Network":false,"Title":"Toolset Views","AuthorName":"OnTheGoSystems"}},"mu_plugins":[],"dropins":[]},"theme":{"Name":"Toolset Starter Child","ThemeURI":null,"Author":"<a href=\"http:\/\/www.onthegosystems.com\/\">OnTheGoSystems<\/a>","AuthorURI":null,"Template":"toolset-starter","Version":"1.1","TextDomain":null,"DomainPath":null},"extra-debug":{"access":{"rules":{"types":[],"taxonomies":[]},"debug":[],"settings":{"types":[],"tax":[],"third_party":[]},"errors":[]},"types":{"add_resized_images_to_library":0,"register_translations_on_import":1,"images_remote":0,"images_remote_cache_time":"36","help_box":"by_types","hide_standard_custom_fields_metabox":"show","postmeta_unfiltered_html":"off","usermeta_unfiltered_html":"off"},"CRED":{"wizard":1,"syntax_highlight":1,"cache_notice":1,"export_settings":1,"export_custom_fields":1,"use_bootstrap":0,"autogeneration_email":{"subject":"Welcome new user","body":"[username]Your username is: %cuf_username%[\/username]\\n[nickname]Your nickname is: %cuf_nickname%[\/nickname]\\n[password]Your password is: %cuf_password%[\/password]"},"dont_load_cred_css":1,"enable_post_expiration":0},"views":{"views_template_loop_blog":0,"wpv_bootstrap_version":1,"wpv_custom_conditional_functions":[],"wpv_custom_inner_shortcodes":[],"wpv_debug_mode":"","wpv_debug_mode_type":"compact","wpv_map_plugin":0,"wpv_show_edit_view_link":1,"wpv_show_hidden_fields":"","wpv_saved_auto_detected_framework":"","wpv_codemirror_autoresize":"","wpv_enable_pagination_manage_history":0,"wpv_enable_parametric_search_manage_history":0,"views_template_for_corporation":12,"views_template_for_firm":15,"view_cpt_firm":16,"views_template_for_job":30,"wpv_post_types_for_archive_loop":{"native":{"home":["corporation"]}},"view_cpt_corporation":"14","views_template_for_service":36,"view_cpt_service":40,"view_cpt_job-application":67}}}

#566450

Minesh
Supporter

Languages: Englisch (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - Do you see any errors while Layouts plugin is active? If yes - Could you please share problem URL where I can see the error. You should activate WP_DEBUG from wp-config.php file to see the error on the page.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).

I have set the next reply to private which means only you and I have access to it.

#566553

I deactivated and deleted the Layouts plugin (again). I was then able to add new instances of custom post types.
I then reinstalled and activated the Layouts plugin. I then attempted to add an instance of a custom post type, and again I received the following error:

Fatal error: Cannot redeclare class FieldFactory in /home/gtagolf/public_html/wp/wp-content/plugins/layouts/vendor/toolset/toolset-common/toolset-forms/classes/class.field_factory.php on line 203

#566637

Minesh
Supporter

Languages: Englisch (English )

Timezone: Asia/Kolkata (GMT+05:30)

Ok - as I understand, you have one CPT added to your site using WP native way using register_post_type() function - correct?

Now, the issue is when Layouts plugin is active you could not able to add new entry for this registered CPT and if Layouts plugin is deactivated, you are able to create new entry for your registered CPT - correct?

If yes:
Could you please share details how you registered your post type and exact steps to replicate the issue.

#566814

Minesh
Supporter

Languages: Englisch (English )

Timezone: Asia/Kolkata (GMT+05:30)

My questons:
1) What is the source of references to 'FieldFactory'? Is that a part of Toolset?
=> Yes - this error is part of Toolset and I'm happy to help you to resolve this but the issue is I do not able to reproduce this issue.

2) Based on the support log, other users have experienced similar errors. How were their issues resolved?
=> Could you please share those tickets.

I really would like to help you further but the issue is that I could not able to reproduce the issue. I was also using Toolset starter theme and now as you suggested, I also changed the theme to 'Twenty Fifteen' them and then I tried to create a new field and also tried to add a new post (instance).

There might be the issue that your site is corrupted - why dont you try to start with fresh install and check if that works for you as with the current setup you were having issues before as well.

#566851

1)
I did a search of 'cannot redeclare class' in the existing support tickets, and I reviewed some of them. However, I could not find any reference to a specific cause/solution to the problem.
2)
Just to clarify, I have been focused on CPTs, not 'fields'. Also, I am not using any instances of native 'posts', only custom post types.
3)
When you suggest a fresh 'install', what are you referring to? Toolset? All plugins? WordPress?
As I mentioned, I had already deleted and reinstalled Toolset. This issue occurred after the reinstall, and only when Layouts is activated.

#567039

Minesh
Supporter

Languages: Englisch (English )

Timezone: Asia/Kolkata (GMT+05:30)

1)
I did a search of 'cannot redeclare class' in the existing support tickets, and I reviewed some of them. However, I could not find any reference to a specific cause/solution to the problem.
==> OK

2)
Just to clarify, I have been focused on CPTs, not 'fields'. Also, I am not using any instances of native 'posts', only custom post types.
=> I know this and I understood that.

3)
When you suggest a fresh 'install', what are you referring to? Toolset? All plugins? WordPress?
As I mentioned, I had already deleted and reinstalled Toolset. This issue occurred after the reinstall, and only when Layouts is activated.
=> When I say fresh install - I mean you should start from first.
- Install fresh wordpress
- install toolset plugins
- create your post type
- check if you are able to reproduce the issue

#567137

1)
Do you not have data/information regarding any other support tickets which refer to this specific error message? That is, you don't have any information on how even one of the problems cited in these tickets was caused or corrected?
Simply acknowledging that I (not you) did a search on existing tickets does not help me. I expect that you would have access to more detailed information not available to me.

2)
If you know this and understand it, why did you refer to 'fields'? I am trying to be precise in my terminology in order to avoid any confusion that may waste time.

3)
So, we have isolated the cause of the error to the Layouts plugin, but you recommend that I do all the work of reinstalling WordPress/plugins, recreating my data and re-running tests that have already failed. If the problem persists, what then?

#567162

Minesh
Supporter

Languages: Englisch (English )

Timezone: Asia/Kolkata (GMT+05:30)

1)
Do you not have data/information regarding any other support tickets which refer to this specific error message? That is, you don't have any information on how even one of the problems cited in these tickets was caused or corrected?
Simply acknowledging that I (not you) did a search on existing tickets does not help me. I expect that you would have access to more detailed information not available to me.
==> No - I do not see any other ticket related to the exact issue you are having.

2)
If you know this and understand it, why did you refer to 'fields'? I am trying to be precise in my terminology in order to avoid any confusion that may waste time.
==> Well - actually I shared whole workflow with you so you know that what I've done to reproduce the issue and whole workflow went well and I did not able to reproduce the issue.

3)
So, we have isolated the cause of the error to the Layouts plugin, but you recommend that I do all the work of reinstalling WordPress/plugins, recreating my data and re-running tests that have already failed. If the problem persists, what then?
==> Well - I asked you to follow that step because in your previous reply you acknowledge you had few issues before with your current installation and you tried to reinstall the plugins manually again and there is the possibility that your site might be corrupted.

If the problem persists then as per our support process I need your duplicator package of your site to debug this issue further.

You can find more info here:
=> https://toolset.com/faq/provide-supporters-copy-site/

#567435

Minesh
Supporter

Languages: Englisch (English )

Timezone: Asia/Kolkata (GMT+05:30)

Ok great - thanks for sharing step by step information.

Now I want only one thing - Could you please share the screenshot of field group ("Firms-primary") and field group "Jobs-primary" as I would like to know what fields you have added to both fields group.

Once you share that I will have accurate information to reproduce the issue and I will first try to reproduce on my test install and will get in touch with you with further updates.

Just share information what fields you used with both fields group and associated fields slug.

#568469

Minesh
Supporter

Languages: Englisch (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - this is a frustrating and really strange issue. I followed the exact steps and created post types and post fields and I do not able to reproduce the issue. Please check following screenshot:
=> hidden link

I need your site's duplicator package to see whats going wrong there:
=> https://toolset.com/faq/provide-supporters-copy-site/

#568503

Before we proceed with looking at my Duplicator data, I have some diagnostic questions:

1) The most recent error message I received reference 'on line 203' of a particular PHP file. When I looked at that file, it contained only 202 lines. So, how could the error be on line 203?

2) What is the general cause of this error ('cannot redeclare class')? Other tickets have triggered this error before, so what condition(s) are required to trigger it in your code?

3) I have done some other research and this error may be avoided by using 'include_once "something.php"' to prevent a class from being declared multiple times. Given this, can't this be done with the FieldFactory classes?

4) The error appears to be completely dependent on the Layouts plugin (i.e. the error occurs when this particular plugin is activated, but not when the plugin is deactivated/deleted). What is the relationship between the Layouts plugin and FieldFactory? Where are the FieldFactory classes being declared in the Layouts plugin?

In short, I don't think you're going to find anything unusual in my site. In this latest set of tests, I started with a brand-new installation of WordPress, ToolSet plugins (no others) and the default theme.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.