DrupalCommand cache-clear needs a higher bootstrap level to runI created a new VMWare appliance for the project that I am working on. I deployed the project and created the DB and all that and when I was trying to access the site, it told me the site was offline. I decided to install DRUSH and clear the cache and see if I can find more information about this problem. Once I installed drush, I got this error: [roychri@p1695vm drupal]$ drush cc Command cache-clear needs a higher bootstrap level to run - you will need invoke drush from a more functional[error] Drupal environment to run this command.
Using Drush without json_decode/json_encode enabled.Did you know that drush requires json support to be enabled in php? Well, I did not until today. Fatal error: Call to undefined function json_encode() in /home/drush/includes/output.inc on line 380 Drush command terminated abnormally due to an unrecoverable error. Error: Call to undefined function json_encode() in /home/drush/includes/output.inc, line 380 If you have root or if your in good terms with your sysadmin, the good solution would be to enable json to your php. Either recompile php or install json using pecl or using your distribution's package manager (yum, rpm, apt, whatever). Well, I did not have root on that machine so here is what I did. <?php if ( !function_exists('json_decode') ){ function json_decode($content, $assoc=false){ require_once 'Services/JSON.php'; if ( $assoc ){ $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE); } else { $json = new Services_JSON; } return $json->decode($content); } } if ( !function_exists('json_encode') ){ function json_encode($content){ require_once 'Services/JSON.php'; $json = new Services_JSON; return $json->encode($content); } } Then I created a /.drush/ folder in my home directory and I created a file called php.ini inside that folder. mkdir ~/.drush emacs ~/.drush/php.ini You can use vi if your one of those :) I put the following inside the file: auto_prepend_file="/path/to/json.php" where /path/to/ is the real path of where I put the json.php file above. That was all and now I could use drush!
Drupal in AfricaI recently had the pleasure and honour to help rebuild the BDA foundation’s website using Drupal. Drupal Camp Montreal 2009 overWhat a Drupal Camp! That was a lot of fun. Here are the camp's photos: Enjoy! (Special Thanks to Omar for inspiration on a successful camp!)
Redirection in Drupal's _submit() functions.I am working on a website which uses the contrib module "mysite". The client wants me to modify the landing page after you change some config. The right way of doing that would be to use hook_form_alter() and change the redirect value: $form['#redirect'] = 'newpath'; However, this was not working for me. I found out this was because the author of the module mysite was using drupal_goto() inside the _submit functions. This is not the recommended way of specifying where you want the page to go to after your form was submitted. You have to return the path.
drupal_goto() does not take query string the way I expected.A friend of mine contacted me about a problem he was having on his site. He was doing a lot of tests with login/logout and he had the login_security module enabled. This little module will ban users automatically if they enter the wrong password too many times. My friend was getting redirected to a page not found when trying to login and he did not understand why. I looked into it and it took me some time to figure out that the problem was with the way drupal_goto() was being called.
drupal_eval() does not allow you to access context variable. but...I am currently working on a project which uses the module site_user_list and I wanted to use some variables in my template. The documentation of the module said I could use the variables from the $r array but I discovered that was not working. I found someone discovered the same problem and opened an issue: That same person also contributed a patch but I was unhappy with it. I provided my own. If you want to use drupal_eval() and allow the code inside that to access (read-only) some of your context variables, try this: Let's assume you want to eval the PHP code found in the variable $code. You might consider doing like this: $options = array('foo' => 'bar'); drupal_eval('<?php ' . $code . '?>'); This would mean that whatever PHP code found in $code would have no access to $options. This is why I recommend this: $options = array('foo' => 'bar'); drupal_eval('<?php $options = '. var_export($options, TRUE).'; ' . $code . '?>'); The var_export() function (php core) will create valid PHP code from your array. You assign that to another variable (could be called anything) and voila. This code will be executed and the values from your $options array becomes accessible (read-only) to your $code. New Assertion: Check for test being found only onceI created a new patch for Drupal 7 simpletest so that we can verify that a piece of text is present on a page, but only present once and no more. Full details can be found here:
Passing a function to another function?Recently I wrote an article about how I handled semaphores in a Drupal project. I want to talk about how I actually implemented it. I needed more than one function to use the semaphore. The goal was to prevent one function to be called when the semaphore was active. The semaphore would get activated when the function would run. Basically, prevent the functions from running at the same time.
Semaphore or Automatic cleaner - built-in PHPI built a system that migrate all sort of data from one legacy system to a new database. It has to be run every 15 minutes and must start with data from today and work it's way back to the oldest data. It takes some time to migrate that much data so it does one day per 15 minutes. |
SearchDrupal ContributionsMake a Payment to Christian Roy |