Jump to content

Error checking during module installation


affect
 Share

Recommended Posts

While developing custom modules I noticed that sometimes they get installed even if some of my checks fail. I click install, I get an error "Module wasn't installed correctly", then I refresh the page and it shows up as "Installed".

The usual module installation process looks like this:

if (!parent::install() OR !$this->registerHook('header') OR *other custom checks*)
 return false;
else
 return true;



I checked the parent::install() function and found the following line (Module.php):

$result = Db::getInstance()->AutoExecute(_DB_PREFIX_.$this->table, array('name' => $this->name, 'active' => 1), 'INSERT');



So, if I understand correctly, parent::install() function inserts the module into installed modules table after doing some default checks. Since in our module we use it BEFORE any other check, it installs the module and only AFTER IT'S INSTALLED performs all other checks. If any of them fail, our install() function returns false and we get an error "Module wasn't installed successfully", but the module IS ALREADY in the installed modules table, so after refreshing the page it's listed as "Installed".

I'm really looking for an answer from PS devs here, since I've been issues recently when my modules showed up as "Installed" in spite of my custom checks failing. Correct me if I'm wrong.

Share this post


Link to post
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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More