pressflow / 6

Each version of Pressflow is API-compatible with the same major Drupal version. For example, Pressflow 6 is compatible with all Drupal 6 modules. Pressflow 6 also integrates the SimpleTest system from Drupal 7 and the CDN support patch.
http://pressflow.org/
GNU General Public License v2.0
234 stars 89 forks source link

Prevent variable_init from retuning an empty array. #37

Open mikeytown2 opened 12 years ago

mikeytown2 commented 12 years ago

Patch does a couple of things

mmurshed commented 12 years ago

I see only one new line and a bunch of white spaces. :)

mikeytown2 commented 12 years ago

There are 41 additions and 21 deletions; that means we have 20 new lines. About 2/3 of the new lines are comments, but there is a fair share of new code. The new logic that is inserted in 2 different places deals with this chunk of code. Click on the diff button above next to Discussion & Commits to see the diff. Or to see the issue on d.o go here http://drupal.org/node/561990#comment-5803696

  // If the recursion_depth hit the limit, assume we aren't going to get it
  // from the cache or the lock will be released any time soon. Give up and
  // get variables from the database.
  $result = db_query('SELECT * FROM {variable}');
  // Exit here if the database went away. Do not want to pollute the cache
  // with bad data. This request isn't going to end well.
  if ($result === FALSE) {
    // This function calls exit.
    _db_error_page();
  }
  while ($variable = db_fetch_object($result)) {
    $variables[$variable->name] = unserialize($variable->value);
  }
mmurshed commented 12 years ago

Sorry, I did not want to be rude. The white spaces just caught my eyes. I really appreciate the work you do for the Drupal community through many great modules.

mikeytown2 commented 12 years ago

White space fixes are a result of the editor I have (kate) :) It removes trailing white space at the end of a line. http://drupal.org/coding-standards#indenting

dimduj commented 10 years ago

Hello,

Thanks for the patch MickeyTown, it is really usefull on our production server.

I've juste a small question about releasing the lock when we detect a FALSE result.

Shouldn't we do something like that (if false then release lock):

if (defined('MAINTENANCE_MODE') || lock_acquire('variable_cache_regenerate')) {
  $result = db_query('SELECT * FROM {variable}');
  // Exit here if the database went away. Do not want to pollute the cache
  // with bad data. This request isn't going to end well anyway; end it
  // eairly.
  if ($result === FALSE) {
    // This function calls exit.
    lock_release('variable_cache_regenerate');
    _db_error_page();
  }
  while ($variable = db_fetch_object($result)) {
    $variables[$variable->name] = unserialize($variable->value);
  }

  cache_set('variables', $variables);
  if (!defined('MAINTENANCE_MODE')) {
    lock_release('variable_cache_regenerate');
  }
}

Thanks for any advice.

regards,

Dimitri