Skip to content

Commit 478f56c

Browse files
authored
Merge pull request #464 from Automattic/fix_461
RestrictedFunctions: Add stats_get_csv()
2 parents 4dfac5d + 78fc9ba commit 478f56c

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

WordPressVIPMinimum/Sniffs/Functions/RestrictedFunctionsSniff.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,13 @@ public function getGroups() {
268268
'delete_site_option',
269269
],
270270
],
271+
'stats_get_csv' => [
272+
'type' => 'error',
273+
'message' => 'Using `%s` outside of Jetpack context pollutes the stats_cache entry in the wp_options table. We recommend building a custom function instead.',
274+
'functions' => [
275+
'stats_get_csv',
276+
]
277+
],
271278
'wp_mail' => [
272279
'type' => 'warning',
273280
'message' => '`%s` should be used sparingly. For any bulk emailing should be handled by a 3rd party service, in order to prevent domain or IP addresses being flagged as spam.',

WordPressVIPMinimum/Tests/Functions/RestrictedFunctionsUnitTest.inc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,3 +224,6 @@ delete_option( $bar ); // Ok.
224224

225225
wpcom_vip_get_page_by_path(); // Ok - VIP recommended version of get_page_by_path().
226226
get_page_by_path( $page_path ); // Warning.
227+
228+
$popular = stats_get_csv( 'postviews', [ 'days' => 2, 'limit' => 20 ] ); // Error.
229+
$popular = custom_stats_get_csv( 'postviews', [ 'days' => 2, 'limit' => 20 ] ); // Ok.

WordPressVIPMinimum/Tests/Functions/RestrictedFunctionsUnitTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ public function getErrorList() {
109109
218 => 1,
110110
220 => 1,
111111
222 => 1,
112+
228 => 1,
112113
];
113114
}
114115

0 commit comments

Comments
 (0)