MarkE Posted January 14 Share Posted January 14 This may be a simple question from a 'simple' person, so I hope there is a simple answer! I have built a module that will not work without certain other software and have a 'requires' statement in the {module}.info.php file like 'requires' => ['ProcessWire>=3.0.200', 'RockFrontend', 'ProcessDbMigrate>=1.0.19'], This all appears to be present and recognized when installing the module. However, the module is shown as being installed even if the requirements are not met but, of course, it is not installed correctly as it needs (for instance) ProcessDbMigrate to install it fully. How do I actually stop the install from happening if the requirements are not met? Link to comment Share on other sites More sharing options...
MarkE Posted January 15 Author Share Posted January 15 (edited) I can sort-of achieve this by explicitly checking in the install() method and throwing an exception in the following manner: if(!wire()->modules->isInstalled('RequiredModule')) { throw new WireException(__("Unable to install MyModule without first installing RequiredModule")); return; } However, that seems rather cumbersome and I would have thought it should be unneccesary when the {module}.info.php already declares the requirements. Update: I have tried to investigate where the requirements are checked and dealt with, but it's very confusing. ModulesLoader.php (463) gives an error message, but just when listing, not as part of the installation. ModulesInstaller install() method seems to be the main place - line 96: $error = $this->_('Unable to install required module') . " - $requiresModule. "; but that doesn't always seem to operate for reasons I have not yet been able to ascertain. Am I alone with this problem?? Edited January 15 by MarkE Update 1 Link to comment Share on other sites More sharing options...
bernhard Posted January 16 Share Posted January 16 To be honest I don't have time to check that on my end. But it sounds like something that could be easily checked with a demo-module on a fresh install of PW and if it's like you said here then I'd ping Ryan about the problem in the issues repository ? I guess there is either a reason or a bug ? Link to comment Share on other sites More sharing options...
MarkE Posted January 16 Author Share Posted January 16 2 hours ago, bernhard said: But it sounds like something that could be easily checked with a demo-module on a fresh install of PW Hmm. I did that but could not reliably replicate the problem. The main check seems to be a js alert "Module requirements are not fulfilled so installing may cause problems. Are you sure you want to install?". This was not always appearing in the set-up that prompted my original post, but it did sometimes and I can't see what caused it to be omitted. Nevertheless, the user can override the alert and install anyway. Often, this is not a problem as the required module can be installed subsequently. However, where the required module is really required for a successful installation (such that reversion to a backup may be necessary if the installation is not complete) then I think it is wise to include the additional check that I described above. This would particularly be the case if, for example, RockMigrations or ProcessDbMigrate was required to install the necessary objects for the module to work. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now