Skip to content

Commit

Permalink
Adjust so telemetry not sent for GitHub workflows (#407)
Browse files Browse the repository at this point in the history
  • Loading branch information
yorkshire-pudding authored Jul 24, 2024
1 parent 7300a6c commit 3b537c8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .lando/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ set_up() {
unzip -q backdrop.zip && mv backdrop-1.x backdrop
echo 'if (isset($_SERVER["BACKDROP_SETTINGS"])) unset($_SERVER["BACKDROP_SETTINGS"]);' >> backdrop/settings.php

# Disable sending of telemetry data from GitHub Action runners. Override if
# testing telemetry locally.
echo '$settings["telemetry_enabled"] = FALSE;' >> backdrop/settings.php

# Configure multisite installation.
cp -r backdrop multisite
cd multisite
Expand Down
4 changes: 3 additions & 1 deletion commands/status.bee.inc
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ function status_bee_callback($arguments, $options) {
try {
// Check if telemetry is enabled.
$telemetry_query = "SELECT `status` FROM {system} WHERE `name` = 'telemetry'";
$telemetry_status = (bool) db_query($telemetry_query)->fetchField();
$telemetry_module = (bool) db_query($telemetry_query)->fetchField();
$telemetry_override = isset($settings['telemetry_enabled']) ? $settings['telemetry_enabled'] : TRUE;
$telemetry_status = $telemetry_module && $telemetry_override;

// States directly from database, as state_get() requires a higher
// bootstrap level with caching and locking.
Expand Down
8 changes: 7 additions & 1 deletion includes/telemetry.inc
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,14 @@ function bee_get_headers_from_curl_response($response_header_content) {
* TRUE if module is enabled, FALSE otherwise.
*/
function bee_telemetry_enabled() {
global $_bee_bootstrap_level;
global $_bee_bootstrap_level, $settings;
$status = FALSE;

$bee_telemetry_override_setting = isset($settings['telemetry_enabled']) ? $settings['telemetry_enabled'] : TRUE;
if (!$bee_telemetry_override_setting) {
return $status;
}

if ($_bee_bootstrap_level == BEE_BOOTSTRAP_FULL) {
// If full bootstrap we can use the Backdrop function.
$status = module_exists('telemetry');
Expand Down

0 comments on commit 3b537c8

Please sign in to comment.