Skip to content

Commit 00eed65

Browse files
committed
Merge branch 'main' into copilot/add-passthrough-args-support
2 parents 20d13ff + 20feb80 commit 00eed65

9 files changed

Lines changed: 65 additions & 5 deletions

File tree

.github/workflows/code-quality.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ on:
66
branches:
77
- main
88
- master
9+
schedule:
10+
- cron: '17 2 * * *' # Run every day on a seemly random time.
911

1012
jobs:
1113
code-quality:

.github/workflows/copilot-setup-steps.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ jobs:
1717

1818
steps:
1919
- name: Checkout code
20-
uses: actions/checkout@v6
20+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
2121

2222
- name: Check existence of composer.json file
2323
id: check_composer_file
24-
uses: andstor/file-existence-action@v3
24+
uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3
2525
with:
2626
files: "composer.json"
2727

2828
- name: Set up PHP environment
2929
if: steps.check_composer_file.outputs.files_exists == 'true'
30-
uses: shivammathur/setup-php@v2
30+
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2
3131
with:
3232
php-version: 'latest'
3333
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On
@@ -38,7 +38,7 @@ jobs:
3838

3939
- name: Install Composer dependencies & cache dependencies
4040
if: steps.check_composer_file.outputs.files_exists == 'true'
41-
uses: ramsey/composer-install@v3
41+
uses: ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520 # v3
4242
env:
4343
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
4444
with:

.github/workflows/issue-triage.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ name: Issue and PR Triage
1313
required: false
1414
type: string
1515

16+
permissions:
17+
issues: write
18+
pull-requests: write
19+
actions: write
20+
contents: read
21+
models: read
22+
1623
jobs:
1724
issue-triage:
1825
uses: wp-cli/.github/.github/workflows/reusable-issue-triage.yml@main

.github/workflows/regenerate-readme.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ on:
1010
- "features/**"
1111
- "README.md"
1212

13+
permissions:
14+
contents: write
15+
pull-requests: write
16+
1317
jobs:
1418
regenerate-readme:
1519
uses: wp-cli/.github/.github/workflows/reusable-regenerate-readme.yml@main

.github/workflows/welcome-new-contributors.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
- main
88
- master
99

10+
permissions:
11+
pull-requests: write
12+
1013
jobs:
1114
welcome:
1215
uses: wp-cli/.github/.github/workflows/reusable-welcome-new-contributors.yml@main

.typos.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[default]
2+
extend-ignore-re = [
3+
"(?Rm)^.*(#|//)\\s*spellchecker:disable-line$",
4+
"(?s)(#|//)\\s*spellchecker:off.*?\\n\\s*(#|//)\\s*spellchecker:on",
5+
"(#|//)\\s*spellchecker:ignore-next-line\\n.*"
6+
]

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
},
1717
"require-dev": {
1818
"wp-cli/entity-command": "^2",
19+
"wp-cli/rewrite-command": "^2",
1920
"wp-cli/wp-cli-tests": "^5"
2021
},
2122
"config": {

features/server.feature

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,25 @@ Feature: Serve WordPress locally
2929
"""
3030
256M
3131
"""
32+
33+
Scenario: Access wp-login.php
34+
Given a WP install
35+
And I launch in the background `wp server --host=localhost --port=8182`
36+
37+
When I run `curl -sS http://localhost:8182/wp-login.php`
38+
Then STDOUT should contain:
39+
"""
40+
wp-login.php
41+
"""
42+
43+
Scenario: Pretty permalinks
44+
Given a WP install
45+
And I launch in the background `wp server --host=localhost --port=8183`
46+
And I run `wp option update permalink_structure '/%postname%/'`
47+
And I run `wp rewrite flush`
48+
49+
When I run `curl -sSL http://localhost:8183/hello-world/`
50+
Then STDOUT should contain:
51+
"""
52+
Hello world!
53+
"""

router.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,15 @@ function ( $url ) {
107107
$url = str_replace( $site_url_host, $_SERVER['HTTP_HOST'], $url );
108108
}
109109

110+
$url = str_replace( 'https://', 'http://', $url );
111+
110112
return $url;
111113
},
112114
20
113115
);
114116

117+
add_filter( 'got_url_rewrite', '__return_true' );
118+
115119
$_SERVER['SERVER_ADDR'] = gethostbyname( $_SERVER['SERVER_NAME'] );
116120
$wpcli_server_root = $_SERVER['DOCUMENT_ROOT'];
117121
// phpcs:ignore WordPress.WP.AlternativeFunctions.parse_url_parse_url
@@ -123,13 +127,24 @@ function ( $url ) {
123127
exit;
124128
}
125129

126-
if ( strpos( $wpcli_server_path, '.php' ) !== false ) {
130+
// Check if this is a PHP file by examining the extension
131+
if ( pathinfo( $wpcli_server_path, PATHINFO_EXTENSION ) === 'php' ) {
132+
// Set $_SERVER variables to mimic direct access to the PHP file
133+
$_SERVER['SCRIPT_NAME'] = $wpcli_server_path;
134+
$_SERVER['PHP_SELF'] = $wpcli_server_path;
135+
$_SERVER['SCRIPT_FILENAME'] = $wpcli_server_root . $wpcli_server_path;
136+
127137
chdir( dirname( $wpcli_server_root . $wpcli_server_path ) );
128138
require_once $wpcli_server_root . $wpcli_server_path;
129139
} else {
130140
return false;
131141
}
132142
} else {
143+
// File doesn't exist - route to index.php for pretty permalinks
144+
$_SERVER['SCRIPT_NAME'] = '/index.php';
145+
$_SERVER['PHP_SELF'] = '/index.php';
146+
$_SERVER['SCRIPT_FILENAME'] = $wpcli_server_root . '/index.php';
147+
133148
chdir( $wpcli_server_root );
134149
require_once 'index.php';
135150
}

0 commit comments

Comments
 (0)