Skip to content

Commit 8d37f7a

Browse files
tarrowAndrewKostka
andauthored
Update to PHP 8.1 (#703)
* Update to PHP 8.1 As part of this process it was necssary to make some tweaks related to our use of PDO calls. In 8.1 attempting to explicitly commit or rollback a transaciton when none is in progress now errors rather than failing silently[1]. We have a number of these in our wiki deletion code since the altering of the tables automatically commits and ends the transaction. For this reason we are also unable use the traits that rollback transactions after running tests if the tests themselves are causing a commit. These have been removed too. Unfortunately this adds more places where the tests are no longer idempotent. [1] php/php-src@990bb34 * Run `composer update` after using php81 (#713) * Run after using php81 * Use legacy PSR-7 message factories --------- Co-authored-by: Andrew Kostka <andrew.kostka@wikimedia.de> --------- Co-authored-by: Andrew Kostka <andrew.kostka@wikimedia.de>
1 parent 0982822 commit 8d37f7a

7 files changed

Lines changed: 1933 additions & 1729 deletions

File tree

.github/workflows/composer.test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Install dependencies
2323
uses: php-actions/composer@v6
2424
with:
25-
php_version: 7.4
25+
php_version: 8.1
2626
command: install
2727

2828
- name: Copy example .env file

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ WORKDIR /tmp/src2
1212
RUN composer install --no-dev --no-progress --optimize-autoloader
1313

1414

15-
FROM php:7.4-apache
15+
FROM php:8.1-apache
1616

1717
RUN apt-get update \
1818
# Needed for the imagick php extension install

app/Jobs/DeleteWikiDbJob.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ public function handle( DatabaseManager $manager )
9696
throw new \RuntimeException("Tried getting table names for wikiDB {$wikiDB->name} but did not find any");
9797
}
9898

99-
$pdo->beginTransaction();
10099

101100
// Create the new database
102101
$pdo->exec(sprintf('CREATE DATABASE %s', $deletedDatabaseName));
@@ -114,16 +113,10 @@ public function handle( DatabaseManager $manager )
114113
}
115114

116115
$pdo->exec(sprintf('DROP USER %s', $wikiDB->user ));
117-
118-
$pdo->commit();
119116
} catch (\Throwable $e) {
120-
121-
$pdo->rollBack();
122-
123117
$manager->purge('mw');
124118
$this->fail( new \RuntimeException('Failed to soft-soft delete '.$wikiDB->name . ': ' . $e->getMessage()) );
125119
return;
126-
127120
}
128121

129122
$wikiDB->delete();

composer.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"gluedev/laravel-stackdriver": "dev-develop#7fb3e78ce949dd341b5418f876c3ff74d8c1ff92",
1616
"google/recaptcha": "^1.2",
1717
"guzzlehttp/guzzle": "^6.3",
18+
"guzzlehttp/psr7": "^1.9",
1819
"hackzilla/password-generator": "^1.6",
1920
"illuminate/mail": "^8.48",
2021
"illuminate/redis": "^8.48",
@@ -28,6 +29,8 @@
2829
"mxl/laravel-job": "^1.2",
2930
"percymamedy/laravel-dev-booter": "^3.0",
3031
"php-http/guzzle6-adapter": "^2.0",
32+
"php-http/message": "^1.16",
33+
"php-http/message-factory": "^1.1",
3134
"predis/predis": "^1.1",
3235
"superbalist/laravel-google-cloud-storage": "^2.2"
3336
},
@@ -77,13 +80,14 @@
7780
},
7881
"config": {
7982
"platform": {
80-
"php": "7.4"
83+
"php": "8.1"
8184
},
8285
"preferred-install": "dist",
8386
"sort-packages": true,
8487
"optimize-autoloader": true,
8588
"allow-plugins": {
86-
"composer/package-versions-deprecated": true
89+
"composer/package-versions-deprecated": true,
90+
"php-http/discovery": false
8791
}
8892
},
8993
"minimum-stability": "dev",

0 commit comments

Comments
 (0)