Skip to content

Commit 5375344

Browse files
committed
Add curly braces on text expansion as requested
Add tests to validate data truncate of wp_links table
1 parent 8f0e7c3 commit 5375344

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

features/site-empty.feature

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,21 @@ Feature: Empty a WordPress site of its data
66
And download:
77
| path | url |
88
| {CACHE_DIR}/large-image.jpg | http://wp-cli.org/behat-data/large-image.jpg |
9+
And a insert_link_data.sql file:
10+
"""
11+
INSERT INTO `wp_links` (`link_url`, `link_name`, `link_image`, `link_target`, `link_description`, `link_visible`, `link_owner`, `link_rating`, `link_rel`, `link_notes`, `link_rss`)
12+
VALUES ('http://wordpress.org/', 'test', '', '', 'test', 'Y', 1, 0, '', '', '')
13+
"""
14+
15+
When I run `wp db query "SOURCE insert_link_data.sql;"`
16+
Then STDERR should be empty
17+
18+
When I run `wp db query "SELECT COUNT(link_id) FROM wp_links;"`
19+
Then STDOUT should be:
20+
"""
21+
COUNT(link_id)
22+
1
23+
"""
924

1025
When I run `wp media import {CACHE_DIR}/large-image.jpg --post_id=1`
1126
Then the wp-content/uploads/large-image.jpg file should exist
@@ -63,6 +78,13 @@ Feature: Empty a WordPress site of its data
6378
0
6479
"""
6580

81+
When I run `wp db query "SELECT COUNT(link_id) FROM wp_links;"`
82+
Then STDOUT should be:
83+
"""
84+
COUNT(link_id)
85+
0
86+
"""
87+
6688
Scenario: Empty a site and its uploads directory
6789
Given a WP multisite installation
6890
And I run `wp site create --slug=foo`

src/Site_Command.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ private function empty_links() {
122122
global $wpdb;
123123

124124
// Remove links and related cached data.
125-
$links_query = "SELECT link_id FROM $wpdb->links";
125+
$links_query = "SELECT link_id FROM {$wpdb->links}";
126126
$links = new QueryIterator( $links_query, 10000 );
127127

128128
// Remove bookmarks cache group.
@@ -140,7 +140,7 @@ private function empty_links() {
140140
}
141141

142142
// Empty the table once link related cache and term is removed.
143-
$wpdb->query( "TRUNCATE $wpdb->links" );
143+
$wpdb->query( "TRUNCATE {$wpdb->links}" );
144144
}
145145

146146
/**

0 commit comments

Comments
 (0)