public static function getBugsforCrashSignature()

in app/classes/ReleaseInsights/Utils.php [42:75]


    public static function getBugsforCrashSignature(string $signature, int $ttl = 21_600): array
    {
        // The signature in the string varies so we create a unique file name in cache
        $cache_id = URL::Socorro->value . 'Bugs/?signatures=' . $signature;

        if (defined('TESTING_CONTEXT')) {
            $cache_id = TEST_FILES .'/crash-stats.mozilla.org_signature.json';

            if ($signature == 'failure') {
                $cache_id = TEST_FILES .'/empty.json';
            }
        }

        // If we can't retrieve cached data, we create and cache it.
        // We cache because we want to avoid http request latency
        if (! $data = Cache::getKey($cache_id, $ttl)) {
            $data = file_get_contents($cache_id);

            // Error fetching data, don't cache.
            // @codeCoverageIgnoreStart
            if ($data === false) {
                return ['error' => 'URL provided no data'];
            }
            // @codeCoverageIgnoreEnd

            // No data returned, bug or incorrect date, don't cache.
            if (empty($data)) {
                return [];
            }
            Cache::setKey($cache_id, $data);
        }

        return Json::toArray($data);
    }