Skip to content

Permissions issue with PHP rename() function. #8

@JamieWritesCode

Description

@JamieWritesCode

Hi mate, getting an 'Operation not permitted' warning with the use of the PHP rename function in src/DocxMerge/Docx.php on line 131. Running Ubuntu 14.04 with PHP7.

// Replace current file with tempFile content
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
    copy( $tempFile, $this->docxPath );
}
else {
    rename($tempFile, $this->docxPath);
}

I've temporarily fixed it by copying then unlinking rather than using replace, similar to what you've done for Windows. Any reason why we can't just use copy and unlink for both like so?

// Replace current file with tempFile content
if ( copy($tempFile, $this->docxPath) ) {
    unlink($tempFile);
}

Happy to create a PR if necessary. Unless I'm missing some particular reason to use rename?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions