Skip to content

Commit 075ab70

Browse files
Merge pull request #109 from buddypress/feature/updates
Misc fixes
2 parents 611bc8a + 9c2d267 commit 075ab70

File tree

7 files changed

+97
-46
lines changed

7 files changed

+97
-46
lines changed

.github/workflows/code-standards.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
steps:
1111
- name: Cancel previous runs of this workflow (pull requests only)
1212
if: ${{ github.event_name == 'pull_request' }}
13-
uses: styfle/cancel-workflow-action@0.5.0
13+
uses: styfle/cancel-workflow-action@0.12.0
1414
with:
1515
access_token: ${{ github.token }}
1616

.github/workflows/tests.yml

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,19 @@ on: pull_request
44

55
jobs:
66
tests:
7-
name: "WP: ${{ matrix.wp }} - PHP: ${{ matrix.php }}"
7+
name: "WP: ${{ matrix.wp_version }} - PHP: ${{ matrix.php }}"
88
runs-on: ubuntu-latest
99
strategy:
1010
fail-fast: false
1111
matrix:
12-
php: [7.4, 8.0, 8.1, 8.2, 8.3]
13-
wp: ['latest']
12+
php: ['7.4', '8.0', '8.1', '8.2', '8.3']
13+
wp_version: ['latest']
1414
mysql: [8.0]
15-
15+
include:
16+
- php: '7.4'
17+
wp_version: '6.1'
1618
env:
17-
WP_VERSION: ${{ matrix.wp }}
18-
19-
services:
20-
mysql:
21-
image: mysql:${{ matrix.mysql }}
22-
ports:
23-
- 3306
24-
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=wp_cli_test --entrypoint sh mysql:${{ matrix.mysql }} -c "exec docker-entrypoint.sh mysqld --default-authentication-plugin=mysql_native_password"
19+
WP_VERSION: ${{ matrix.wp_version }}
2520

2621
steps:
2722
- name: Cancel previous runs of this workflow (pull requests only)
@@ -48,26 +43,44 @@ jobs:
4843
php-version: ${{ matrix.php }}
4944
extensions: gd, imagick, mysql, zip
5045
coverage: none
51-
tools: composer
46+
tools: composer:v2
5247

53-
- name: Install Composer dependencies & cache dependencies
48+
- name: Install Composer dependencies
5449
uses: ramsey/composer-install@v2
5550

56-
- name: Start MySQL server
57-
run: sudo systemctl start mysql
51+
- name: Setup MySQL Server
52+
id: setup-mysql
53+
uses: shogo82148/actions-setup-mysql@v1
54+
with:
55+
mysql-version: ${{ matrix.mysql }}
56+
auto-start: true
57+
root-password: root
58+
user: wp_cli_test
59+
password: password1
60+
my-cnf: |
61+
default_authentication_plugin=mysql_native_password
5862
5963
- name: Configure DB environment
6064
run: |
61-
export MYSQL_HOST=127.0.0.1
62-
export MYSQL_TCP_PORT=${{ job.services.mysql.ports['3306'] }}
65+
echo "MYSQL_HOST=127.0.0.1" >> $GITHUB_ENV
66+
echo "MYSQL_TCP_PORT=3306" >> $GITHUB_ENV
6367
echo "WP_CLI_TEST_DBROOTUSER=root" >> $GITHUB_ENV
6468
echo "WP_CLI_TEST_DBROOTPASS=root" >> $GITHUB_ENV
65-
echo "WP_CLI_TEST_DBUSER=root" >> $GITHUB_ENV
66-
echo "WP_CLI_TEST_DBPASS=root" >> $GITHUB_ENV
67-
echo "WP_CLI_TEST_DBHOST=$MYSQL_HOST:$MYSQL_TCP_PORT" >> $GITHUB_ENV
69+
echo "WP_CLI_TEST_DBNAME=wp_cli_test" >> $GITHUB_ENV
70+
echo "WP_CLI_TEST_DBUSER=wp_cli_test" >> $GITHUB_ENV
71+
echo "WP_CLI_TEST_DBPASS=password1" >> $GITHUB_ENV
72+
echo "WP_CLI_TEST_DBHOST=127.0.0.1:3306" >> $GITHUB_ENV
6873
6974
- name: Prepare tests
75+
env:
76+
WP_VERSION: '${{ matrix.wp_version }}'
77+
WP_CLI_TEST_DBTYPE: 'mysql'
78+
WP_CLI_TEST_DBSOCKET: '${{ steps.setup-mysql.outputs.base-dir }}/tmp/mysql.sock'
7079
run: composer prepare-tests
7180

7281
- name: Run Behat
82+
env:
83+
WP_VERSION: '${{ matrix.wp_version }}'
84+
WP_CLI_TEST_DBTYPE: 'mysql'
85+
WP_CLI_TEST_DBSOCKET: '${{ steps.setup-mysql.outputs.base-dir }}/tmp/mysql.sock'
7386
run: composer behat || composer behat-rerun

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
This library adheres to [Semantic Versioning](https://semver.org/) and [Keep a CHANGELOG](https://keepachangelog.com/en/1.0.0/).
44

5+
## 3.0.1 Unpublished
6+
7+
### Changed
8+
9+
* `wp bp tool signup` supports multisite.
10+
* `wp bp signup`:
11+
* `list`: list 50 items by default, instead of 1.
12+
* added support for more object fields.
13+
* Avoid the `generate_callback` method to appear as a valid command by turning it into a protected method.
14+
* Added `composer phpunit` as an alias for `composer behat`.
15+
516
## 3.0.0
617

718
## Added

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"scripts": {
3636
"behat": "run-behat-tests",
3737
"behat-rerun": "rerun-behat-tests",
38+
"phpunit": "behat",
3839
"lint": "run-linter-tests",
3940
"phpcs": "run-phpcs-tests",
4041
"phpcbf": "run-phpcbf-cleanup",

src/command.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ function ( $component ) {
195195
* @param array $assoc_args Command arguments.
196196
* @param callable $callback Callback to execute.
197197
*/
198-
public function generate_callback( $message, $assoc_args, $callback ) {
198+
protected function generate_callback( $message, $assoc_args, $callback ) {
199199
$format = WP_CLI\Utils\get_flag_value( $assoc_args, 'format', 'progress' );
200200
$limit = $assoc_args['count'];
201201
$notify = false;

src/signup.php

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
*
1010
* ## EXAMPLES
1111
*
12+
* # Add a signup.
1213
* $ wp bp signup create --user-login=test_user --user-email=teste@site.com
1314
* Success: Successfully added new user signup (ID #345).
1415
*
16+
* # Activate a signup.
1517
* $ wp bp signup activate ee48ec319fef3nn4
1618
* Success: Signup activated, new user (ID #545).
1719
*
@@ -25,12 +27,14 @@ class Signup extends BuddyPressCommand {
2527
* @var array
2628
*/
2729
protected $obj_fields = [
28-
'signup_id',
29-
'user_login',
30+
'id',
3031
'user_name',
32+
'user_login',
33+
'user_email',
34+
'registered',
3135
'meta',
3236
'activation_key',
33-
'registered',
37+
'count_sent',
3438
];
3539

3640
/**
@@ -70,7 +74,7 @@ public static function check_dependencies() {
7074
* [--porcelain]
7175
* : Output only the new signup id.
7276
*
73-
* ## EXAMPLE
77+
* ## EXAMPLES
7478
*
7579
* # Add a signup.
7680
* $ wp bp signup create --user-login=test_user --user-email=teste@site.com
@@ -155,9 +159,16 @@ public function create( $args, $assoc_args ) {
155159
*
156160
* ## EXAMPLES
157161
*
158-
* $ wp bp signup get 123
159-
* $ wp bp signup get foo@example.com
160-
* $ wp bp signup get 123 --match-field=id
162+
* # Get a signup.
163+
* $ wp bp signup get 35 --fields=id,user_login,user_name,count_sent
164+
* +------------+------------+
165+
* | Field | Value |
166+
* +------------+------------+
167+
* | id | 35 |
168+
* | user_login | user897616 |
169+
* | user_name | Test user |
170+
* | count_sent | 4 |
171+
* +------------+------------+
161172
*/
162173
public function get( $args, $assoc_args ) {
163174
$signup = $this->get_signup_by_identifier( $args[0], $assoc_args );
@@ -220,7 +231,7 @@ function ( $signup_id ) {
220231
* <signup-id>
221232
* : Identifier for the signup. Can be a signup ID, an email address, or a user_login.
222233
*
223-
* ## EXAMPLE
234+
* ## EXAMPLES
224235
*
225236
* # Activate a signup.
226237
* $ wp bp signup activate ee48ec319fef3nn4
@@ -301,7 +312,7 @@ function ( $assoc_args, $format ) use ( $random_login, $email_domain ) {
301312
* <signup-id>
302313
* : Identifier for the signup. Can be a signup ID, an email address, or a user_login.
303314
*
304-
* ## EXAMPLE
315+
* ## EXAMPLES
305316
*
306317
* # Resend activation e-mail to a newly registered user.
307318
* $ wp bp signup resend test@example.com
@@ -326,9 +337,12 @@ public function resend( $args, $assoc_args ) {
326337
*
327338
* ## OPTIONS
328339
*
329-
* [--fields=<value>]
340+
* [--<field>=<value>]
330341
* : One or more parameters to pass. See \BP_Signup::get()
331342
*
343+
* [--fields=<fields>]
344+
* : Fields to display.
345+
*
332346
* [--count=<number>]
333347
* : How many signups to list.
334348
* ---
@@ -355,14 +369,20 @@ public function resend( $args, $assoc_args ) {
355369
* 70 71 72 73 74
356370
*
357371
* # List 100 signups and return the count.
358-
* $ wp bp signup list --number=100 --format=count
372+
* $ wp bp signup list --count=100 --format=count
359373
* 100
360374
*
375+
* # List active signups.
376+
* $ wp bp signup list --active=1 --count=10
377+
* 50
378+
*
361379
* @subcommand list
362380
*/
363381
public function list_( $args, $assoc_args ) {
364382
$formatter = $this->get_formatter( $assoc_args );
365383

384+
$assoc_args['number'] = $assoc_args['count'];
385+
366386
if ( in_array( $formatter->format, [ 'ids', 'count' ], true ) ) {
367387
$assoc_args['fields'] = 'ids';
368388
}

src/tool.php

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
* $ wp bp tool version
1818
* BuddyPress: 6.0.0
1919
*
20-
* # Reinstall BuddyPress default emails.
21-
* $ wp bp tool reinstall --yes
22-
* Success: Emails have been successfully reinstalled.
20+
* # Activate the signup tool.
21+
* $ wp bp tool signup 1
22+
* Success: Signup tool updated.
2323
*
2424
* @since 1.5.0
2525
*/
@@ -47,10 +47,9 @@ public static function check_dependencies() {
4747
* - group-count
4848
* - blog-records
4949
* - count-members
50-
* - last-activity
5150
* ---
5251
*
53-
* ## EXAMPLE
52+
* ## EXAMPLES
5453
*
5554
* # Repair the friend count.
5655
* $ wp bp tool repair friend-count
@@ -109,16 +108,23 @@ public function version() {
109108
* Success: Signup tool updated.
110109
*/
111110
public function signup( $args ) {
111+
$status = wp_validate_boolean( $args[0] );
112112

113-
// Bail early.
114-
if ( bp_get_signup_allowed() ) {
115-
WP_CLI::error( 'The BuddyPress signup feature is already allowed.' );
116-
}
113+
if ( is_multisite() ) {
114+
$retval = get_site_option( 'registration' );
117115

118-
$retval = bp_update_option( 'users_can_register', $args[0] );
116+
if ( 'all' === $retval && $status ) {
117+
WP_CLI::error( 'Both sites and user accounts registration is already allowed.' );
118+
}
119+
120+
$current = $status ? 'all' : 'none';
121+
update_site_option( 'registration', $current );
122+
} else {
123+
if ( bp_get_signup_allowed() && $status ) {
124+
WP_CLI::error( 'The BuddyPress signup feature is already allowed.' );
125+
}
119126

120-
if ( false === $retval ) {
121-
WP_CLI::error( 'Could not update the signup tool.' );
127+
bp_update_option( 'users_can_register', $status );
122128
}
123129

124130
WP_CLI::success( 'Signup tool updated.' );

0 commit comments

Comments
 (0)