Skip to content

feat: upgrade all instances of PHP 7.4 and 8.0 to 8.1 or higher #1963

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

Merged
merged 12 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
php-version: '8.2'

- name: Run Script
run: testing/run_cs_check.sh
Expand All @@ -25,7 +25,7 @@ jobs:
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
php-version: '8.2'
- name: Get changed files
id: changedFiles
uses: tj-actions/changed-files@v41
Expand Down
2 changes: 1 addition & 1 deletion .kokoro/deploy_gae.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/php80"
value: "gcr.io/cloud-devrel-kokoro-resources/php81"
}

# Run the deployment tests
Expand Down
2 changes: 1 addition & 1 deletion .kokoro/deploy_gcf.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/php80"
value: "gcr.io/cloud-devrel-kokoro-resources/php81"
}

# Run the deployment tests
Expand Down
2 changes: 1 addition & 1 deletion .kokoro/deploy_misc.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/php80"
value: "gcr.io/cloud-devrel-kokoro-resources/php81"
}

# Run the deployment tests
Expand Down
2 changes: 1 addition & 1 deletion .kokoro/php80.cfg → .kokoro/php83.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/php80"
value: "gcr.io/cloud-devrel-kokoro-resources/php83"
}

# Give the docker image a unique project ID and credentials per PHP version
Expand Down
2 changes: 1 addition & 1 deletion .kokoro/php_rest.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/php80"
value: "gcr.io/cloud-devrel-kokoro-resources/php81"
}

# Set this project to run REST tests only
Expand Down
6 changes: 3 additions & 3 deletions appengine/standard/getting-started/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Getting Started on App Engine for PHP 7.4
# Getting Started on App Engine for PHP 8.1

This sample demonstrates how to deploy a PHP application which integrates with
Cloud SQL and Cloud Storage on App Engine Standard for PHP 7.4. The tutorial
Cloud SQL and Cloud Storage on App Engine Standard for PHP 8.1. The tutorial
uses the Slim framework.

## View the [full tutorial](https://cloud.google.com/appengine/docs/standard/php7/building-app/)
## View the [full tutorial](https://cloud.google.com/appengine/docs/standard/php-gen2/building-app)
6 changes: 3 additions & 3 deletions appengine/standard/slim-framework/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Slim Framework on App Engine for PHP 7.4
# Slim Framework on App Engine for PHP

This sample demonstrates how to deploy a *very* basic [Slim][slim] application to
[Google App Engine for PHP 7.4][appengine-php]. For a more complete guide, follow
[Google App Engine for PHP][appengine-php]. For a more complete guide, follow
the [Building an App][building-an-app] tutorial.

## Setup
Expand Down Expand Up @@ -34,7 +34,7 @@ The application consists of three components:
3. An [`index.php`](index.php) which handles all the requests which get routed to your app.

The `index.php` file is the most important. All applications running on App Engine
for PHP 7.4 require use of a [front controller][front-controller] file.
for PHP require use of a [front controller][front-controller] file.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did we drop the version in these files?

I could see this being redundant though. Are the minimum requirements stated elsewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the instructions are not specific to a version of PHP, so we can remove the "7.4" because it's an unnecessary qualifier.


[console]: https://console.developers.google.com/project
[slim]: https://www.slimframework.com/
Expand Down
2 changes: 1 addition & 1 deletion appengine/standard/slim-framework/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
-->
<phpunit bootstrap="../../../testing/bootstrap.php">
<testsuites>
<testsuite name="AppEngine for PHP 7.4 Slim Framework test">
<testsuite name="AppEngine for PHP Slim Framework test">
<directory>test</directory>
</testsuite>
</testsuites>
Expand Down
2 changes: 1 addition & 1 deletion bigtable/src/update_app_profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function update_app_profile(
if ($operationResponse->operationSucceeded()) {
$updatedAppProfile = $operationResponse->getResult();
printf('App profile updated: %s' . PHP_EOL, $updatedAppProfile->getName());
// doSomethingWith($updatedAppProfile)
// doSomethingWith($updatedAppProfile)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we remove this line?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am ambivalent... someone put it here because they thought it illustrated something important. I only changed it because it was indented improperly.

} else {
$error = $operationResponse->getError();
// handleError($error)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with this one - the comment is meant as an example of something a user could implement, e.g. they could implement some error handling here with a fake function such as handleError

Expand Down
2 changes: 1 addition & 1 deletion bigtable/src/update_cluster.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function update_cluster(
if ($operationResponse->operationSucceeded()) {
$updatedCluster = $operationResponse->getResult();
printf('Cluster updated with the new num of nodes: %s.' . PHP_EOL, $updatedCluster->getServeNodes());
// doSomethingWith($updatedCluster)
// doSomethingWith($updatedCluster)
} else {
$error = $operationResponse->getError();
// handleError($error)
Expand Down
2 changes: 1 addition & 1 deletion bigtable/src/update_instance.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function update_instance(
if ($operationResponse->operationSucceeded()) {
$updatedInstance = $operationResponse->getResult();
printf('Instance updated with the new display name: %s.' . PHP_EOL, $updatedInstance->getDisplayName());
// doSomethingWith($updatedInstance)
// doSomethingWith($updatedInstance)
} else {
$error = $operationResponse->getError();
// handleError($error)
Expand Down
8 changes: 4 additions & 4 deletions datastore/api/test/ConceptsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -441,10 +441,10 @@ public function testKeyFilter()
$this->assertStringContainsString('Query\Query Object', $output);

$this->runEventuallyConsistentTest(
function () use ($key1, $output) {
$this->assertStringContainsString('Found 1 records', $output);
$this->assertStringContainsString($key1->path()[0]['name'], $output);
});
function () use ($key1, $output) {
$this->assertStringContainsString('Found 1 records', $output);
$this->assertStringContainsString($key1->path()[0]['name'], $output);
});
}

public function testAscendingSort()
Expand Down
4 changes: 2 additions & 2 deletions dlp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ See the [DLP Documentation](https://cloud.google.com/dlp/docs/inspecting-text) f
export GOOGLE_PROJECT_ID=YOUR_PROJECT_ID
```
- [Create a Google Cloud Storage bucket](https://console.cloud.google.com/storage) and upload [test.txt](src/test/data/test.txt).
- Set the `GOOGLE_STORAGE_BUCKET` environment variable.
- Set the `GOOGLE_STORAGE_BUCKET` environment variable.
- Set the `GCS_PATH` environment variable to point to the path for the bucket file.
```
export GOOGLE_STORAGE_BUCKET=YOUR_BUCKET
Expand Down Expand Up @@ -120,7 +120,7 @@ PHP Fatal error: Uncaught Error: Call to undefined function Google\Protobuf\Int
You may need to install the bcmath PHP extension.
e.g. (may depend on your php version)
```
$ sudo apt-get install php8.0-bcmath
$ sudo apt-get install php8.1-bcmath
```


Expand Down
4 changes: 2 additions & 2 deletions eventarc/generic/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -16,7 +16,7 @@

# Use the official PHP image.
# https://hub.docker.com/_/php
FROM php:8.0-apache
FROM php:8.1-apache

# Configure PHP for Cloud Run.
# Precompile PHP code with opcache.
Expand Down
2 changes: 1 addition & 1 deletion functions/helloworld_http/composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"require": {
"php": ">= 7.4",
"php": ">= 8.1",
"google/cloud-functions-framework": "^1.1"
},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion functions/helloworld_pubsub/composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"require": {
"php": ">= 7.4",
"php": ">= 8.1",
"cloudevents/sdk-php": "^1.0",
"google/cloud-functions-framework": "^1.1"
},
Expand Down
2 changes: 1 addition & 1 deletion functions/helloworld_storage/composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"require": {
"php": ">= 7.4",
"php": ">= 8.1",
"google/cloud-functions-framework": "^1.1"
},
"scripts": {
Expand Down
42 changes: 21 additions & 21 deletions functions/http_content_type/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,30 @@ function helloContent(ServerRequestInterface $request): string
switch ($request->getHeaderLine('content-type')) {
// '{"name":"John"}'
case 'application/json':
if (!empty($body)) {
$json = json_decode($body, true);
if (json_last_error() != JSON_ERROR_NONE) {
throw new RuntimeException(sprintf(
'Could not parse body: %s',
json_last_error_msg()
));
}
$name = $json['name'] ?? $name;
}
break;
// 'John', stored in a stream
if (!empty($body)) {
$json = json_decode($body, true);
if (json_last_error() != JSON_ERROR_NONE) {
throw new RuntimeException(sprintf(
'Could not parse body: %s',
json_last_error_msg()
));
}
$name = $json['name'] ?? $name;
}
break;
// 'John', stored in a stream
case 'application/octet-stream':
$name = $body;
break;
// 'John'
$name = $body;
break;
// 'John'
case 'text/plain':
$name = $body;
break;
// 'name=John' in the body of a POST request (not the URL)
$name = $body;
break;
// 'name=John' in the body of a POST request (not the URL)
case 'application/x-www-form-urlencoded':
parse_str($body, $data);
$name = $data['name'] ?? $name;
break;
parse_str($body, $data);
$name = $data['name'] ?? $name;
break;
}

return sprintf('Hello %s!', htmlspecialchars($name));
Expand Down
2 changes: 1 addition & 1 deletion functions/response_streaming/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function streamBigQuery(ServerRequestInterface $request)
$bigQuery = new BigQueryClient(['projectId' => $projectId]);
$queryJobConfig = $bigQuery->query(
'SELECT abstract FROM `bigquery-public-data.breathe.bioasq` LIMIT 1000'
);
);
$queryResults = $bigQuery->runQuery($queryJobConfig);

// Stream out large payload by iterating rows and flushing output.
Expand Down
2 changes: 1 addition & 1 deletion functions/typed_greeting/composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"require": {
"php": ">= 7.4",
"php": ">= 8.1",
"google/cloud-functions-framework": "^1.3"
},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion run/helloworld/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

# Use the official PHP image.
# https://hub.docker.com/_/php
FROM php:8.0-apache
FROM php:8.1-apache

# Configure PHP for Cloud Run.
# Precompile PHP code with opcache.
Expand Down
Loading