Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tempdir problem #1465

Open
tlcd96 opened this issue Oct 6, 2019 · 8 comments
Open

Tempdir problem #1465

tlcd96 opened this issue Oct 6, 2019 · 8 comments

Comments

@tlcd96
Copy link

tlcd96 commented Oct 6, 2019

temp dir

get temp dir from php function:
sys_get_temp_dir()
or
putenv('TMPDIR='.ini_get('open_basedir').'/tmp')

@borekb
Copy link
Member

borekb commented Oct 6, 2019

@skullwritter, could you please clarify what you mean? Thanks.

@tlcd96
Copy link
Author

tlcd96 commented Oct 6, 2019

yup... the sys_get_temp_dir does not always work so it would be nice to gave something checking for the open_basedir:

/*** if can access the default else this code bellow - display also a warning about it but proceed ***/
$var=ini_get('open_basedir');
$exploded=explode(':',$var);
$newdir='';
foreach($exploded as $e){
    if(strpos('/tmp')!==false){
        /** getting temp dir from open_basedir**/
        $newdir=$e; 
        break;
    }
}
if($newdir!==''){
    /**if we have define this for sys_get_temp_dir() function*/
    putenv('TMPDIR='.newdir);
}else{
    /** display the default error **/
}

@tlcd96
Copy link
Author

tlcd96 commented Oct 6, 2019

@borekb i've updated the comment

@borekb
Copy link
Member

borekb commented Oct 6, 2019

Thanks. It's still not clear to me when this happens or why, could you please link to some resources? Also, if you're suggesting specific code changes in VersionPress, feel free to open a PR where the discussion can happen closer to the source code (there's no guarantee that the PR will be accepted, it might just be easier to discuss around specific code changes).

@tlcd96
Copy link
Author

tlcd96 commented Oct 6, 2019

@borekb it happened after the install of the plugin it was saying that it didn't have readwrite permission on the /tmp, and the open base dir contained it, so, i've had to add the:
putenv('TMPDIR='.$newdir); code to the wp-config for it to work cause my temp dir was something like:
/home/*******/tmp

@borekb
Copy link
Member

borekb commented Oct 8, 2019

Thanks for the additional info. It sounds to me that it's a server configuration issue, not something that should lead to a change in VersionPress itself, would you agree? If so, we could move this to versionpress/support so that other can find this.

@tlcd96
Copy link
Author

tlcd96 commented Oct 9, 2019

in terms of server configuration, i've had seen many users complaining about virtualhosts, that do not contain the specific var TMPDIR defined, or wrongfully defined by host company, so that's why i've opened this issue, to alert to one solution, that may be as harmless as something as a try and a catch like:

function test_enviorment(){
    try{
        $f=fopen("/tmp/testfile.txt");
        fwrite($f,'test');
        fclose($f);
        return true;
    }catch(Exception $exct){
        /** launch the provided thing to check if open_basedir contains a tmp dir **/
        return $what_ever_function_with_some_example_code_provided_in_here;
    }
}

@MaraScott
Copy link

I host my wp on virtualhost and I faced that issue, however, when I have defined putenv('TMPDIR='.VP_TEMP_DIR); where VP_TEMP_DIR is a dir I can write on, it solves my trouble.

I agree with @borekb this issue seems more a configuration issue, however @borekb, to ease the process of configuration what about upgrading vp code to add an option where we can define VP_TEMP_DIR putenv('TMPDIR='.VP_TEMP_DIR); ?

What do you think ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants