Skip to content

Instantly share code, notes, and snippets.

@alcaeus
Last active October 11, 2016 11:23
Show Gist options
  • Save alcaeus/a367e895e6c55f7fb93870dcba46efa9 to your computer and use it in GitHub Desktop.
Save alcaeus/a367e895e6c55f7fb93870dcba46efa9 to your computer and use it in GitHub Desktop.
Docker file rename problem demonstration

This attempts to reproduce the problems laid out in doctrine/mongodb-odm#1495 and symfony/symfony#12533.

To run this you'll need a working docker setup. Run the following commands to clone this gist and run the docker image:

git clone git@gist.github.com:a367e895e6c55f7fb93870dcba46efa9.git php-rename-failure
cd php-rename-failure
docker build -t php-rename-failure .
docker run -it --rm php-rename-failure
FROM php:7.0-cli
COPY . /usr/src
WORKDIR /usr/src
RUN mkdir -p existing-dir
RUN touch existing-dir/test
RUN cp -r existing-dir existing-dir-2
CMD [ "php", "./rename.php" ]
<?php declare(strict_types = 1);
echo "Trying directory rename\n";
var_dump(rename('existing-dir', 'existing-dir-renamed'));
echo "Trying file rename in directory\n";
var_dump(rename('existing-dir-2/test', 'existing-dir-2/test.bak'));
echo "Trying directory rename\n";
var_dump(rename('existing-dir-2', 'existing-dir-renamed-2'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment