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

Check whether the chmod call is needed before calling it #68

Closed
Amunak opened this issue Aug 14, 2018 · 1 comment
Closed

Check whether the chmod call is needed before calling it #68

Amunak opened this issue Aug 14, 2018 · 1 comment
Assignees

Comments

@Amunak
Copy link

Amunak commented Aug 14, 2018

So (as per #47) I get that you want to make the install "crash hard" when the chmod() call fails, but at least make sure that you call it only when necessary.

In the vast majority of cases the permissions are already correct but your script is crashing the whole composer install just because a different developer (user) ran it than the one who ran it the first time. When this happens on a production system while you desperately need to run all your install scripts, it's really annoying and kind of unacceptable.

You can use something akin to this:

--- /dev/null
+++ ocramius/package-versions/src/PackageVersions/Installer.php
@@ -119,7 +119,9 @@
         $io->write('<info>ocramius/package-versions:</info>  Generating version class...');
 
         file_put_contents($installPath, $versionClassSource);
-        chmod($installPath, 0664);
+        if (decoct(fileperms($installPath) & 0777) !== '664') {
+            chmod($installPath, 0664);
+        }
 
         $io->write('<info>ocramius/package-versions:</info> ...done generating version class');
     }
@Amunak Amunak changed the title Check whether the chmod() call is needed Check whether the chmod() call is needed before calling it Aug 14, 2018
@Amunak Amunak changed the title Check whether the chmod() call is needed before calling it Check whether the chmod call is needed before calling it Aug 14, 2018
@Ocramius
Copy link
Owner

In the vast majority of cases the permissions are already correct but your script is crashing the whole composer install just because a different developer (user) ran it than the one who ran it the first time.

This is correct.

When this happens on a production system while you desperately need to run all your install scripts, it's really annoying and kind of unacceptable.

That means that you have no proper deployment process:

  1. no deployment "owner" (user that owns the deployment dir, if any)
  2. deployment process has no rollback system

As I described in #47, I can gladly fix problems when a failing automated test case is provided.

Closing as duplicate: please re-open once a test case is available.

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

No branches or pull requests

2 participants