Jump to content

Module overriding class. Problem when reinstall. ReflectionException


serralta

Recommended Posts

Hi everybody.

 

I am trying to develop an easy module. It is my first one, so it may be some stupid problem but the fact is I'm stuck with it from some days ago.

 

I have a simple module that has a override/classes/Product.php class. It adds a simple single method. When I install it, all is fine. The overriden Product class is generated.

 

The problem is when I do some changes and I try to reinstall it (reseting it or uninstalling and installing, again, the result is the same). The method I added to the overriden class is not deleted completly when I uninstall the module. Only the name is removed but not the function body.

 

This causes a Fatal error: Uncaught exception 'ReflectionException' with message 'Class ProductOverrideOriginal_remove539defbda2a6c does not exist'

 

I paste the generated code.

 

When I install the module for first time I got:

class Product extends ProductCore {
	public function getLocalizationImage(Context $context = null)
	{
		return true;
	}  
}

When I reinstall it, or uninstall it the classe is left as follows:

class Product extends ProductCore {
	{
		return true;
	}  
}

Is it normal? What am I missing? The same problem if I do a second module that adds a DIFFERENT function to the Produt class. The second module I install has no name in its function declarations.

 

Any help would be appreciate.

Thanks!

Edited by serralta (see edit history)
Link to comment
Share on other sites

  • 3 weeks later...

hi,

 

delete all your file overrided in www/override

and read www/override/readme_override.txt which tel :

in order to reinstate the default behavior, you must delete the /cache/class_index.php file

  • Like 1
Link to comment
Share on other sites

  • 6 months later...

I don't think delete /cache/class_index.php file would solve the problem.

 

I've found this workaround here

http://stackoverflow.com/questions/18996528/how-to-remove-override-when-uninstalling-the-module-in-prestashop

 

not a perfect solution but you have to manually remove any file generated in override directory.

 

still looking forward to better elegant solution.

  • Like 1
Link to comment
Share on other sites

  • 1 year later...
  • 4 years later...
On 6/15/2014 at 9:15 PM, serralta said:

Hi everybody.

 

I am trying to develop an easy module. It is my first one, so it may be some stupid problem but the fact is I'm stuck with it from some days ago.

 

I have a simple module that has a override/classes/Product.php class. It adds a simple single method. When I install it, all is fine. The overriden Product class is generated.

 

The problem is when I do some changes and I try to reinstall it (reseting it or uninstalling and installing, again, the result is the same). The method I added to the overriden class is not deleted completly when I uninstall the module. Only the name is removed but not the function body.

 

This causes a Fatal error: Uncaught exception 'ReflectionException' with message 'Class ProductOverrideOriginal_remove539defbda2a6c does not exist'

 

I paste the generated code.

 

When I install the module for first time I got:


class Product extends ProductCore {
	public function getLocalizationImage(Context $context = null)
	{
		return true;
	}  
}

When I reinstall it, or uninstall it the classe is left as follows:


class Product extends ProductCore {
	{
		return true;
	}  
}

Is it normal? What am I missing? The same problem if I do a second module that adds a DIFFERENT function to the Produt class. The second module I install has no name in its function declarations.

 

Any help would be appreciate.

Thanks!

Hi, I'm having the same problem, did you find a solution?

Let me know. 

Regards.

Link to comment
Share on other sites

17 hours ago, rrataj said:

What is in your "uninstall()" method?

Hi, this is my code for uninstall method:

    public function uninstall()
    {
        Configuration::deleteByName('PECSDIFIELDS_SHOW_REDLABEL');
        include(dirname(__FILE__).'/sql/install.php');

        return parent::uninstall();
    }

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...