Missing module provides information about modules missing from the filesystem

  • in the /admin/reports/status page
  • and via drush mm

Missing modules can cause huge delays (250ms+) to all page loads due to 100's or 1000's of redundant calls to file_scan_directory()

This is different from other projects as it does not automatically disable modules, it provides reports and gives the drush command to re download any missing modules.

This module is designed for using when switching databases between dev, staging and live.

This is a Drupal 7 project

Page:
missing module sandbox

Git repo
git clone --branch 7.x-1.x p4ul@git.drupal.org:sandbox/p4ul/1947350.git missing_module

Cheers,

Paul

CommentFileSizeAuthor
#6 mm_report.png11.06 KBp4ul
#4 new_report.png9.55 KBp4ul
report.png10.79 KBp4ul

Comments

PA robot’s picture

Status: Needs review » Needs work

There are some errors reported by automated review tools, did you already check them? See http://ventral.org/pareview/httpgitdrupalorgsandboxp4ul1947350git

We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and we will take a look at your project right away :-)

Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).

I'm a robot and this is an automated message from Project Applications Scraper.

p4ul’s picture

Status: Needs work » Needs review

Fixed PAReview issues.

rrrob’s picture

Hi Paul,

Great idea for a module. I've had a need for this in the past. PAReview looked good (http://ventral.org/pareview/httpgitdrupalorgsandboxp4ul1947350git)

A few things that jumped out (see http://drupal.org/node/1587704):

5.3 Ensure the code contains a well-balanced amount of inline-comments. - There were zero inline-comments.

Lines 34-36 of missing_module.install - These should be formatted for better readability.

hook_requirements() - If I'm reading the API documentation correctly, the return value array should have four parts. You are missing the description. I think you should dump all of your $missing_output information into description instead of value. Value can be empty if not applicable.

p4ul’s picture

StatusFileSize
new9.55 KB

Hi rrrob,

Thanks for reviewing it, if I remove value from array I get the following error.

Notice: Undefined index: value in theme_status_report() (line 2572 of /var/www/nzceronline/nzceronline/modules/system/system.admin.inc).

So I have slightly modified it, see attached screenshot.

I have tided up lines 34-36 and added some comments.

Cheers,
Paul

rrrob’s picture

Paul,

Code fixes look better.

When on /admin/reports/status and have a missing module, your message provides a link to the module page to disable the module. This is a good idea, but if a module does not reside in code, it doesn't show up on the module page.

A couple of thoughts. Maybe you could put a disable link directly next to each module path, that when clicked, the database entries will be removed. Also, in addition to having the Drush download code, could you provide a link to the d.o project itself for those who don't use Drush?

p4ul’s picture

StatusFileSize
new11.06 KB

Hi rrrob,

I have added links to the drupal.org projects (based on module name), removed the link to the modules page and added a disable link with a confirmation screen.

See attached screenshot.

Cheers,
Paul

rrrob’s picture

Paul,

Your new changes look and work great. I guess your next step is to either wait until someone with the proper privileges comes along and reviews your project, or perform the steps outlined to get the review bonus.

Good luck!
Rob

veeraprasadd’s picture

Hi p4ul,

First of all i like this module. I installed your module in local system and verified for the same. It looks promising.
----
No issues found in automated review in ventral.org
----

I just noticed some minor things.

Files:
missing_module.module
missing_module.install
missing_module.module

Line 2 & Line 8: Single blank line is enough instead 2 lines.
Line 6: Unwanted '*' character.

Thanks and Regards,
D. Veera Prasad.
www.drup-all.com

drupik’s picture

What is the difference between this http://drupal.org/project/bootstrap_optimizer ?

p4ul’s picture

Thanks veeraprasadd,
I a have implemented your feedback.

Cheers, Paul

p4ul’s picture

Hi drupik,

This is different to http://drupal.org/project/bootstrap_optimizer in the following ways:

  1. Provides the user with information in regards to re downloading the missing modules
  2. Gives users the option of disabling specific modules
  3. Provides information in /admin/reports/status page, no batch process required :)

This module is targeted at people that swap databases between different developers / environments. This module is based on the assumptions that:
1. missing modules are bad for performance,
2. if you database is pointing to a module that does not exist this is unexpected and likely the cause of user error and you probably want to find and download it (even if you don't want it you should download it and uninstall it properly).
3. if you no longer need a module on the current environment and you no you don't need it you can disable it.
4. users want to go to one place (admin/reports/status) to see problems with their system.

Bootstrap optimizer seems to make the assumptions that:
1. If a module is no longer in the file system but it is referenced in the database it is fine to delete it from the system table (this ignores any cruft left in database due to not uninstalling it),
2. people will remember to go to obscure pages to check system performance.

Cheers,
Paul

sam hermans’s picture

Status: Needs review » Needs work

Hey,

I installed and reviewed your module manually and i think it's a pretty neat and usefull idea ... The only thing that i feel is that you should add is some hook to cron or a 'check' button in an admin page, since your only checking during install hook or when 'drush mm' is called, and i think you should try to use system_list('module_enabled') instead of running a db_select to gather the active modules.

p4ul’s picture

Status: Needs work » Needs review

Hi Sam,

The install_hook is actually called every time you visit admin/reports/status (the 'runtime' phase) which is the general place to go to look for problems with your installation.

I have modified the error level from warning to error as per http://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_requirements/7 so the message will show up on the admin configuration page.

In terms of system_list this seems to be a more expensive way of getting the same information? It returns a lot of unneeded information in array structures.

Cheers,
Paul

sam hermans’s picture

Your absolutely right about the runtime, sorry about that.

About the system_list .. not sure what you should do there, using framework functions seems better then a db_select no ? Up to you, and keep up the good work ..

jeffstric’s picture

Hello Paul:
It's a very useful module. But I find a file named:'missing_module.drush.inc', which seems unnecessary, is it a test file? :>

p4ul’s picture

Hi jeffstric,

From what read in the documentation that file is required to run a drush command?

This allows you to run the command `drush mm` after you have updated the site (say from SVN) to see if all the required modules are present.

Cheers,
Paul

jeffstric’s picture

drush mm work fine!

I suggest you optimalize the README.TXT
Like:

-- SUMMARY --

This module lists modules that are activated in your database but missing
from your file system.

These can greatly impact the performance of your drupal 7 site.

For example: 1 missing module lead to 900 file_scan_directory() calls
resulting in a wasted 250ms every page load.

-- Usage --
1 To use either view the site status report
/admin/reports/status
2 from drush run
drush mm

-- Module url --

* http://drupal.org/xxx

-- CONTACT --

Current maintainers:
*** - http://drupal.org/user/***

p4ul’s picture

Thanks jeffstric.
I have updated readme.

pierre_cotiniere’s picture

Hi p4ul,

First i found this module interesting, it could be used for my pre-production site.

Just two suggestions :

  • In the missing_module_disable_confirm_submit() function, you don't need to use arg() function because arguments are still in $form_state.
    So you can replace : $module_name = arg(4); by $view = $form_state['build_info']['args'][0];
  • Actually, you can delete a module present on the filesystem, for example delete a module like system with : admin/reports/status/disable_module/system
    To avoid this action, in the missing_module_disable_confirm() function, you could check if the module is enabled and return an error message in this case.
jeffstric’s picture

Status: Needs review » Needs work

Hi pierre_cotiniere:
I'm not module creator.T_T.

pierre_cotiniere’s picture

Hi jeffstric, fixed.

SamChez’s picture

Very straightforward module, short and sweet. Consider renaming the link to the module pages to something along the lines of "Module Home" just to make sure people understand that it links to the module home page instead of maybe Drupal itself. I'll be recommending this to my colleagues because it deserves more attention then it's getting at the moment. Nice Work!

SamChez’s picture

*Doublepost

p4ul’s picture

Status: Needs work » Needs review

Hi pierre_cotiniere,

Thanks for your input, I have updated the code to use $form_state instead of args().

I am not sure that I needs an extra query to the database to inform the user that the module is already disabled? The end result is the same.

Cheers,
Paul

p4ul’s picture

Hi SamChez,

Thanks for the feedback. I have updated that link text to "link to module on drupal.org".

Cheers,
Paul

pierre_cotiniere’s picture

p4ul,
it's not to inform, it's to block uninstallation if the module exists on the filesystem, to prevent errors.
With your module, i can disable the system module for example.

sreynen’s picture

Title: Missing Module » [D7] Missing Module
Status: Needs review » Needs work

I guess your next step is to either wait until someone with the proper privileges comes along and reviews your project

There are no special privileges required to review projects. Everyone can do it.

I see two blocker issues:

1) The permission for disabling modules is currently "access administration pages" and should be "administer modules". In general, it's very important to use the most specific permission available, so you're not granting any more access than necessary.
2) As #26 said, you're currently disabling modules with no check to confirm they're actually missing code. There's nothing wrong with disabling modules that have code, but that would need to happen differently, with module_disable(), to run the proper hooks in the module. Probably simpler to only allow your module to disable modules with no code rather than write two different processes for disabling modules.

p4ul’s picture

Status: Needs work » Needs review

Thanks pierre_cotiniere & sreynen, I can now see where you are coming from and have made those changes.

Cheers,
Paul

pranit84’s picture

Status: Needs review » Needs work

Manual Review

In .module file at line number 38 add t() function for 'title' => 'Disable Module',
For line 55 to 60, do proper indentation.

p4ul’s picture

Status: Needs work » Needs review

Thanks pranit84, I have made those changes.

izus’s picture

Status: Needs review » Needs work

Hi,
This is a useful module, Thanks !
Here is the result of my review :
- $result = db_select('system')->fields('system', array('filename'))->condition('status', '1', '=')->range(0, 150)->execute();
I think it would be better to not hard code '150' without giving the user the possibility to alter it.
I would suggest to add a config form to set this value and use variable_get() instead of the hard coded value.

- $missing_modules = missing_module_find_missing();
You are doing this twice : in the form and in its submit handler, i would suggest to store the result you get from the form builder in $form_state['missing_module']['modules'] for example, so that you can access it in the submit handler and avoid an extra query/foreach/file_exists ;)

-Extra suggestion : For better performance the .module should only contain necessary code : the form builder and its submit handler are not necessary if we are not in 'admin/reports/status/disable_module/%'' page. i suggest to add a 'file' => 'missing_module.form.inc'to your $items['admin/reports/status/disable_module/%'] array and move the form definition and submit handler to it.

p4ul’s picture

Status: Needs review » Needs work

Hi pranit84,
I have removed the t() function as it is not allowed see ventral code review

p4ul’s picture

Status: Needs work » Needs review

Hi izus,

Thanks for the feedback, the limit of 150 was a bug and I have removed the range method.
I have cached the missing modules in the form_state variable and moved the form functions out to a different file as per your suggestions.

Tests are now passing

izus’s picture

Status: Needs work » Reviewed & tested by the community

Hi,
I reviewed it again and tried it locally, it look good for me.
Thanks

klausi’s picture

Status: Reviewed & tested by the community » Fixed

Sorry for the delay, but you have not listed any reviews of other project applications in your issue summary as strongly recommended in the application documentation.

manual review:

  1. maintainers link on project page is broken
  2. please add the differences to http://drupal.org/project/bootstrap_optimizer to the project page.
  3. "$value = 'No missing modules detected.';": all user facing text must run through t() for translation.
  4. missing_module_find_missing(): Do not use db_select() for simple static queries, use db_query() instead. See http://drupal.org/node/310075
  5. missing_module_disable_confirm_submit(): this should have a comment why you cannot use module_disable().

But that are not blockers, so ...

Thanks for your contribution, p4ul!

I updated your account so you can promote this to a full project and also create new projects as either a sandbox or a "full" project.

Here are some recommended readings to help with excellent maintainership:

You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and stay involved!

Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

Thanks to the dedicated reviewer(s) as well.

p4ul’s picture

Thanks klausi!, and thanks for feedback from all the other reviewers.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.