occ command can only be called from ownCloud root directory #21251

Merged
merged 1 commit into from Dec 17, 2015

Projects

None yet

5 participants

@MorrisJobke
Member
  • this changes into the ownCloud root directory and then should run just fine
  • avoids weird error messages that are caused by this

cc @dragotin @DeepDiver1975 @LukasReschke

@carlaschroder With this change merge the occ tool can be called from everywhere without errors:

$ /var/www/owncloud/occ

This is then possible from every directory on your machine.

@MorrisJobke MorrisJobke added this to the 9.0-current milestone Dec 17, 2015
@mention-bot

By analyzing the blame information on this pull request, we identified @DeepDiver1975, @LukasReschke and @bartv2 to be potential reviewers

@MorrisJobke
Member

This is what it looks before:

$ pwd
.../owncloud/tests
$ ../occ maintenance:install --admin-pass=mjob --admin-user=mjob
ownCloud is not installed - only a limited number of commands are available
creating sqlite db
PHP Fatal error:  Call to a member function children() on boolean in owncloud/lib/private/db/mdb2schemareader.php on line 71
@DeepDiver1975 DeepDiver1975 and 1 other commented on an outdated diff Dec 17, 2015
@@ -64,6 +64,16 @@
}
}
+ $oldWorkingDir = getcwd();
+ if ($oldWorkingDir === false) {
+ echo "This script can be run from the ownCloud root directory only." . PHP_EOL;
+ echo "Can't determine current working dir - the script will continue to work but be aware of the above fact." . PHP_EOL;
+ } else if ($oldWorkingDir !== __DIR__ && !chdir(__DIR__)) {
+ echo "This script can be run from the ownCloud root directory only." . PHP_EOL;
+ echo "Can't change to ownCloud root diretory." . PHP_EOL;
+ exit(0);
@DeepDiver1975
DeepDiver1975 Dec 17, 2015 Member

should not be 0

@MorrisJobke
MorrisJobke Dec 17, 2015 Member

The other ones also exit with 0 ๐Ÿ™ˆ I can do this a 1 if you want

@MorrisJobke
Member

@karlitschek I would backport this because there are quite regular reports about those weird error messages that aren't easy to spot.

@rullzer rullzer commented on an outdated diff Dec 17, 2015
@@ -64,6 +64,16 @@
}
}
+ $oldWorkingDir = getcwd();
+ if ($oldWorkingDir === false) {
+ echo "This script can be run from the ownCloud root directory only." . PHP_EOL;
+ echo "Can't determine current working dir - the script will continue to work but be aware of the above fact." . PHP_EOL;
+ } else if ($oldWorkingDir !== __DIR__ && !chdir(__DIR__)) {
+ echo "This script can be run from the ownCloud root directory only." . PHP_EOL;
+ echo "Can't change to ownCloud root diretory." . PHP_EOL;
+ exit(0);
+ }
+
@rullzer
rullzer Dec 17, 2015 Contributor

shouldn't we chdir back here?

@MorrisJobke MorrisJobke occ command can only be called from ownCloud root directory
* this changes into the ownCloud root directory and then should run just fine
* avoids weird error messages that are caused by this
b8ceae6
@rullzer
Contributor
rullzer commented Dec 17, 2015

We should chdir back at the end.

@MorrisJobke
Member

We should chdir back at the end.

I tested and it has no impact. I guess this is because the php process is a separate process.

@rullzer
Contributor
rullzer commented Dec 17, 2015

Aaah, of course.
Tested, and good to go I think ๐Ÿ‘

@DeepDiver1975
Member

๐Ÿ‘

@DeepDiver1975 DeepDiver1975 merged commit a9ad5c7 into master Dec 17, 2015

20 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
core-ci-linux-jsunit/database=sqlite,label=SLAVE Build #53984 succeeded in 23 sec
Details
core-ci-linux-swift-primary-storage/database=mysql,label=SLAVE Build #45311 succeeded in 5 min 44 sec
Details
core-ci-linux/database=mysql,label=SLAVE Build #18734 succeeded in 6 min 53 sec
Details
core-ci-linux/database=oci,label=SLAVE Build #18734 succeeded in 9 min 59 sec
Details
core-ci-linux/database=pgsql,label=SLAVE Build #18734 succeeded in 7 min 5 sec
Details
core-ci-linux/database=sqlite,label=SLAVE Build #18734 succeeded in 3 min 41 sec
Details
ocs-api-integration-tests-ci Build #4943 succeeded in 1 min 52 sec
Details
server-master-linux-externals-ci/database=sqlite,external=smb-silvershell,label=SLAVE Build #5123 succeeded in 48 sec
Details
server-master-linux-externals-ci/database=sqlite,external=swift-ceph,label=SLAVE Build #5123 succeeded in 1 min 54 sec
Details
server-master-linux-externals-ci/database=sqlite,external=webdav-ownCloud,label=SLAVE Build #5123 succeeded in 2 min 12 sec
Details
server-master-linux-externals-smb-windows-ext-ci/database=sqlite,external=smb-windows,label=master Build #5284 succeeded in 1 min 55 sec
Details
server-master-linux-php7-ci/database=sqlite,label=SLAVE Build #28381 succeeded in 1 min 18 sec
Details
smashbox-on-docker-ci/DOCKER_IMAGE=ubuntu_oc_lamp-git,TEST_NAME=litmus,mirallBranch=v2.0.2,slave=SMASH Build #952 succeeded in 42 min
Details
smashbox-on-docker-ci/DOCKER_IMAGE=ubuntu_oc_lamp-git,TEST_NAME=test_basicSync@0,mirallBranch=v2.0.2,slave=SMASH Build #952 succeeded in 59 min
Details
smashbox-on-docker-ci/DOCKER_IMAGE=ubuntu_oc_lamp-git,TEST_NAME=test_basicSync@1,mirallBranch=v2.0.2,slave=SMASH Build #952 succeeded in 43 min
Details
smashbox-on-docker-ci/DOCKER_IMAGE=ubuntu_oc_lamp-git,TEST_NAME=test_shareLink,mirallBranch=v2.0.2,slave=SMASH Build #952 succeeded in 47 min
Details
smashbox-on-docker-ci/DOCKER_IMAGE=ubuntu_oc_lamp-git,TEST_NAME=test_sharePermissions,mirallBranch=v2.0.2,slave=SMASH Build #952 succeeded in 54 min
Details
smashbox-on-docker-ci/DOCKER_IMAGE=ubuntu_oc_lamp-git,TEST_NAME=test_sharePropagationGroups,mirallBranch=v2.0.2,slave=SMASH Build #952 succeeded in 57 min
Details
smashbox-on-docker-ci/DOCKER_IMAGE=ubuntu_oc_lamp-git,TEST_NAME=test_sharePropagationInsideGroups,mirallBranch=v2.0.2,slave=SMASH Build #952 succeeded in 56 min
Details
@DeepDiver1975 DeepDiver1975 deleted the make-occ-more-error-proof branch Dec 17, 2015
@MorrisJobke
Member

@karlitschek I would backport this because there are quite regular reports about those weird error messages that aren't easy to spot.

@karlitschek Ping

@karlitschek
Member

Backport makes sense. Thanks! ๐Ÿ‘

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