"Fatal error: cannot override class" ... but class was not declared

(I am using Joomla v1.5.15 and PHP 5.3.4)

I tested the solutions found in this and other developer forums, but I still have the same error.

Requires file => contratolocal.php

... if ( !class_exists('MTIHelperEstadosLocal') ) JLoader::import('helpers.estados.estadoslocal', JPATH_COMPONENT, false); class MTIControllerContratoLocal extends MTIController { ... 

Required file => estadoslocal.php

 ... class MTIHelperEstadosLocal extends MTIHelperEstados { ... 

"JLoader :: import" is commonly used in Joomla to import files into the actual script. Anyway, I also tried using include / require_once php methods.

I got the same error with every solution I tried:

"Fatal error: Unable to override MTIHelperEstadosLocal class"

The class is not declared earlier because I cannot use the class without import, and if I print the returned php get_declared_classes () method array, this class will not be.

What's happening?

thanks

+4
source share
1 answer

solvable.

There were 2 problems:

  • There are some helpers in my project that include other files, and one of them has a previously executed require_once.
  • require_once does not avoid the second include, and I had to encode every require_once in state:

    if (! class_exists ('MTIHelperEstadosLocal'))

+3
source

Source: https://habr.com/ru/post/1388456/


All Articles