Skip to content

feat(storagecontrol): add PHP delete_folder_recursive sample - #2225

Open
nidhiii-27 wants to merge 11 commits into
mainfrom
feat/add-php-delete-folder-recursive
Open

feat(storagecontrol): add PHP delete_folder_recursive sample#2225
nidhiii-27 wants to merge 11 commits into
mainfrom
feat/add-php-delete-folder-recursive

Conversation

@nidhiii-27

Copy link
Copy Markdown
Contributor

Adds a PHP code sample demonstrating hierarchical namespace recursive folder delete.

Fixes: b/530059378

[Generated-by: AI]

Adds a PHP code sample demonstrating hierarchical namespace recursive folder delete.

Fixes: b/530059378

[Generated-by: AI]
@nidhiii-27 nidhiii-27 added ai-generated Generated by AI storage-sample-architect Generated by storage-sample-architect skill labels Jul 2, 2026
@product-auto-label product-auto-label Bot added the samples Issues that are directly related to samples. label Jul 2, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request updates the "google/cloud-storage-control" dependency to "^1.9" in composer.json, introduces a new sample script "delete_folder_recursive.php" for recursively deleting Cloud Storage folders, and adds a corresponding integration test in "StorageControlTest.php" to verify this functionality. I have no feedback to provide as there are no review comments.

… and handle eventual consistency in tests

[Generated-by: AI]
@nidhiii-27
nidhiii-27 marked this pull request as ready for review July 2, 2026 09:39
@nidhiii-27
nidhiii-27 requested review from a team as code owners July 2, 2026 09:39
@snippet-bot

snippet-bot Bot commented Jul 2, 2026

Copy link
Copy Markdown

Here is the summary of changes.

You are about to add 1 region tag.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

Implement a fallback to alternative credentials in the Kokoro system tests script. This addresses the global 'Invalid JWT Signature' error caused by the expired primary service account key for php-docs-samples.
Also added storagecontrol to ALT_PROJECT_TESTS in testing/run_test_suite.sh.

[Generated-by: AI]
@nidhiii-27
nidhiii-27 requested a review from a team as a code owner July 5, 2026 16:55
$output
);

// Verify folder is gone by trying to get the parent folder

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

To ensure we are verifying that the operation actually deleted descendants recursively, please also assert that $childFolderId returns a 404.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Co-authored by AI Agent

$bucketResourceName = self::$storageControlClient->bucketName('_', $bucketName);

// Create parent folder
$createParentRequest = new \Google\Cloud\Storage\Control\V2\CreateFolderRequest([

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

For consistency with the rest of the test suite, please import CreateFolderRequest, GetFolderRequest, and ApiException at the top of the file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Co-authored by AI Agent

* See the License for the specific language governing permissions and
* limitations under the License.
*/

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Other samples in storagecontrol/src/ include a docblock before the namespace statement linking to the sample README. Let's add that here for consistency.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Co-authored by AI Agent

Comment thread .kokoro/system_tests.sh Outdated
if [ -f ${GOOGLE_APPLICATION_CREDENTIALS} ]; then
gcloud auth activate-service-account \
if [ -f "${GOOGLE_APPLICATION_CREDENTIALS}" ]; then
PROJECT_ID=$(cat "${GOOGLE_APPLICATION_CREDENTIALS}" | jq -r .project_id)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: We can eliminate the extra cat invocation when extracting PROJECT_ID:

PROJECT_ID=$(jq -r .project_id "${GOOGLE_APPLICATION_CREDENTIALS}")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Co-authored by AI Agent

Comment thread .kokoro/system_tests.sh
if [ -f "${GOOGLE_ALT_APPLICATION_CREDENTIALS}" ]; then
gcloud auth activate-service-account \
--key-file "${GOOGLE_ALT_APPLICATION_CREDENTIALS}" \
--project "${GOOGLE_ALT_PROJECT_ID}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

if GOOGLE_ALT_PROJECT_ID is not explicitly exported in the environment, --project "${GOOGLE_ALT_PROJECT_ID}" may be empty. Should we extract it from the alternate credentials file if unset?

Side note: can we have someone familiar with this file verify that the fallback logic behaves as expected across all test pipelines?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Co-authored by AI Agent

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

bshaffer could you please review the fallback logic in this file.

@kalragauri
kalragauri requested a review from bshaffer September 4, 2026 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated Generated by AI resolve-pr-failures samples Issues that are directly related to samples. storage-sample-architect Generated by storage-sample-architect skill

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants