0 - Class 'FormController' not found in a site view #971

Closed
opened 2023-01-30 12:06:23 +00:00 by Pierre Burri-Wittke · 9 comments

Steps to reproduce the issue

in a site view with a custom button witch goes to the next site view.
upgrade JCB version 2.12.16 to any of a newer version of JCB

Expected result

shows the next site view without any errors...

Actual result

a blank page with a php fatal error:

0 - Class 'FormController' not found 

System information (as much as possible)

  • OS Name & Version: MacOS Catalina
  • MySql Version: 5.7.34
  • Apache Version: 2.4.46
  • PHP Version: 7.4.21
  • Joomla Version: 3.10.11
  • JCB Version: 3.1.6 or 3.1.12
  • Browser: Firefox 102.7.0esr

Additional comments

the error happens in ComponentHelper.php after

$contents = static::executeComponent($path); 

the value of $path seams to be correct.

I already saw this error after upgrading JCB version 2.12.16 to JCB version 2.13.0, but I was first focused at the error with SITE_TOOLBAR (#969). After upgrading to 3.1.6, the error was still there, also after upgrading to JCB 3.1.12.
I didn't change any code in any site views.

### Steps to reproduce the issue in a site view with a custom button witch goes to the next site view. upgrade JCB version 2.12.16 to any of a newer version of JCB ### Expected result shows the next site view without any errors... ### Actual result a blank page with a php fatal error: ``` 0 - Class 'FormController' not found ``` ### System information (as much as possible) - OS Name & Version: MacOS Catalina - MySql Version: 5.7.34 - Apache Version: 2.4.46 - PHP Version: 7.4.21 - Joomla Version: 3.10.11 - JCB Version: 3.1.6 or 3.1.12 - Browser: Firefox 102.7.0esr ### Additional comments the error happens in ComponentHelper.php after ``` $contents = static::executeComponent($path); ``` the value of $path seams to be correct. I already saw this error after upgrading JCB version 2.12.16 to JCB version 2.13.0, but I was first focused at the error with SITE_TOOLBAR ([#969](https://git.vdm.dev/joomla/Component-Builder/issues/969)). After upgrading to 3.1.6, the error was still there, also after upgrading to JCB 3.1.12. I didn't change any code in any site views.

I went a bit further.
from $contents = static::executeComponent($path);

a get in the component there is:

$controller = JControllerLegacy::getInstance('Bookshop');

and in loader.php where $class = JControllerLegacy...

public function loadClass($class)
{
	if ($result = $this->loader->loadClass($class))
	{
		JLoader::applyAliasFor($class);
	}

in the controller in the view
there is:

class BookshopControllerShippingpayment extends FormController

and with FormController, it seams to get a null string.

I went a bit further. from $contents = static::executeComponent($path); a get in the component there is: $controller = JControllerLegacy::getInstance('Bookshop'); and in loader.php where $class = JControllerLegacy... public function loadClass($class) { if ($result = $this->loader->loadClass($class)) { JLoader::applyAliasFor($class); } in the controller in the view there is: class BookshopControllerShippingpayment extends FormController and with FormController, it seams to get a null string.
Owner

Okay so the controller that is not found is auto-loaded by Joomla, we don't need to load it, we simple need to add the use to the the top of the controller class:

use Joomla\CMS\MVC\Controller\FormController;

So let me ask if you made changes to the compiler path or any of the compiler/joomla_3 files? Since these where updated and now load the needed use requests to the head of the files.

Next are you installing JCB from this link? and are you enabling all the JCB plugins?

Going from JCB 2 to JCB 3 we have many plugins that need to act during compilation for things to work. Each of these plugins have tutorials and are explained in detail under the PRO Members playlist.

The FormController works in all my projects and I have not seen this issue before. So currently I am unable to duplicate the issue... which makes it very hard to debug.

Further more, any customization migration will need attention. Meaning any customization that you have made will require manual migration. We tried to avoid any breaking changes but in some cases it is out of my hands due to the level of freedom and divergent outcomes.

Okay so the controller that is not found is auto-loaded by Joomla, we don't need to load it, we simple need to add the `use` to the the top of the controller class: ``` use Joomla\CMS\MVC\Controller\FormController; ``` So let me ask if you made changes to the compiler path or any of the [compiler/joomla_3](https://git.vdm.dev/joomla/Component-Builder/src/branch/staging/admin/compiler/joomla_3) files? Since these where updated and [now load the needed](https://git.vdm.dev/joomla/Component-Builder/src/branch/staging/admin/compiler/joomla_3/FormController.php#L20) `use` requests to the head of the files. Next are you installing JCB from [this link](https://git.vdm.dev/joomla/pkg-component-builder/archive/master.zip)? and are you enabling all the JCB plugins? Going from JCB 2 to JCB 3 we have many plugins that need to act during compilation for things to work. Each of these plugins have tutorials and are explained in detail under the PRO Members playlist. The `FormController` works in all my projects and I have not seen this issue before. So currently I am unable to duplicate the issue... which makes it very hard to debug. Further more, any customization migration will need attention. Meaning any customization that you have made will require manual migration. We tried to avoid any breaking changes but in some cases it is out of my hands due to the level of freedom and divergent outcomes.

we simple need to add the use to the the top of the controller class:

I thought so it was just a namespace problem.
I just added it in the controllers with a custom code and know it works again :-)

So let me ask if you made changes to the compiler path or any of the compiler/joomla_3 files?

definitely no.

Next are you installing JCB from this link? and are you enabling all the JCB plugins?

I used think link from tags since my last version of JCB was so old... and yes, a few of the plugins were disabled.

Going from JCB 2 to JCB 3 we have many plugins that need to act during compilation for things to work. Each of these plugins have tutorials and are explained in detail under the PRO Members playlist.

ok, I will have to see these tutorials in details.

Further more, any customization migration will need attention. Meaning any customization that you have made will require manual migration. We tried to avoid any breaking changes but in some cases it is out of my hands due to the level of freedom and divergent outcomes.

I can understand this very well.

Thanks a lot gain.

> we simple need to add the use to the the top of the controller class: I thought so it was just a namespace problem. I just added it in the controllers with a custom code and know it works again :-) > So let me ask if you made changes to the compiler path or any of the compiler/joomla_3 files? definitely no. > Next are you installing JCB from this link? and are you enabling all the JCB plugins? I used think link from [tags](https://git.vdm.dev/joomla/Component-Builder/tags) since my last version of JCB was so old... and yes, a few of the plugins were disabled. > Going from JCB 2 to JCB 3 we have many plugins that need to act during compilation for things to work. Each of these plugins have tutorials and are explained in detail under the PRO Members playlist. ok, I will have to see these tutorials in details. > Further more, any customization migration will need attention. Meaning any customization that you have made will require manual migration. We tried to avoid any breaking changes but in some cases it is out of my hands due to the level of freedom and divergent outcomes. I can understand this very well. Thanks a lot gain.

Hi,

I hope this message finds you well. I am writing to report a simillar bug that I've encountered in an extension that I developed using Component Builder.

The issue is that I receive the following error message: "Class 'FormController' not found" when I try to access a particular page with a logged-in user. If you need it, I can send you a link to the page and the user details. The error is occurring in the file "ao_services_ouverts.php" on line 27.

39.PNG

After investigation with an older version that is running in production, we found that the class "class AoservicesControllerAjouter_ao_services extends FormController" is wrong and the correct class should be: "class AoservicesControllerAjouter_ao_services extends JControllerForm" to resolve the error
Do you have any idea of the cause of the problem and a global solution to give us about this class error? Thank you for your help.

formcontroller_img.png

We can create a sandbox access if you want to have an example for debugging.

I would greatly appreciate it if you could please consider correcting this error in a future update of the extension. Thank you very much for your time and assistance in this matter.

Best regards,

Hi, I hope this message finds you well. I am writing to report a simillar bug that I've encountered in an extension that I developed using Component Builder. The issue is that I receive the following error message: "Class 'FormController' not found" when I try to access a particular page with a logged-in user. If you need it, I can send you a link to the page and the user details. The error is occurring in the file "ao_services_ouverts.php" on line 27. 39.PNG After investigation with an older version that is running in production, we found that the class "class AoservicesControllerAjouter_ao_services extends FormController" is wrong and the correct class should be: "class AoservicesControllerAjouter_ao_services extends JControllerForm" to resolve the error Do you have any idea of the cause of the problem and a global solution to give us about this class error? Thank you for your help. formcontroller_img.png We can create a sandbox access if you want to have an example for debugging. I would greatly appreciate it if you could please consider correcting this error in a future update of the extension. Thank you very much for your time and assistance in this matter. Best regards,

have you tried to add in the header

use Joomla\CMS\MVC\Controller\FormController;

in the last controller file

.../com_aoservices/controllers/ao_services_ouvers.php ?

this was the only line I had to add in my controller file.

have you tried to add in the header ``` use Joomla\CMS\MVC\Controller\FormController; ``` in the last controller file ``` .../com_aoservices/controllers/ao_services_ouvers.php ? ``` this was the only line I had to add in my controller file.
Owner

@appnweb I would start by looking at what JCB has build in the Joomla package. I would look at the files, and see if the use ... value was added. Once I see what happened there, I can start looking at the next things. But knowing what happened in the actual package is the first step.

@appnweb I would start by looking at what JCB has build in the Joomla package. I would look at the files, and see if the use ... value was added. Once I see what happened there, I can start looking at the next things. But knowing what happened in the actual package is the first step.

Applying this change it works, but I don't understand why this line is present on other files and not in this one.
I wanted to know if this will be fixed in a future update and eventually if the plugin will be updated to Joomla 4.

Thanks to you for your help.

Applying this change it works, but I don't understand why this line is present on other files and not in this one. I wanted to know if this will be fixed in a future update and eventually if the plugin will be updated to Joomla 4. Thanks to you for your help.

Rather late to the party but I think I have the answer to this. Having been facing the 'FormController' not found issue for quite a while, I had stuck to an old version of JCB to sidestep it. Today, I spent a couple of hours experimenting as, similar to others, I had found that most of my views had the controller line but a stubborn few did not. The end result appears to be that if the main dynamic get for the view is a getItem, then the line appears. And, if the main dynamic get is a getListQuery then the FormController line is not included.

Basically, I created a new view with a getItem method, then added a couple of Custom Buttons and method stubs in the Controller. Compile with the latest JCB and the 'use Joomla\CMS\MVC\Controller\FormController;' line appears in the newViewController.php file. Change to a getListQuery, recompile - no 'use Joomla\CMS\MVC\Controller\FormController;'

I'm sure that there's a perfectly logical explanation for this - and no doubt it's documented somewhere - but I'm at the limits of my abilities getting 'under the hood' of JCB and pass this on with no further explanation.

Rather late to the party but I think I have the answer to this. Having been facing the 'FormController' not found issue for quite a while, I had stuck to an old version of JCB to sidestep it. Today, I spent a couple of hours experimenting as, similar to others, I had found that most of my views had the controller line but a stubborn few did not. The end result appears to be that if the main dynamic get for the view is a getItem, then the line appears. And, if the main dynamic get is a getListQuery then the FormController line is not included. Basically, I created a new view with a getItem method, then added a couple of Custom Buttons and method stubs in the Controller. Compile with the latest JCB and the 'use Joomla\CMS\MVC\Controller\FormController;' line appears in the newViewController.php file. Change to a getListQuery, recompile - no 'use Joomla\CMS\MVC\Controller\FormController;' I'm sure that there's a perfectly logical explanation for this - and no doubt it's documented somewhere - but I'm at the limits of my abilities getting 'under the hood' of JCB and pass this on with no further explanation.
Owner

@oldgit hmmm, I think I can fix this... thank you! this has been very helpful.

@oldgit hmmm, I think I can fix this... thank you! this has been very helpful.
Sign in to join this conversation.
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: joomla/Component-Builder#971
No description provided.