Installed 6.x-1.0-beta1 and my site stopped caching.

I see the .htaccess code is now at /admin/settings/performance and that it is different from before (as you describe in this thread).

I am not clear about the following:
* should I take the .htaccess code relevant to Boost out of my .htaccess ... all of it or just a part?
* how does the code from /admin/settings/performance apply to my .htaccess ... do I need to make that file writeable for Apache?
* more generally, any idea why Boost has stopped working at version 6.x-1.0-beta1 ?

Thanks!

Comments

vacilando’s picture

mikeytown2’s picture

Remove all the boost code from your .htaccess file then copy the generated code over it. Boost does not write to your htaccess file.

Boost stopped working because it won't cache if there are php errors or a drupal message is shown. Run this code in a php block, it should let you know whats causing the error.

if ($error || $drupal_msg != 0) {
  $ttl = boost_file_get_ttl(boost_file_path($GLOBALS['_boost_path']));
  $output = t('There are <strong>php errors</strong> or <strong>drupal messages</strong> on this page, preventing boost from caching.');
  if ($error){
    $output .= t(' ERROR: <pre>%error</pre> !link <br> !performance', array('%error' => print_r($error, TRUE), '!link' => l(t('Lookup Error Type'), 'http://php.net/errorfunc.constants'),'!performance' => l(t('Turn Off Error Checking'),'admin/settings/performance')));
  }
  if ($drupal_msg != 0) {
    $output .= t(' MESSAGES: %msg <br> !performance', array('%msg' => $drupal_msg, '!performance' => l(t('Turn Off Error Checking'),'admin/settings/performance')));
  }
}

The latest dev makes this an option that can be turned off.

vacilando’s picture

Status: Active » Fixed

Great - things work fine again after copying the suggested code from /admin/settings/performance to .htaccess. It was just a question of documentation, it appears. Thanks, this is an amazing module!

vacilando’s picture

Category: bug » support
Status: Fixed » Active

Hi again --

So things worked fine on a standard LAMP install on CentOS 5, but on my sites hosted at Mosso I still cannot get beta1 to work with the new .htaccess.

To explain, also in the previous version of .htaccess (alpha versions), I had to adapt the .htaccess to run at Mosso. Specifically, I had to use absolute path like this:
%{DOCUMENT_ROOT}/cache/
to
/mnt/path-to-my-site/web/content/cache/

Now, in the new code, I've tried without any change, and then with this change, but pages are not being saved (cache folder remains empty).

Maybe in the new .htaccess I have to do other modifications to get it running on Mosso? Any suggestions, things to try?

vacilando’s picture

Version: 6.x-1.0-beta1 » 6.x-1.x-dev
Status: Active » Fixed

Works with the above change also on Mosso when using the latest dev release. Thanks!

mikeytown2’s picture

in regards to #4
try the latest patch out and let me know if it gives you the correct directory.
#428942: AHAH update textarea for .htaccess rules on performance >> boost page.

Status: Fixed » Closed (fixed)

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

capellic’s picture

Thanks for the Mosso tip, I needed it.

vacilando’s picture

Version: 6.x-1.x-dev » 6.x-1.0-beta2
Status: Closed (fixed) » Active

@mikeytown2 re: #6 - tried to use the generated code in beta2 in my .htaccess on Mosso as you asked. Cleared all cache at /admin/settings/performance, then browsed anonymously and refreshed /admin/settings/performance The count of cached pages kept increasing there BUT on the anonymous pages, no matter how many times I cleared browser cache and tried different browsers, I am not getting the footer info in page source about the page being cached! For example this page - when I look at it logged in, the Boost status block tells me it is cached. But when I look at its source (give it a try!) it does not have the footer that would confirm it. (FYI, the setting to not cache on error is off.)

Please advise.. I am now not sure whether pages are served from cache. I leave this for some time for you to check but if not solved I'll get back to the old .htaccess code I know works for me (from beta1 and with #4 fix). Thanks for having a look at this.

capellic’s picture

@vacilando re: #9: A couple of things you can do to narrow the problem down.

1. Confirm that the cached pages are really being created by looking through the sub-directories in the /cache directory. I suspect the pages are there, but checking never hurts.

2. Double check your .htaccess paths. It feels like Drupal isn't picking up the cache files because the paths are invalid. I'm also on Mosso and it wasn't clear to me what my full path was until I looked at the options on the Boost Settings page (admin/settings/performance/boost). Expand the "Boost Apache .htaccess settings generation" field group and then, in your .htaccess file, replace any instances of "%{DOCUMENT_ROOT}" with the Mosso path that is "Document Root" radio list. It should look something like this: /mnt/stor2-wc1-dfw1/3903020/3903020/www.sitename.com/web/content. I then changed any instance of "%{SERVER_NAME}" or "%{HTTP_HOST}" to "sitename.com". Works like a charm.

vacilando’s picture

@capellic -- thanks for your message.

(1) I confirm the cache dir is getting filled with pages.

(2) Well, you are repeating what I said in post #4 above and which you yourself used in #8. :-)
The idea is not to have to do this manual change on Mosso (or other similar) servers. mikeytown2 in #6 suggested a patch which I did not use, but I did use beta 2. In #9 I reported that without changing %{DOCUMENT_ROOT} I seem to be using cached versions (boost block says, and the anonymous pages seem fast) but that there was no confirmation in the source footer.

To this, I am hoping for an answer from mikeytown2. At this moment I am still running the beta 2 generated .htaccess and the footer does not show. Hope mikeytown2 can have a look and ask me for further info if needed. I would like to get this solved rather than give up and live with the need for manual changes.

mikeytown2’s picture

The boost block only checks if the pages cache got generated. It would be hard to make it check to see if apache is serving it as well. If it's not in the footer then your not getting the cached page. Check in different browser to be sure. Changing %{DOCUMENT_ROOT} is there for a reason, some setups might need it in order to work.

What's going on is apache's %{DOCUMENT_ROOT} is different from php's getcwd();. getcwd() holds the correct dir for the static files. So for some reason on Mosso, apache's %{DOCUMENT_ROOT} isn't set right.
http://www.cyberciti.biz/faq/howto-find-unix-linux-apache-documentroot/

I would ask them (Mosso) about this difference between apache and php. Reference this thread.

vacilando’s picture

Title: %{DOCUMENT_ROOT} not set correctly on Mosso hosting. » Boost not working since 6.x-1.0-beta1
Version: 6.x-1.x-dev » 6.x-1.0-beta2
Priority: Normal » Critical
Status: Fixed » Active

All right; did that. See the transcript below. They recommend using %{PHP_DOCUMENT_ROOT}. I confirm that that variable correctly renders the path in Mosso. mikeytown2, is this something you can work into the module expecting it will work on all systems? Or can the module detect being on such a system and use %{PHP_DOCUMENT_ROOT} under some conditions? Hoping for a generic fix.

Tomas Fulopp: OK, working with Drupal community on an issue that is affecting websites installed on Mosso.
Tomas Fulopp: The problem is that a module sets .htaccess rewrite rules that rely on %{DOCUMENT_ROOT}
Tomas Fulopp: On all other known servers tested this variable provides path to the, well, document root.
Tomas Fulopp: In my case it is /mnt/path-to-my-site/web/content/
Tomas Fulopp: But that does not work.
Tomas Fulopp: Another user confirms this finding at http://drupal.org/node/482000#comment-1825828
Miguel S.: yeah, document root won't provide the valid document root path, it's best to use php document root, you can override that though so it always provides the path you need.
Tomas Fulopp: I've spoken with the developer of the module and I would like you to have a careful look at his response at http://drupal.org/node/482000#comment-1839464
Tomas Fulopp: What exactly should we use instead of %{DOCUMENT_ROOT} ?
Miguel S.: one minute.
Tomas Fulopp: Sure, take your time. Note we need a solution for .htaccess - PHP does not come into play in that case.
Miguel S.: i know, i just want to confirm it.
Tomas Fulopp: Thx.
Miguel S.: it should be: %{PHP_DOCUMENT_ROOT }
Miguel S.: If you take a look at the data from a phpinfo(); you'll see that DOCUMENT_ROOT points to /var/www/html where as PHP_DOCUMENT_ROOT will point to the correct server address.
Tomas Fulopp: All right, we'll try that. Thanks a lot.
Miguel S.: You're welcome.

mikeytown2’s picture

%{PHP_DOCUMENT_ROOT} is not part of the apache reserved variables, which means it is a server specific thing that was done using the SetEnv Directive. In short I will add it as an option to the .htaccess generating function but I can not use that instead of %{DOCUMENT_ROOT}.

vacilando’s picture

OK, great; looking forward!

In order for me to understand: do you plan to add some kind of checkbox saying "generate .htaccess paths using php_document_root instead of document_root" or suchlike? Or are you able to detect the correct one for the given system?

mikeytown2’s picture

Priority: Critical » Normal
Status: Active » Needs review
StatusFileSize
new1.87 KB

I can detect it, here's the patch

vacilando’s picture

Priority: Normal » Critical
Status: Needs review » Active

Well.. not out of the woods yet.

I tried replacing %{DOCUMENT_ROOT} by %{PHP_DOCUMENT_ROOT} in the generated .htaccess, but despite running cron, flushing the tested page, trying different browsers with flushed caches, the boost footer did not appear in the source!

When I look at phpinfo() there is a section headed "Apache Environment" and one of the lines indeed is:
PHP_DOCUMENT_ROOT /mnt/path-to-my-site/web/content
(btw, there is also: REDIRECT_PHP_DOCUMENT_ROOT /mnt/path-to-my-site/web/content)

Which is the correct path.

Then I went in and replaced %{PHP_DOCUMENT_ROOT} in the .htaccess by that /mnt/path-to-my-site/web/content. Flushed and... the footer appeared in page source!

Any idea why is this... seems like the variable is set but it cannot be invoked by %{PHP_DOCUMENT_ROOT}? How then?

mikeytown2’s picture

Priority: Critical » Normal
Status: Active » Needs review
StatusFileSize
new3.25 KB

forgot to say that this patch is for the latest dev. Made this compatible on windows now and slightly smarter.

mikeytown2’s picture

@vacilando
Try %{REDIRECT_PHP_DOCUMENT_ROOT}

in the mean time you gave me an idea. search the $_SERVER array for any matches to getcwd().

mikeytown2’s picture

Also try
%{ENV:PHP_DOCUMENT_ROOT}
%{ENV:REDIRECT_PHP_DOCUMENT_ROOT}

vacilando’s picture

Re #19. Did that. No match for 'getcwd' :-(

Interestingly, FYI, in that array there are three mentions of that full path of mine (/mnt/path-to-my-site/web/content), namely in:
["REDIRECT_PHP_DOCUMENT_ROOT"]
["PHP_DOCUMENT_ROOT"]
but also
["DOCUMENT_ROOT"]

mikeytown2’s picture

whats the diff between ["PHP_DOCUMENT_ROOT"] and getcwd() on your server?

vacilando’s picture

mikeytown2! It works!

#20 did it -- I used %{ENV:PHP_DOCUMENT_ROOT}, then actually deleted the cache dir and created a new one, flushed Boost cache in Performance, flushed browser caches... one try, no footer (normal), reload, and the footer is there, consistently, on any page I try!

Do you think you could roll this into the dev version so that I can try it that way?

It would be good if capellic could try it as well, but I am pretty sure it's a solution.

vacilando’s picture

@mikeytown2 re #22 ... in case you still need to know that for some reason: there is no difference, they are precisely the same (slashes and all).

mikeytown2’s picture

Title: Boost not working since 6.x-1.0-beta1 » %{DOCUMENT_ROOT} not set correctly on Mosso hosting.
Version: 6.x-1.0-beta2 » 6.x-1.x-dev
StatusFileSize
new4.56 KB

Here is a generalized solution, please test on your server and let me know if it works.

mikeytown2’s picture

StatusFileSize
new4.47 KB

Fixed an issue with the recommendation in the description.

vacilando’s picture

Status: Needs review » Needs work

We're very close but not there yet...

The generated .htaccess is headed by:

Document Root:
* %{DOCUMENT_ROOT}
  /mnt/path-to-my-site/web/content
Value of %{DOCUMENT_ROOT} is recommened for this server.

So the path to my web directory is correct, but the problem is that it is not automatically selected (and the recommendation is incorrect), so the .htaccess code still uses %{DOCUMENT_ROOT}. (Could this be because this is not a new install? I did however run update.php after installing the dev. Or what can be the problem?)

Let me know how can I help.

(Edit: Note that if I set the second option, apply, and then use the resulting .htaccess code, Boost works OK on Mosso!)

mikeytown2’s picture

The above patch is supposed to search the $_SERVER array for any kind of matches to getcwd(). It appears to not be working in your case... it should output %{ENV:PHP_DOCUMENT_ROOT} if I made some correct assumptions.

Would you mind giving me the output of this?

/**
 * Returns all key/values in array that match.
 *
 * @param $needle
 *  What your searching for
 * @param $haystack
 *  Array of values
 * @param $a_not
 *  Optional array of key names to exclude
 */
function boost_array_find($needle, $haystack, $a_not = array()) {
  $out = array();
  foreach($haystack as $key=>$value) {
    if (strpos($value, $needle) !== FALSE) {
      $good = TRUE;
      foreach($a_not as $not) {
        if (strpos($key, $not) !== FALSE) {
          $good = FALSE;
        }
      }
      if ($good) {
        $out[$key] = $value;
      }
    }
  }
  return $out;
}

  // Set DOCUMENT_ROOT
  $drupal_subdir = rtrim($base_path, '/');
  $document_root = str_replace("\\", '/', getcwd()); // remove windows
  $document_root = str_replace($drupal_subdir, '', $document_root); // remove subdir
  $options = array('%{DOCUMENT_ROOT}' => '%{DOCUMENT_ROOT}', $document_root => $document_root); // initial options
  $rejects = array(); // values to ignore
  $output = boost_array_find($document_root, $_SERVER, $rejects); //search for values that match getcwd
  if (!empty($output)) {
    foreach ($output as $key=>$value) {
      $temp = '%{ENV:' . $key . '}';
      $options[$temp] = $temp; // adding values to options
      if ($value == $document_root) {
        $best = $temp; // set best since it's a match
      }
    }
  }
  if ($_SERVER['DOCUMENT_ROOT'] == $document_root) {
    $best = '%{DOCUMENT_ROOT}';
  }
  $description = t("Value of $best is recommened for this server.");
  if (!isset($best)) {
    $best = $document_root;
    $description .= t(' Please open an boost issue on drupal.org, since apache and php are not configured correctly.');
  }
  echo boost_print_r($options, TRUE);
  echo $description;
vacilando’s picture

See #24... There was no match for 'getcwd' in the $_SERVER array.

Your code returns ( precise path censored, as always :-) the following:

Array
      [%{DOCUMENT_ROOT}] => %{DOCUMENT_ROOT}
      [/mnt/path-to-my-site/web/content] => /mnt/path-to-my-site/web/content
      [%{ENV:REDIRECT_PHP_DOCUMENT_ROOT}] => %{ENV:REDIRECT_PHP_DOCUMENT_ROOT}
      [%{ENV:PHP_DOCUMENT_ROOT}] => %{ENV:PHP_DOCUMENT_ROOT}
      [%{ENV:SCRIPT_FILENAME}] => %{ENV:SCRIPT_FILENAME}
      [%{ENV:DOCUMENT_ROOT}] => %{ENV:DOCUMENT_ROOT}
Value of %{DOCUMENT_ROOT} is recommened for this server.
mikeytown2’s picture

try this for kicks...

/**
 * Returns all key/values in array that match.
 *
 * @param $needle
 *  What your searching for
 * @param $haystack
 *  Array of values
 * @param $a_not
 *  Optional array of key names to exclude
 */
function boost_array_find($needle, $haystack, $a_not = array()) {
  $out = array();
  foreach($haystack as $key=>$value) {
    if (strpos($value, $needle) !== FALSE) {
      $good = TRUE;
      foreach($a_not as $not) {
        if (strpos($key, $not) !== FALSE) {
          $good = FALSE;
        }
      }
      if ($good) {
        $out[$key] = $value;
      }
    }
  }
  return $out;
}
Global $base_path;
  // Set DOCUMENT_ROOT
  $drupal_subdir = rtrim($base_path, '/');
  $document_root = str_replace("\\", '/', getcwd()); // remove windows
  $document_root = str_replace($drupal_subdir, '', $document_root); // remove subdir
  $options = array('%{DOCUMENT_ROOT}' => '%{DOCUMENT_ROOT}', $document_root => $document_root); // initial options
  $rejects = array(); // values to ignore
  $output = boost_array_find($document_root, $_SERVER, $rejects); //search for values that match getcwd
  if (!empty($output)) {
    foreach ($output as $key=>$value) {
      $temp = '%{ENV:' . $key . '}';
      $options[$temp] = $value; // adding values to options
      if ($value == $document_root) {
        $best = $temp; // set best since it's a match
      }
    }
  }
  if ($_SERVER['DOCUMENT_ROOT'] == $document_root) {
    $best = '%{DOCUMENT_ROOT}';
  }
  if (!isset($best)) {
    $best = $document_root;
    $description = t("Value of $best is recommened for this server.");
    $description .= t(' Please open an boost issue on drupal.org, since apache and php are not configured correctly.');
  }
  else {
    $description = t("Value of $best is recommened for this server.");
  }
  echo boost_print_r($options, TRUE, TRUE) . '<br />';
  echo $description . '<br />';
  echo $document_root . '<br />';
  echo getcwd() . '<br />';
vacilando’s picture

boost_print_r was producing array, so I changed it to var_dump($options) etc.

array(6) {
  ["%{DOCUMENT_ROOT}"]=>
  string(16) "%{DOCUMENT_ROOT}"
  ["/mnt/path-to-my-site/web/content"]=>
  string(56) "/mnt/path-to-my-site/web/content"
  ["%{ENV:REDIRECT_PHP_DOCUMENT_ROOT}"]=>
  string(56) "/mnt/path-to-my-site/web/content"
  ["%{ENV:PHP_DOCUMENT_ROOT}"]=>
  string(56) "/mnt/path-to-my-site/web/content"
  ["%{ENV:SCRIPT_FILENAME}"]=>
  string(66) "/mnt/path-to-my-site/web/content/index.php"
  ["%{ENV:DOCUMENT_ROOT}"]=>
  string(56) "/mnt/path-to-my-site/web/content"
}
<br />Value of %{DOCUMENT_ROOT} is recommened for this server.<br />/mnt/path-to-my-site/web/content<br />/mnt/path-to-my-site/web/content<br />
mikeytown2’s picture

The reason why it's not giving the correct recommendation is the fact that according to PHP's point of view DOCUMENT_ROOT is set correctly. Do you get %{ENV:PHP_DOCUMENT_ROOT} as an option with the patch?

vacilando’s picture

No, I get only %{DOCUMENT_ROOT} and the correct path, but not %{ENV:PHP_DOCUMENT_ROOT} as an option (see #27).

:-{

mikeytown2’s picture

Status: Needs work » Needs review
StatusFileSize
new4.52 KB

Try this patch. It's nothing new for the most part, as I can't think of a good generalized solution to your problem since DOCUMENT_ROOT in apache is different then it is in PHP. More options should show up.

mikeytown2’s picture

Status: Needs review » Fixed

committed

vacilando’s picture

Title: Boost not working since 6.x-1.0-beta1 » %{DOCUMENT_ROOT} not set correctly on Mosso hosting.
Version: 6.x-1.0-beta2 » 6.x-1.x-dev
Category: support » bug

I wanted to report on this, so I uninstalled Boost completely, then installed the newest dev.

Got a wholly new problem: these two error messages after enabling the module:

* user warning: Key column 'mime_type' doesn't exist in table query: CREATE TABLE boost_cache ( `filename` VARCHAR(255) NOT NULL DEFAULT '', `base_dir` VARCHAR(128) NOT NULL DEFAULT '', `expire` INT unsigned NOT NULL DEFAULT 0, `lifetime` INT NOT NULL DEFAULT -1, `push` SMALLINT NOT NULL DEFAULT -1, `page_callback` VARCHAR(255) NOT NULL DEFAULT '', `page_arguments` VARCHAR(255) NOT NULL DEFAULT '', `page_id` INT unsigned NOT NULL DEFAULT 0, `extension` VARCHAR(8) NOT NULL DEFAULT '', `timer` INT unsigned NOT NULL DEFAULT 0, `timer_average` FLOAT NOT NULL DEFAULT 0, PRIMARY KEY (filename), INDEX expire (expire), INDEX push (push), INDEX base_dir (base_dir), INDEX page_id (page_id), INDEX timer (timer), INDEX timer_average (timer_average), INDEX page_callback (page_callback), INDEX page_arguments (page_arguments), INDEX mime_type (mime_type) ) /*!40100 DEFAULT CHARACTER SET UTF8 */ in /mnt/path-to-my-site/web/content/includes/database.inc on line 517.
* user warning: Key column 'mime_type' doesn't exist in table query: CREATE TABLE boost_cache_settings ( `csid` INT unsigned NOT NULL auto_increment, `base_dir` VARCHAR(128) NOT NULL DEFAULT '', `page_callback` VARCHAR(255) NOT NULL DEFAULT '', `page_arguments` VARCHAR(255) NOT NULL DEFAULT '0', `page_id` INT unsigned NOT NULL DEFAULT 0, `extension` VARCHAR(8) NOT NULL DEFAULT '', `lifetime` INT NOT NULL DEFAULT -1, `push` SMALLINT NOT NULL DEFAULT -1, PRIMARY KEY (csid), INDEX page_callback (page_callback), INDEX page_arguments (page_arguments), INDEX base_dir (base_dir), INDEX page_id (page_id), INDEX mime_type (mime_type) ) /*!40100 DEFAULT CHARACTER SET UTF8 */ in /mnt/path-to-my-site/web/content/includes/database.inc on line 517.

Then I went to the performance settings, and got another warning:
user warning: Table 'mydatabase.boost_cache' doesn't exist query: SELECT COUNT(*) FROM boost_cache in /mnt/path-to-my-site/web/content/sites/all/modules/boost/boost.admin.inc on line 534.
Did run update.php - no improvement.

Eventually went back to beta2 and ran update.php, which finally installed the missing tables.

FYI: as for the document root settings, there still are the two items:

%{DOCUMENT_ROOT}
/mnt/path-to-my-site/web/content

of which the second is my correct path, but it is NOT selected.

So - I think the Mosso issue is now satisfactory (even though not automatic), but the db install problems in dev are grave and do need attention (therefore marking this as a critical bug).

mikeytown2’s picture

Status: Active » Needs review
StatusFileSize
new2 KB

It was a bone-head move by me. I originally named the column mime_type but then I changed it to extension. Forgot to change the database index. Here's the patch that fixes that as well as some minor things in the install file. Thanks for reporting this!

mikeytown2’s picture

Status: Needs review » Fixed

committed above patch. Fix should be in Aug 1st dev.

vacilando’s picture

OK, went again through the whole disable > uninstall > enable > configure procedure -- the problem described in #36 is fixed, excellent, yay!

mikeytown2’s picture

@vacilando
Thanks for confirming this is fixed

Status: Fixed » Closed (fixed)
Issue tags: -boost, -.htaccess, -Apache

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