Skip to main content

Behaviour of glob function in php is different with open_basedir



I migrate from sugar 5.2 to sugar crm 6.2 and i'm using open_basedir and it doesn't work ...





I detected the problem in the code. It's the function glob which returns false (with open_basedir) instead of an blank array (with open basedir disactivated)





The file with the problem is modules/ModuleBuilder/parsers/views/History.php line 72.







foreach (glob($this->getFileByTimestamp('*')) as $filename)

{

if(preg_match('/(\d+)$/', $filename, $match)) {

$this->_list [] = $match[1];

}

}







(if glob return null, there is an error)





When I look for the documentation of glob http://fr2.php.net/glob , there is a flag *GLOB_ERR* : Stop on read errors (like unreadable directories), by default errors are ignored.





But it doesn't change, the result is false and I've no error.





The configuration of open base dir allow the application path, /tmp and /usr/share





Does someone know how to resolve that problem without modify the code (or how to add an upgrade safe code)





Edit





The path looked by the glob function is located within the path of the open basedir, it's in the sugarcrm directory. The glob function only return false when there is no matching file (behaviour without open base dir for the same case : blank array). When there are files in both case it will return a populated array.


Comments

  1. Read about this bug https://bugs.php.net/bug.php?id=47358

    Possible solution is

    $temp = glob($this->getFileByTimestamp('*'));
    if (is_array($temp))
    foreach ($temp as $filename)
    {
    if(preg_match('/(\d+)$/', $filename, $match)) {
    $this->_list [] = $match[1];
    }
    }

    ReplyDelete

Post a Comment

Popular posts from this blog

Why is this Javascript much *slower* than its jQuery equivalent?

I have a HTML list of about 500 items and a "filter" box above it. I started by using jQuery to filter the list when I typed a letter (timing code added later): $('#filter').keyup( function() { var jqStart = (new Date).getTime(); var search = $(this).val().toLowerCase(); var $list = $('ul.ablist > li'); $list.each( function() { if ( $(this).text().toLowerCase().indexOf(search) === -1 ) $(this).hide(); else $(this).show(); } ); console.log('Time: ' + ((new Date).getTime() - jqStart)); } ); However, there was a couple of seconds delay after typing each letter (particularly the first letter). So I thought it may be slightly quicker if I used plain Javascript (I read recently that jQuery's each function is particularly slow). Here's my JS equivalent: document.getElementById('filter').addEventListener( 'keyup', function () { var jsStart = (new Date).getTime()...

Is it possible to have IF statement in an Echo statement in PHP

Thanks in advance. I did look at the other questions/answers that were similar and didn't find exactly what I was looking for. I'm trying to do this, am I on the right path? echo " <div id='tabs-".$match."'> <textarea id='".$match."' name='".$match."'>". if ($COLUMN_NAME === $match) { echo $FIELD_WITH_COLUMN_NAME; } else { } ."</textarea> <script type='text/javascript'> CKEDITOR.replace( '".$match."' ); </script> </div>"; I am getting the following error message in the browser: Parse error: syntax error, unexpected T_IF Please let me know if this is the right way to go about nesting an IF statement inside an echo. Thank you.