*.xml and *.html files could be deleted at document root

lapith - July 1, 2009 - 16:34
Project:Boost
Version:6.x-1.0-beta2
Component:Expiration logic
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

We currently have a .xml file and a couple of static .html files (for apache errors as an example). We had noticed that these files were randomly being deleted from the document root. As a result of some digging I was able to determine that the problem lies with the combination of the glob() call and the boost_file_path function.

    $tempA = glob(boost_file_path($path, FALSE, NULL) . (($wildcard) ? '*' : '') . BOOST_FILE_EXTENSION, GLOB_NOSORT);
    $tempB = glob(boost_file_path($path, FALSE, NULL) . (($wildcard) ? '*' : '') . BOOST_XML_EXTENSION, GLOB_NOSORT);

in some instances the boost_file_path function returns false (especially since the $query param is FALSE). As a temporary solution to this I wrapped these in a conditional:

if(boost_file_path($path, FALSE, NULL) !== FALSE) {
    $tempA = glob(boost_file_path($path, FALSE, NULL) . (($wildcard) ? '*' : '') . BOOST_FILE_EXTENSION, GLOB_NOSORT);
    $tempB = glob(boost_file_path($path, FALSE, NULL) . (($wildcard) ? '*' : '') . BOOST_XML_EXTENSION, GLOB_NOSORT);
  }

This will ensure that there is always a path before the *.[ext]

#1

mikeytown2 - July 1, 2009 - 19:12

wow, talk about an ugly bug. Thanks for tracking this down! Looks like I really should change this glob() to a database LIKE search in the future. Here's my take on your patch; testing would be appreciated.

AttachmentSize
boost-507348.patch 1.68 KB

#2

chrisakeley - July 1, 2009 - 20:41

I tested this version, along with some similar lines based on the original suggestion. It works like a champ with no ill effect on boost functionality. I'm going to install it tonight on weei.com

#3

mikeytown2 - July 1, 2009 - 20:44
Status:needs review» reviewed & tested by the community

#4

mikeytown2 - July 1, 2009 - 20:49
Title:*.xml and *.html files deleted at document root» *.xml and *.html files could be deleted at document root
Priority:critical» normal
Status:reviewed & tested by the community» active

committed the patch, keeping this open so I can add more logic to the actual file deletion function.

#5

mikeytown2 - July 1, 2009 - 20:56
Status:active» needs review

Added another sanity check

AttachmentSize
boost-507348-1.patch 777 bytes

#6

mikeytown2 - July 6, 2009 - 05:49
Status:needs review» fixed

committed 2 days ago
http://drupal.org/cvs?commit=233182

#7

System Message - July 20, 2009 - 05:50
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.