Download & Extend

Boost hook_nodeapi() silently fails in some update cases

Project:Boost
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

I haven't tracked down the details yet but I've been working on a site where on updating a node in some cases the node's cck fields are empty when saving a new revision. By implementing debugging in the hook_nodeapi call what we see is that on the case where the $op is update boost_nodeapi() is called but never returns. More debugging to do but filing this in case others are seeing it and can comment on what they've seen.

Comments

#1

here's the code

<?php
/**
* Implementation of hook_nodeapi(). Acts on nodes defined by other modules.
*/
function boost_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
  if (!
BOOST_ENABLED) return;
 
$data[] = array('page_callback' => 'node', 'page_id' => $node->nid);
 
boost_set_base_dir_in_array($data);

  switch (
$op) {
    case
'insert':
      if (
BOOST_FLUSH_VIEWS_INSERT && module_exists('views')) {
       
$GLOBALS['_boost_nid'] = $node->nid;
       
// Can not reliability call require_once inside a shutdown function; see drupal.org/node/652508
       
views_include('view');
       
views_include('query');
       
register_shutdown_function('_boost_view_insert');
      }
     
boost_expire_node($node);
      break;
    case
'update':
     
boost_expire_node($node);
      if (!
$node->status) {
       
boost_cache_expire_router($data, TRUE, TRUE);
      }
      break;
    case
'delete':
     
boost_expire_node($node);
     
boost_cache_expire_router($data, TRUE, TRUE);
      break;
    case
'presave':
     
// Logic taken from path_redirect_node_presave()
     
if (!empty($node->path)) {
       
$node_path = 'node/'. $node->nid;
       
$old_alias = drupal_get_path_alias($node_path, ($node->language ? $node->language : ''));
        if (
$old_alias != $node_path && $node->path != $old_alias) {
         
// If the user is manually changing the path alias, nuke the old files
         
boost_cache_expire_router($data, TRUE, TRUE);
        }
      }
      break;
  }
}
?>

I would have guessed 'insert' was causing the issue if you had flush views on node insert; since that loads up some views code and could have pushed PHP over the memory limit. Turn boost's verbose setting to 9 as that will allow you to trace the stack. Long story short this sounds like an out of memory error in PHP, try upping the memory limit, hopefully that takes care of this issue your having.

#2

Priority:critical» normal
Status:active» postponed (maintainer needs more info)

I think this may be a local environment interaction sort of thing though it should return an actionable error.

Attached is a section of the debugging log.

There is no PHP out of memory error thrown in this case. What I suspect is there may be a case where there is a database entry for the page but no file exists on disk to be purged. Still investigating that possibility and where it's dying. However, by commenting out the 'update' case of boost_nodeapi() the problem goes away (though obviously if there is a file present it is not removed from the boost cache.

AttachmentSize
20091214-1mp12h8n2mmfy3inkb8kh232et.png 168.81 KB

#3

do you get anything written to the watchdog when you set boost verbose at 9; in regards to the update function? PHP shouldn't be error-ing out if Boost tries to delete a file that doesn't exist.

<?php
/**
* Deletes cached page from file system.
*
* @param array $files
*  An array of files. Each file is a secondary array must have a key for 'filename'
*  Optional keys for 'hash' and 'base_dir' that will be recalculated if necessary.
*  The hash is the primary key in the database. If omitted it will be recalculated from the filename.
* @param boolean $force_flush = FALSE
*  Override BOOST_EXPIRE_NO_FLUSH setting.
*/
function boost_cache_kill($files, $force_flush = FALSE) {
 
$hashes = array();
 
$count = 0;

  if (!
$files) {
    return
FALSE;
  }

 
// If not ignoring file removal
  // AND site is multisite and cache path matches filename
  //  OR full base url matches filename
 
if (variable_get('boost_ignore_flush', 0) < 3) {
   
// Calc md5 hash and set base dir
   
foreach ($files as $key => $file) {
      if (!
is_string($file['filename'])) {
        if (
BOOST_VERBOSE >= 5) {
         
watchdog('boost', 'Error in boost_cache_kill() <br />String was not given for filename: !output', array('!output' => boost_print_r($file, TRUE, TRUE)));
        }
        continue;
      }
      if (empty(
$file['hash'])) {
       
$files[$key]['hash'] = md5($file['filename']);
      }
      if (empty(
$file['base_dir'])) {
       
$files[$key]['base_dir'] = BOOST_FILE_PATH;
      }
     
$hashes[] = $files[$key]['hash'];
      if (
stristr($files[$key]['filename'], BOOST_ROOT_CACHE_DIR) == FALSE) {
        unset(
$files[$key]);
      }
    }
   
// Expire entries from Database
   
if (count($hashes)) {
      if (
$force_flush || !BOOST_EXPIRE_NO_FLUSH) {
       
boost_db_update_set_multi('boost_cache', 'expire', '%d', 0, 'hash', "'%s'", $hashes);
      }
      else {
       
boost_db_update_set_multi('boost_cache', 'expire', '%d', 434966400, 'hash', "'%s'", $hashes);
       
$count = db_affected_rows();
      }
    }
   
// Kill Files from filesystem
   
if ($force_flush || !BOOST_EXPIRE_NO_FLUSH) {
      foreach (
$files as $file) {
       
$filenames = boost_get_all_filenames($file['filename'], $file['base_dir']);
        foreach (
$filenames as $key => $values) {
          foreach (
$values as $num => $filename) {
            if (
file_exists($filename)) {
              @
unlink($filename);
              if (
$key == 'normal' && $num == 0) {
               
$count++;
              }
            }
          }
        }
      }
    }
  }
  return
$count;
}
?>

#4

Version:6.x-1.17» 6.x-1.x-dev
Status:postponed (maintainer needs more info)» needs review

Put this patch in, and set verbose setting to level 9. Let me know what happens when you update a node.

AttachmentSize
boost-658942.patch 997 bytes

#5

@jbrauer
is this bug a false report?

#6

Status:needs review» postponed (maintainer needs more info)

This environment migrated away from using Boost so I don't have more information on this at this time. Marking at postponed needs more info but it would be reasonable to close/won't fix etc. it.

#7

Status:postponed (maintainer needs more info)» fixed

I believe this was fixed; had to do with this line at the top

<?php
  $data
[] = array('page_callback' => 'node', 'page_id' => $node->nid);
 
boost_set_base_dir_in_array($data);
?>

If $node->nid doesn't exist then it would throw an error.

#8

Status:fixed» closed (fixed)

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

nobody click here