-
Initializing
@@ -1740,64 +1740,87 @@ public function logVersion() { updateAvailable() || $stepNumber > 0) { $buttonText = 'Start update'; - if($stepNumber > 0) { + if ($stepNumber > 0) { $buttonText = 'Continue update'; - } - ?> + } ?> + ?>
diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index 9c6405d9..00000000 --- a/.drone.yml +++ /dev/null @@ -1,213 +0,0 @@ -kind: pipeline -name: check-same-code-base - -steps: - - name: check-same-code-base - image: ghcr.io/nextcloud/continuous-integration-php8.0:latest - commands: - - make check-same-code-base - -trigger: - branch: - - master - - stable* - event: - - pull_request - - push - ---- -kind: pipeline -name: php73-cli - -steps: - - name: php73-cli - image: ghcr.io/nextcloud/continuous-integration-php7.3:latest - commands: - - make test-cli - -trigger: - branch: - - master - - stable* - event: - - pull_request - - push - ---- -kind: pipeline -name: php74-cli - -steps: - - name: php74-cli - image: ghcr.io/nextcloud/continuous-integration-php7.4:latest - commands: - - make test-cli - -trigger: - branch: - - master - - stable* - event: - - pull_request - - push ---- -kind: pipeline -name: php73-stable19 - -steps: - - name: php73-stable19 - image: ghcr.io/nextcloud/continuous-integration-php7.3:latest - commands: - - make test-stable19 - -trigger: - branch: - - master - - stable* - event: - - pull_request - - push - ---- -kind: pipeline -name: php74-stable19 - -steps: - - name: php74-stable19 - image: ghcr.io/nextcloud/continuous-integration-php7.4:latest - commands: - - make test-stable19 - -trigger: - branch: - - master - - stable* - event: - - pull_request - - push - ---- -kind: pipeline -name: php73-stable20 - -steps: - - name: php73-stable20 - image: ghcr.io/nextcloud/continuous-integration-php7.3:latest - commands: - - make test-stable20 - -trigger: - branch: - - master - - stable* - event: - - pull_request - - push - ---- -kind: pipeline -name: php74-stable20 - -steps: - - name: php74-stable20 - image: ghcr.io/nextcloud/continuous-integration-php7.4:latest - commands: - - make test-stable20 - -trigger: - branch: - - master - - stable* - event: - - pull_request - - push - ---- -kind: pipeline -name: php73-stable21 - -steps: - - name: php73-stable21 - image: ghcr.io/nextcloud/continuous-integration-php7.3:latest - commands: - - make test-stable21 - -trigger: - branch: - - master - - stable* - event: - - pull_request - - push - ---- -kind: pipeline -name: php74-stable21 - -steps: - - name: php74-stable21 - image: ghcr.io/nextcloud/continuous-integration-php7.4:latest - commands: - - make test-stable21 - -trigger: - branch: - - master - - stable* - event: - - pull_request - - push - ---- -kind: pipeline -name: php80-stable21 - -steps: - - name: php80-stable21 - image: ghcr.io/nextcloud/continuous-integration-php8.0:latest - commands: - - make test-stable21 - -trigger: - branch: - - master - - stable* - event: - - pull_request - - push - ---- -kind: pipeline -name: php74-master - -steps: - - name: php74-master - image: ghcr.io/nextcloud/continuous-integration-php7.4:latest - commands: - - make test-master - -trigger: - branch: - - master - - stable* - event: - - pull_request - - push - ---- -kind: pipeline -name: php80-master - -steps: - - name: php80-master - image: ghcr.io/nextcloud/continuous-integration-php8.0:latest - commands: - - make test-master - -trigger: - branch: - - master - - stable* - event: - - pull_request - - push diff --git a/.github/workflows/check-same-code-base.yml b/.github/workflows/check-same-code-base.yml new file mode 100644 index 00000000..4cf592d7 --- /dev/null +++ b/.github/workflows/check-same-code-base.yml @@ -0,0 +1,34 @@ +name: Check same code base + +on: + pull_request: + push: + branches: + - main + - master + - stable* + +permissions: + contents: read + +jobs: + php-lint: + runs-on: ubuntu-latest + strategy: + matrix: + php-versions: ["8.0"] + + name: check-same-code-base + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up php ${{ matrix.php-versions }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + coverage: none + + - name: check-same-code-base + run: make check-same-code-base diff --git a/.github/workflows/command-rebase.yml b/.github/workflows/command-rebase.yml new file mode 100644 index 00000000..78fcf5d1 --- /dev/null +++ b/.github/workflows/command-rebase.yml @@ -0,0 +1,51 @@ +# This workflow is provided via the organization template repository +# +# https://github.com/nextcloud/.github +# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization + +name: Rebase command + +on: + issue_comment: + types: created + +permissions: + contents: read + +jobs: + rebase: + runs-on: ubuntu-latest + permissions: + contents: none + + # On pull requests and if the comment starts with `/rebase` + if: github.event.issue.pull_request != '' && startsWith(github.event.comment.body, '/rebase') + + steps: + - name: Add reaction on start + uses: peter-evans/create-or-update-comment@v2 + with: + token: ${{ secrets.COMMAND_BOT_PAT }} + repository: ${{ github.event.repository.full_name }} + comment-id: ${{ github.event.comment.id }} + reaction-type: "+1" + + - name: Checkout the latest code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + token: ${{ secrets.COMMAND_BOT_PAT }} + + - name: Automatic Rebase + uses: cirrus-actions/rebase@1.7 + env: + GITHUB_TOKEN: ${{ secrets.COMMAND_BOT_PAT }} + + - name: Add reaction on failure + uses: peter-evans/create-or-update-comment@v2 + if: failure() + with: + token: ${{ secrets.COMMAND_BOT_PAT }} + repository: ${{ github.event.repository.full_name }} + comment-id: ${{ github.event.comment.id }} + reaction-type: "-1" diff --git a/.github/workflows/lint-php-cs.yml b/.github/workflows/lint-php-cs.yml new file mode 100644 index 00000000..eb236b73 --- /dev/null +++ b/.github/workflows/lint-php-cs.yml @@ -0,0 +1,39 @@ +# This workflow is provided via the organization template repository +# +# https://github.com/nextcloud/.github +# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization + +name: Lint + +on: + pull_request: + push: + branches: + - main + - master + - stable* + +permissions: + contents: read + +jobs: + lint: + runs-on: ubuntu-latest + + name: php-cs + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up php ${{ matrix.php-versions }} + uses: shivammathur/setup-php@v2 + with: + php-version: "7.4" + coverage: none + + - name: Install dependencies + run: composer i + + - name: Lint + run: composer run cs:check || ( echo 'Please run `composer run cs:fix` to format your code' && exit 1 ) diff --git a/.github/workflows/lint-php.yml b/.github/workflows/lint-php.yml new file mode 100644 index 00000000..d089d1ba --- /dev/null +++ b/.github/workflows/lint-php.yml @@ -0,0 +1,53 @@ +# This workflow is provided via the organization template repository +# +# https://github.com/nextcloud/.github +# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization + +name: Lint + +on: + pull_request: + push: + branches: + - main + - master + - stable* + +permissions: + contents: read + +jobs: + php-lint: + runs-on: ubuntu-latest + strategy: + matrix: + php-versions: ["7.4", "8.0", "8.1"] + + name: php-lint + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up php ${{ matrix.php-versions }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + coverage: none + + - name: Lint + run: composer run lint + + summary: + permissions: + contents: none + runs-on: ubuntu-latest + needs: php-lint + + if: always() + + name: php-lint-summary + + steps: + - name: Summary status + run: if ${{ needs.php-lint.result != 'success' && needs.php-lint.result != 'skipped' }}; then exit 1; fi diff --git a/.github/workflows/test-cli.yml b/.github/workflows/test-cli.yml new file mode 100644 index 00000000..f3b2657c --- /dev/null +++ b/.github/workflows/test-cli.yml @@ -0,0 +1,34 @@ +name: Test cli + +on: + pull_request: + push: + branches: + - main + - master + - stable* + +permissions: + contents: read + +jobs: + php-lint: + runs-on: ubuntu-latest + strategy: + matrix: + php-versions: ["7.4"] + + name: test-cli + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up php ${{ matrix.php-versions }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + coverage: none + + - name: test-cli + run: make test-cli diff --git a/.github/workflows/test-master.yml b/.github/workflows/test-master.yml new file mode 100644 index 00000000..30b88140 --- /dev/null +++ b/.github/workflows/test-master.yml @@ -0,0 +1,46 @@ +name: Test master + +on: + pull_request: + push: + branches: + - main + - master + - stable* + +permissions: + contents: read + +jobs: + test-master: + runs-on: ubuntu-latest + strategy: + matrix: + php-versions: ["7.4", "8.0", "8.1"] + + name: test-master + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up php ${{ matrix.php-versions }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + coverage: none + + - name: test-master + run: make test-master + + summary: + runs-on: ubuntu-latest + needs: test-master + + if: always() + + name: test-master-summary + + steps: + - name: Summary status + run: if ${{ needs.test-master.result != 'success' }}; then exit 1; fi diff --git a/.github/workflows/test-stable.yml b/.github/workflows/test-stable.yml new file mode 100644 index 00000000..f77d183e --- /dev/null +++ b/.github/workflows/test-stable.yml @@ -0,0 +1,52 @@ +name: Test stable + +on: + pull_request: + push: + branches: + - main + - master + - stable* + +permissions: + contents: read + +jobs: + test-stable: + runs-on: ubuntu-latest + strategy: + matrix: + php-versions: ["7.4", "8.0"] + nextcloud-versions: ["19", "20", "21"] + exclude: + - php-versions: "8.0" + nextcloud-versions: "19" + - php-versions: "8.0" + nextcloud-versions: "20" + + name: test-stable + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up php ${{ matrix.php-versions }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + coverage: none + + - name: test-stable${{ matrix.nextcloud-versions }} + run: make test-stable${{ matrix.nextcloud-versions }} + + summary: + runs-on: ubuntu-latest + needs: test-stable + + if: always() + + name: test-stable-summary + + steps: + - name: Summary status + run: if ${{ needs.test-stable.result != 'success' }}; then exit 1; fi diff --git a/.gitignore b/.gitignore index 96a4bdf9..f7ead8cb 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,4 @@ tests/data tests/vendor vendor/symfony/console/Tests vendor/symfony/debug/Tests - +/vendor-bin/**/vendor \ No newline at end of file diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 00000000..135545a2 --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,19 @@ +getFinder() + ->notPath('build') + ->notPath('l10n') + ->notPath('src') + ->notPath('vendor') + ->notPath('vendor-bin') + ->notPath('node_modules') + ->in(__DIR__); +return $config; diff --git a/Makefile b/Makefile index ff921420..6f6de787 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ box: updater.phar: box updater.php lib/*.php buildVersionFile.php php buildVersionFile.php composer dump-autoload - ./box build -c box.json + ./box compile -c box.json chmod +x updater.phar rm lib/Version.php diff --git a/composer.json b/composer.json index 10b2f87e..90683020 100644 --- a/composer.json +++ b/composer.json @@ -5,10 +5,27 @@ } }, "config": { + "allow-plugins": { + "bamarni/composer-bin-plugin": true + }, + "classmap-authoritative": true, "optimize-autoloader": true, - "classmap-authoritative": true + "platform": { + "php": "7.4" + }, + "sort-packages": true }, "require": { - "symfony/console": "^3.1" + "symfony/console": "^4.4" + }, + "scripts": { + "cs:check": "php-cs-fixer fix --dry-run --diff", + "cs:fix": "php-cs-fixer fix", + "lint": "find . -name \\*.php -not -path './vendor*' -not -path './build/*' -not -path './node_modules/*' -print0 | xargs -0 -n1 php -l", + "post-install-cmd": ["@composer bin all install --ansi"], + "post-update-cmd": ["@composer bin all update --ansi"] + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.5" } } diff --git a/composer.lock b/composer.lock index 6ec278b4..a2cc241d 100644 --- a/composer.lock +++ b/composer.lock @@ -1,38 +1,32 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "hash": "489973e863a86950adf5f6f80f6e0bec", - "content-hash": "aa14a3132a5656628d30fdd0b7292318", + "content-hash": "41e003a0aea3705ba595ca045d13224e", "packages": [ { - "name": "psr/log", - "version": "1.0.2", + "name": "psr/container", + "version": "1.1.2", "source": { "type": "git", - "url": "https://github.com/php-fig/log.git", - "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d" + "url": "https://github.com/php-fig/container.git", + "reference": "513e0666f7216c7459170d56df27dfcefe1689ea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", - "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "url": "https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea", + "reference": "513e0666f7216c7459170d56df27dfcefe1689ea", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": ">=7.4.0" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, "autoload": { "psr-4": { - "Psr\\Log\\": "Psr/Log/" + "Psr\\Container\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -42,53 +36,71 @@ "authors": [ { "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" + "homepage": "https://www.php-fig.org/" } ], - "description": "Common interface for logging libraries", - "homepage": "https://github.com/php-fig/log", + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", "keywords": [ - "log", - "psr", - "psr-3" + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" ], - "time": "2016-10-10 12:19:37" + "support": { + "issues": "https://github.com/php-fig/container/issues", + "source": "https://github.com/php-fig/container/tree/1.1.2" + }, + "time": "2021-11-05T16:50:12+00:00" }, { "name": "symfony/console", - "version": "v3.1.6", + "version": "v4.4.43", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "c99da1119ae61e15de0e4829196b9fba6f73d065" + "reference": "8a2628d2d5639f35113dc1b833ecd91e1ed1cf46" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/c99da1119ae61e15de0e4829196b9fba6f73d065", - "reference": "c99da1119ae61e15de0e4829196b9fba6f73d065", + "url": "https://api.github.com/repos/symfony/console/zipball/8a2628d2d5639f35113dc1b833ecd91e1ed1cf46", + "reference": "8a2628d2d5639f35113dc1b833ecd91e1ed1cf46", "shasum": "" }, "require": { - "php": ">=5.5.9", - "symfony/debug": "~2.8|~3.0", - "symfony/polyfill-mbstring": "~1.0" + "php": ">=7.1.3", + "symfony/polyfill-mbstring": "~1.0", + "symfony/polyfill-php73": "^1.8", + "symfony/polyfill-php80": "^1.16", + "symfony/service-contracts": "^1.1|^2" + }, + "conflict": { + "psr/log": ">=3", + "symfony/dependency-injection": "<3.4", + "symfony/event-dispatcher": "<4.3|>=5", + "symfony/lock": "<4.4", + "symfony/process": "<3.3" + }, + "provide": { + "psr/log-implementation": "1.0|2.0" }, "require-dev": { - "psr/log": "~1.0", - "symfony/event-dispatcher": "~2.8|~3.0", - "symfony/process": "~2.8|~3.0" + "psr/log": "^1|^2", + "symfony/config": "^3.4|^4.0|^5.0", + "symfony/dependency-injection": "^3.4|^4.0|^5.0", + "symfony/event-dispatcher": "^4.3", + "symfony/lock": "^4.4|^5.0", + "symfony/process": "^3.4|^4.0|^5.0", + "symfony/var-dumper": "^4.3|^5.0" }, "suggest": { "psr/log": "For using the console logger", "symfony/event-dispatcher": "", + "symfony/lock": "", "symfony/process": "" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.1-dev" - } - }, "autoload": { "psr-4": { "Symfony\\Component\\Console\\": "" @@ -111,47 +123,57 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony Console Component", + "description": "Eases the creation of beautiful and testable command line interfaces", "homepage": "https://symfony.com", - "time": "2016-10-06 01:44:51" + "support": { + "source": "https://github.com/symfony/console/tree/v4.4.43" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-06-23T12:22:25+00:00" }, { - "name": "symfony/debug", - "version": "v3.1.6", + "name": "symfony/deprecation-contracts", + "version": "v2.5.2", "source": { "type": "git", - "url": "https://github.com/symfony/debug.git", - "reference": "e2b3f74a67fc928adc3c1b9027f73e1bc01190a8" + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/e2b3f74a67fc928adc3c1b9027f73e1bc01190a8", - "reference": "e2b3f74a67fc928adc3c1b9027f73e1bc01190a8", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/e8b495ea28c1d97b5e0c121748d6f9b53d075c66", + "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66", "shasum": "" }, "require": { - "php": ">=5.5.9", - "psr/log": "~1.0" - }, - "conflict": { - "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" - }, - "require-dev": { - "symfony/class-loader": "~2.8|~3.0", - "symfony/http-kernel": "~2.8|~3.0" + "php": ">=7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.1-dev" + "dev-main": "2.5-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" } }, "autoload": { - "psr-4": { - "Symfony\\Component\\Debug\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" + "files": [ + "function.php" ] }, "notification-url": "https://packagist.org/downloads/", @@ -160,34 +182,54 @@ ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "name": "Nicolas Grekas", + "email": "p@tchwork.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony Debug Component", + "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", - "time": "2016-09-06 11:02:40" + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.2" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-01-02T09:53:40+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.2.0", + "version": "v1.26.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "dff51f72b0706335131b00a7f49606168c582594" + "reference": "9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/dff51f72b0706335131b00a7f49606168c582594", - "reference": "dff51f72b0706335131b00a7f49606168c582594", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e", + "reference": "9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=7.1" + }, + "provide": { + "ext-mbstring": "*" }, "suggest": { "ext-mbstring": "For best performance" @@ -195,15 +237,99 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2-dev" + "dev-main": "1.26-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, "autoload": { + "files": [ + "bootstrap.php" + ], "psr-4": { "Symfony\\Polyfill\\Mbstring\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.26.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-05-24T11:49:31+00:00" + }, + { + "name": "symfony/polyfill-php73", + "version": "v1.26.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php73.git", + "reference": "e440d35fa0286f77fb45b79a03fedbeda9307e85" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/e440d35fa0286f77fb45b79a03fedbeda9307e85", + "reference": "e440d35fa0286f77fb45b79a03fedbeda9307e85", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.26-dev" }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { "files": [ "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php73\\": "" + }, + "classmap": [ + "Resources/stubs" ] }, "notification-url": "https://packagist.org/downloads/", @@ -220,24 +346,257 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony polyfill for the Mbstring extension", + "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", "homepage": "https://symfony.com", "keywords": [ "compatibility", - "mbstring", "polyfill", "portable", "shim" ], - "time": "2016-05-18 14:26:46" + "support": { + "source": "https://github.com/symfony/polyfill-php73/tree/v1.26.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-05-24T11:49:31+00:00" + }, + { + "name": "symfony/polyfill-php80", + "version": "v1.26.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "cfa0ae98841b9e461207c13ab093d76b0fa7bace" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/cfa0ae98841b9e461207c13ab093d76b0fa7bace", + "reference": "cfa0ae98841b9e461207c13ab093d76b0fa7bace", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.26-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php80/tree/v1.26.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-05-10T07:21:04+00:00" + }, + { + "name": "symfony/service-contracts", + "version": "v2.5.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/service-contracts.git", + "reference": "4b426aac47d6427cc1a1d0f7e2ac724627f5966c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/4b426aac47d6427cc1a1d0f7e2ac724627f5966c", + "reference": "4b426aac47d6427cc1a1d0f7e2ac724627f5966c", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "psr/container": "^1.1", + "symfony/deprecation-contracts": "^2.1|^3" + }, + "conflict": { + "ext-psr": "<1.1|>=2" + }, + "suggest": { + "symfony/service-implementation": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.5-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\Service\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to writing services", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "support": { + "source": "https://github.com/symfony/service-contracts/tree/v2.5.2" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-05-30T19:17:29+00:00" + } + ], + "packages-dev": [ + { + "name": "bamarni/composer-bin-plugin", + "version": "v1.5.0", + "source": { + "type": "git", + "url": "https://github.com/bamarni/composer-bin-plugin.git", + "reference": "49934ffea764864788334c1485fbb08a4b852031" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/bamarni/composer-bin-plugin/zipball/49934ffea764864788334c1485fbb08a4b852031", + "reference": "49934ffea764864788334c1485fbb08a4b852031", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0 || ^2.0", + "php": "^5.5.9 || ^7.0 || ^8.0" + }, + "require-dev": { + "composer/composer": "^1.0 || ^2.0", + "symfony/console": "^2.5 || ^3.0 || ^4.0" + }, + "type": "composer-plugin", + "extra": { + "class": "Bamarni\\Composer\\Bin\\Plugin" + }, + "autoload": { + "psr-4": { + "Bamarni\\Composer\\Bin\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "No conflicts for your bin dependencies", + "keywords": [ + "composer", + "conflict", + "dependency", + "executable", + "isolation", + "tool" + ], + "time": "2022-02-22T21:01:25+00:00" } ], - "packages-dev": [], "aliases": [], "minimum-stability": "stable", "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": [], - "platform-dev": [] + "platform-dev": [], + "platform-overrides": { + "php": "7.4" + }, + "plugin-api-version": "1.1.0" } diff --git a/index.php b/index.php index 03b55585..9acd7ed7 100644 --- a/index.php +++ b/index.php @@ -60,7 +60,7 @@ class Auth { * @param string $password */ public function __construct(Updater $updater, - $password) { + $password) { $this->updater = $updater; $this->password = $password; } @@ -131,7 +131,7 @@ public function isAuthenticated() { $storedHash = $this->updater->getConfigOption('updater.secret'); // As a sanity check the stored hash or the sent password can never be empty - if($storedHash === '' || $storedHash === null || $this->password === null) { + if ($storedHash === '' || $storedHash === null || $this->password === null) { return false; } @@ -164,7 +164,7 @@ class Updater { public function __construct($baseDir) { $this->baseDir = $baseDir; - if($dir = getenv('NEXTCLOUD_CONFIG_DIR')) { + if ($dir = getenv('NEXTCLOUD_CONFIG_DIR')) { $configFileName = rtrim($dir, '/') . '/config.php'; } else { $configFileName = $this->baseDir . '/../config/config.php'; @@ -184,7 +184,7 @@ public function __construct($baseDir) { } $dataDir = $this->getDataDirectoryLocation(); - if(empty($dataDir) || !is_string($dataDir)) { + if (empty($dataDir) || !is_string($dataDir)) { throw new \Exception('Could not read data directory from config.php.'); } @@ -201,16 +201,16 @@ public function __construct($baseDir) { $buildTime = $OC_Build; } - if($version === null) { + if ($version === null) { return; } - if($buildTime === null) { + if ($buildTime === null) { return; } // normalize version to 3 digits $splittedVersion = explode('.', $version); - if(sizeof($splittedVersion) >= 3) { + if (sizeof($splittedVersion) >= 3) { $splittedVersion = array_slice($splittedVersion, 0, 3); } @@ -367,11 +367,11 @@ private function getExpectedElementsList() { */ private function getAppDirectories() { $expected = []; - if($appsPaths = $this->getConfigOption('apps_paths')) { + if ($appsPaths = $this->getConfigOption('apps_paths')) { foreach ($appsPaths as $appsPath) { $parentDir = realpath($this->baseDir . '/../'); $appDir = basename($appsPath['path']); - if(strpos($appsPath['path'], $parentDir) === 0 && $appDir !== 'apps') { + if (strpos($appsPath['path'], $parentDir) === 0 && $appDir !== 'apps') { $expected[] = $appDir; } } @@ -404,7 +404,7 @@ public function checkForExpectedFilesAndFolders() { $expectedElements = $this->getExpectedElementsList(); $unexpectedElements = []; foreach (new \DirectoryIterator($this->baseDir . '/../') as $fileInfo) { - if(array_search($fileInfo->getFilename(), $expectedElements) === false) { + if (array_search($fileInfo->getFilename(), $expectedElements) === false) { $unexpectedElements[] = $fileInfo->getFilename(); } } @@ -427,11 +427,11 @@ public function checkWritePermissions() { $it = new \RecursiveIteratorIterator($filter); foreach ($it as $path => $dir) { - if(!is_writable($path)) { + if (!is_writable($path)) { $notWritablePaths[] = $path; } } - if(count($notWritablePaths) > 0) { + if (count($notWritablePaths) > 0) { throw new UpdateException($notWritablePaths); } @@ -447,7 +447,7 @@ public function checkWritePermissions() { public function setMaintenanceMode($state) { $this->silentLog('[info] setMaintenanceMode("' . ($state ? 'true' : 'false') . '")'); - if($dir = getenv('NEXTCLOUD_CONFIG_DIR')) { + if ($dir = getenv('NEXTCLOUD_CONFIG_DIR')) { $configFileName = rtrim($dir, '/') . '/config.php'; } else { $configFileName = $this->baseDir . '/../config/config.php'; @@ -491,7 +491,7 @@ public function createBackup() { $this->silentLog('[info] backup folder location: ' . $backupFolderLocation); $state = mkdir($backupFolderLocation, 0750, true); - if($state === false) { + if ($state === false) { throw new \Exception('Could not create backup folder location'); } @@ -507,35 +507,35 @@ public function createBackup() { $folderStructure = explode('/', $fileName, -1); // Exclude the exclusions - if(isset($folderStructure[0])) { - if(array_search($folderStructure[0], $excludedElements) !== false) { + if (isset($folderStructure[0])) { + if (array_search($folderStructure[0], $excludedElements) !== false) { continue; } } else { - if(array_search($fileName, $excludedElements) !== false) { + if (array_search($fileName, $excludedElements) !== false) { continue; } } // Create folder if it doesn't exist - if(!file_exists($backupFolderLocation . '/' . dirname($fileName))) { + if (!file_exists($backupFolderLocation . '/' . dirname($fileName))) { $state = mkdir($backupFolderLocation . '/' . dirname($fileName), 0750, true); - if($state === false) { + if ($state === false) { throw new \Exception('Could not create folder: '.$backupFolderLocation.'/'.dirname($fileName)); } } // If it is a file copy it - if($fileInfo->isFile()) { + if ($fileInfo->isFile()) { $state = copy($fileInfo->getRealPath(), $backupFolderLocation . $fileName); - if($state === false) { + if ($state === false) { $message = sprintf( 'Could not copy "%s" to "%s"', $fileInfo->getRealPath(), $backupFolderLocation . $fileName ); - if(is_readable($fileInfo->getRealPath()) === false) { + if (is_readable($fileInfo->getRealPath()) === false) { $message = sprintf( '%s. Source %s is not readable', $message, @@ -543,7 +543,7 @@ public function createBackup() { ); } - if(is_writable($backupFolderLocation . $fileName) === false) { + if (is_writable($backupFolderLocation . $fileName) === false) { $message = sprintf( '%s. Destination %s is not writable', $message, @@ -573,7 +573,7 @@ private function getUpdateServerResponse() { $this->silentLog('[info] getUpdateServerResponse()'); $updaterServer = $this->getConfigOption('updater.server.url'); - if($updaterServer === null) { + if ($updaterServer === null) { // FIXME: used deployed URL $updaterServer = 'https://updates.nextcloud.com/updater_server/'; } @@ -603,26 +603,26 @@ private function getUpdateServerResponse() { } $response = curl_exec($curl); - if($response === false) { + if ($response === false) { throw new \Exception('Could not do request to updater server: '.curl_error($curl)); } curl_close($curl); // Response can be empty when no update is available - if($response === '') { + if ($response === '') { return []; } $xml = simplexml_load_string($response); - if($xml === false) { + if ($xml === false) { throw new \Exception('Could not parse updater server XML response'); } $json = json_encode($xml); - if($json === false) { + if ($json === false) { throw new \Exception('Could not JSON encode updater server response'); } $response = json_decode($json, true); - if($response === null) { + if ($response === null) { throw new \Exception('Could not JSON decode updater server response.'); } $this->silentLog('[info] getUpdateServerResponse response: ' . print_r($response, true)); @@ -639,12 +639,12 @@ public function downloadUpdate() { $response = $this->getUpdateServerResponse(); $storageLocation = $this->getDataDirectoryLocation() . '/updater-'.$this->getConfigOption('instanceid') . '/downloads/'; - if(file_exists($storageLocation)) { + if (file_exists($storageLocation)) { $this->silentLog('[info] storage location exists'); $this->recursiveDelete($storageLocation); } $state = mkdir($storageLocation, 0750, true); - if($state === false) { + if ($state === false) { throw new \Exception('Could not mkdir storage location'); } @@ -663,11 +663,11 @@ public function downloadUpdate() { ]); } - if(curl_exec($ch) === false) { + if (curl_exec($ch) === false) { throw new \Exception('Curl error: ' . curl_error($ch)); } $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); - if($httpCode !== 200) { + if ($httpCode !== 200) { $statusCodes = [ 400 => 'Bad request', 401 => 'Unauthorized', @@ -680,14 +680,14 @@ public function downloadUpdate() { ]; $message = 'Download failed'; - if(isset($statusCodes[$httpCode])) { + if (isset($statusCodes[$httpCode])) { $message .= ' - ' . $statusCodes[$httpCode] . ' (HTTP ' . $httpCode . ')'; } else { $message .= ' - HTTP status code: ' . $httpCode; } $curlErrorMessage = curl_error($ch); - if(!empty($curlErrorMessage)) { + if (!empty($curlErrorMessage)) { $message .= ' - curl error message: ' . $curlErrorMessage; } @@ -710,11 +710,11 @@ private function getDownloadedFilePath() { $this->silentLog('[info] storage location: ' . $storageLocation); $filesInStorageLocation = scandir($storageLocation); - $files = array_values(array_filter($filesInStorageLocation, function($path){ + $files = array_values(array_filter($filesInStorageLocation, function ($path) { return $path !== '.' && $path !== '..'; })); // only the downloaded archive - if(count($files) !== 1) { + if (count($files) !== 1) { throw new \Exception('There are more files than the downloaded archive in the downloads/ folder.'); } return $storageLocation . '/' . $files[0]; @@ -728,13 +728,13 @@ private function getDownloadedFilePath() { public function verifyIntegrity() { $this->silentLog('[info] verifyIntegrity()'); - if($this->getCurrentReleaseChannel() === 'daily') { + if ($this->getCurrentReleaseChannel() === 'daily') { $this->silentLog('[info] current channel is "daily" which is not signed. Skipping verification.'); return; } $response = $this->getUpdateServerResponse(); - if(!isset($response['signature'])) { + if (!isset($response['signature'])) { throw new \Exception('No signature specified for defined update'); } @@ -775,7 +775,7 @@ public function verifyIntegrity() { OPENSSL_ALGO_SHA512 ); - if($validSignature === false) { + if ($validSignature === false) { throw new \Exception('Signature of update is not valid'); } @@ -792,7 +792,7 @@ public function verifyIntegrity() { private function getVersionByVersionFile($versionFile) { require $versionFile; - if(isset($OC_Version)) { + if (isset($OC_Version)) { /** @var array $OC_Version */ return implode('.', $OC_Version); } @@ -813,12 +813,12 @@ public function extractDownload() { $zipState = $zip->open($downloadedFilePath); if ($zipState === true) { $extraction = $zip->extractTo(dirname($downloadedFilePath)); - if($extraction === false) { + if ($extraction === false) { throw new \Exception('Error during unpacking zipfile: '.($zip->getStatusString())); } $zip->close(); $state = unlink($downloadedFilePath); - if($state === false) { + if ($state === false) { throw new \Exception("Can't unlink ". $downloadedFilePath); } } else { @@ -828,7 +828,7 @@ public function extractDownload() { // Ensure that the downloaded version is not lower $downloadedVersion = $this->getVersionByVersionFile(dirname($downloadedFilePath) . '/nextcloud/version.php'); $currentVersion = $this->getVersionByVersionFile($this->baseDir . '/../version.php'); - if(version_compare($downloadedVersion, $currentVersion, '<')) { + if (version_compare($downloadedVersion, $currentVersion, '<')) { throw new \Exception('Downloaded version is lower than installed version'); } @@ -853,17 +853,17 @@ public function replaceEntryPoints() { ]; $content = "silentLog('[info] replace ' . $file); $parentDir = dirname($this->baseDir . '/../' . $file); - if(!file_exists($parentDir)) { + if (!file_exists($parentDir)) { $r = mkdir($parentDir); - if($r !== true) { + if ($r !== true) { throw new \Exception('Can\'t create parent directory for entry point: ' . $file); } } $state = file_put_contents($this->baseDir . '/../' . $file, $content); - if($state === false) { + if ($state === false) { throw new \Exception('Can\'t replace entry point: '.$file); } } @@ -878,7 +878,7 @@ public function replaceEntryPoints() { * @throws \Exception */ private function recursiveDelete($folder) { - if(!file_exists($folder)) { + if (!file_exists($folder)) { return; } $iterator = new \RecursiveIteratorIterator( @@ -908,7 +908,7 @@ private function recursiveDelete($folder) { } $state = rmdir($folder); - if($state === false) { + if ($state === false) { throw new \Exception('Could not rmdir ' . $folder); } } @@ -922,12 +922,12 @@ public function deleteOldFiles() { $this->silentLog('[info] deleteOldFiles()'); $shippedAppsFile = $this->baseDir . '/../core/shipped.json'; - if(!file_exists($shippedAppsFile)) { + if (!file_exists($shippedAppsFile)) { throw new \Exception('core/shipped.json is not available'); } $newShippedAppsFile = $this->getDataDirectoryLocation() . '/updater-'.$this->getConfigOption('instanceid') . '/downloads/nextcloud/core/shipped.json'; - if(!file_exists($newShippedAppsFile)) { + if (!file_exists($newShippedAppsFile)) { throw new \Exception('core/shipped.json is not available in the new release'); } @@ -936,12 +936,12 @@ public function deleteOldFiles() { json_decode(file_get_contents($shippedAppsFile), true)['shippedApps'], json_decode(file_get_contents($newShippedAppsFile), true)['shippedApps'] ); - foreach($shippedApps as $app) { + foreach ($shippedApps as $app) { $this->recursiveDelete($this->baseDir . '/../apps/' . $app); } $configSampleFile = $this->baseDir . '/../config/config.sample.php'; - if(file_exists($configSampleFile)) { + if (file_exists($configSampleFile)) { $this->silentLog('[info] config sample exists'); // Delete example config @@ -952,7 +952,7 @@ public function deleteOldFiles() { } $themesReadme = $this->baseDir . '/../themes/README'; - if(file_exists($themesReadme)) { + if (file_exists($themesReadme)) { $this->silentLog('[info] themes README exists'); // Delete themes @@ -988,23 +988,23 @@ public function deleteOldFiles() { $fileName = explode($currentDir, $path)[1]; $folderStructure = explode('/', $fileName, -1); // Exclude the exclusions - if(isset($folderStructure[0])) { - if(array_search($folderStructure[0], $excludedElements) !== false) { + if (isset($folderStructure[0])) { + if (array_search($folderStructure[0], $excludedElements) !== false) { continue; } } else { - if(array_search($fileName, $excludedElements) !== false) { + if (array_search($fileName, $excludedElements) !== false) { continue; } } - if($fileInfo->isFile() || $fileInfo->isLink()) { + if ($fileInfo->isFile() || $fileInfo->isLink()) { $state = unlink($path); - if($state === false) { + if ($state === false) { throw new \Exception('Could not unlink: '.$path); } - } elseif($fileInfo->isDir()) { + } elseif ($fileInfo->isDir()) { $state = rmdir($path); - if($state === false) { + if ($state === false) { throw new \Exception('Could not rmdir: '.$path); } } @@ -1039,15 +1039,15 @@ private function moveWithExclusions($dataLocation, array $excludedElements) { } } - if($fileInfo->isFile()) { - if(!file_exists($this->baseDir . '/../' . dirname($fileName))) { + if ($fileInfo->isFile()) { + if (!file_exists($this->baseDir . '/../' . dirname($fileName))) { $state = mkdir($this->baseDir . '/../' . dirname($fileName), 0755, true); - if($state === false) { + if ($state === false) { throw new \Exception('Could not mkdir ' . $this->baseDir . '/../' . dirname($fileName)); } } $state = rename($path, $this->baseDir . '/../' . $fileName); - if($state === false) { + if ($state === false) { throw new \Exception( sprintf( 'Could not rename %s to %s', @@ -1057,9 +1057,9 @@ private function moveWithExclusions($dataLocation, array $excludedElements) { ); } } - if($fileInfo->isDir()) { + if ($fileInfo->isDir()) { $state = rmdir($path); - if($state === false) { + if ($state === false) { throw new \Exception('Could not rmdir ' . $path); } } @@ -1104,11 +1104,11 @@ public function finalize() { $this->silentLog('[info] storage location: ' . $storageLocation); $this->moveWithExclusions($storageLocation, []); $state = rmdir($storageLocation); - if($state === false) { + if ($state === false) { throw new \Exception('Could not rmdir $storagelocation'); } $state = unlink($this->getDataDirectoryLocation() . '/updater-'.$this->getConfigOption('instanceid') . '/.step'); - if($state === false) { + if ($state === false) { throw new \Exception('Could not rmdir .step'); } @@ -1127,21 +1127,21 @@ public function finalize() { */ private function writeStep($state, $step) { $updaterDir = $this->getDataDirectoryLocation() . '/updater-'.$this->getConfigOption('instanceid'); - if(!file_exists($updaterDir . '/.step')) { - if(!file_exists($updaterDir)) { + if (!file_exists($updaterDir . '/.step')) { + if (!file_exists($updaterDir)) { $result = mkdir($updaterDir); if ($result === false) { throw new \Exception('Could not create $updaterDir'); } } $result = touch($updaterDir . '/.step'); - if($result === false) { + if ($result === false) { throw new \Exception('Could not create .step'); } } $result = file_put_contents($updaterDir . '/.step', json_encode(['state' => $state, 'step' => $step])); - if($result === false) { + if ($result === false) { throw new \Exception('Could not write to .step'); } } @@ -1173,7 +1173,7 @@ public function currentStep() { $updaterDir = $this->getDataDirectoryLocation() . '/updater-'.$this->getConfigOption('instanceid'); $jsonData = []; - if(file_exists($updaterDir. '/.step')) { + if (file_exists($updaterDir. '/.step')) { $state = file_get_contents($updaterDir . '/.step'); if ($state === false) { throw new \Exception('Could not read from .step'); @@ -1197,7 +1197,7 @@ public function rollbackChanges($step) { $this->silentLog('[info] rollbackChanges("' . $step . '")'); $updaterDir = $this->getDataDirectoryLocation() . '/updater-'.$this->getConfigOption('instanceid'); - if(file_exists($updaterDir . '/.step')) { + if (file_exists($updaterDir . '/.step')) { $this->silentLog('[info] unlink .step'); $state = unlink($updaterDir . '/.step'); if ($state === false) { @@ -1205,7 +1205,7 @@ public function rollbackChanges($step) { } } - if($step >= 7) { + if ($step >= 7) { $this->silentLog('[info] rollbackChanges - step >= 7'); // TODO: If it fails after step 7: Rollback } @@ -1227,7 +1227,7 @@ public function logException(\Exception $e) { $message .= 'Trace:' . PHP_EOL . $e->getTraceAsString() . PHP_EOL; $message .= 'File:' . $e->getFile() . PHP_EOL; $message .= 'Line:' . $e->getLine() . PHP_EOL; - if($e instanceof UpdateException) { + if ($e instanceof UpdateException) { $message .= 'Data:' . PHP_EOL . print_r($e->getData(), true) . PHP_EOL; } $this->log($message); @@ -1243,11 +1243,11 @@ public function log($message) { $updaterLogPath = $this->getDataDirectoryLocation() . '/updater.log'; $fh = fopen($updaterLogPath, 'a'); - if($fh === false) { + if ($fh === false) { throw new LogException('Could not open updater.log'); } - if($this->requestID === null) { + if ($this->requestID === null) { $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $charactersLength = strlen($characters); $randomString = ''; @@ -1260,7 +1260,7 @@ public function log($message) { $logLine = date(\DateTime::ISO8601) . ' ' . $this->requestID . ' ' . $message . PHP_EOL; $result = fwrite($fh, $logLine); - if($result === false) { + if ($result === false) { throw new LogException('Could not write to updater.log'); } @@ -1311,7 +1311,7 @@ public function logVersion() { try { $updater->log('[info] request to updater'); } catch (\Exception $e) { - if(isset($_POST['step'])) { + if (isset($_POST['step'])) { // mark step as failed http_response_code(500); echo(json_encode(['proceed' => false, 'response' => $e->getMessage()])); @@ -1328,31 +1328,31 @@ public function logVersion() { // Check if already a step is in process $currentStep = $updater->currentStep(); $stepNumber = 0; -if($currentStep !== []) { +if ($currentStep !== []) { $stepState = $currentStep['state']; $stepNumber = $currentStep['step']; $updater->log('[info] Step ' . $stepNumber . ' is in state "' . $stepState . '".'); - if($stepState === 'start') { + if ($stepState === 'start') { die( - sprintf( - 'Step %s is currently in process. Please reload this page later.', - $stepNumber + sprintf( + 'Step %s is currently in process. Please reload this page later.', + $stepNumber ) ); } } -if(isset($_POST['step'])) { +if (isset($_POST['step'])) { $updater->log('[info] POST request for step "' . $_POST['step'] . '"'); set_time_limit(0); try { - if(!$auth->isAuthenticated()) { + if (!$auth->isAuthenticated()) { throw new \Exception('Not authenticated'); } $step = (int)$_POST['step']; - if($step > 12 || $step < 1) { + if ($step > 12 || $step < 1) { throw new \Exception('Invalid step'); } @@ -1407,7 +1407,7 @@ public function logVersion() { $message .= ' (and writing to log failed also with: ' . $logE->getMessage() . ')'; } - if(isset($step)) { + if (isset($step)) { $updater->rollbackChanges($step); } http_response_code(500); @@ -1422,7 +1422,7 @@ public function logVersion() { $message .= ' (and writing to log failed also with: ' . $logE->getMessage() . ')'; } - if(isset($step)) { + if (isset($step)) { $updater->rollbackChanges($step); } http_response_code(500); @@ -1435,7 +1435,7 @@ public function logVersion() { $updater->log('[info] show HTML page'); $updater->logVersion(); $updaterUrl = explode('?', $_SERVER['REQUEST_URI'], 2)[0]; -if(strpos($updaterUrl, 'index.php') === false) { +if (strpos($updaterUrl, 'index.php') === false) { $updaterUrl = rtrim($updaterUrl, '/') . '/index.php'; } ?> @@ -1730,7 +1730,7 @@ public function logVersion() {