mirror of
https://github.com/sbrl/Pepperminty-Wiki.git
synced 2024-11-22 04:23:01 +00:00
Add more type hints, and fail to get Server-Timing working.
Note to self: If we do end up implementing it, remember that $env->perfdata does containsensitive information sometimes, so we might need to revise our approach a bit (e.g. only sending it to authenticated admins)
This commit is contained in:
parent
12d4387c99
commit
45c2fa56cd
2 changed files with 17 additions and 3 deletions
|
@ -778,7 +778,7 @@ $body
|
|||
* @param string $body The body of the email.
|
||||
* @return int The number of emails sent successfully.
|
||||
*/
|
||||
function email_users($usernames, $subject, $body)
|
||||
function email_users($usernames, string $subject, string $body) : int
|
||||
{
|
||||
$emailsSent = 0;
|
||||
foreach($usernames as $username)
|
||||
|
@ -828,8 +828,16 @@ function crypto_id(int $length) : string {
|
|||
* Returns whether we are both on the cli AND the cli is enabled.
|
||||
* @return boolean
|
||||
*/
|
||||
function is_cli() {
|
||||
function is_cli() : bool {
|
||||
global $settings;
|
||||
return php_sapi_name() == "cli" &&
|
||||
$settings->cli_enabled;
|
||||
}
|
||||
|
||||
function metrics2servertiming(stdClass $perfdata) : string {
|
||||
$result = [];
|
||||
foreach($perfdata as $key => $value) {
|
||||
$result[] = str_replace("_", "", $key).";dur=$value";
|
||||
}
|
||||
return "foo, ".implode(", ", $result);
|
||||
}
|
||||
|
|
|
@ -147,7 +147,13 @@ class page_renderer
|
|||
*/
|
||||
public static function render($title, $content, $body_template = false)
|
||||
{
|
||||
global $settings, $start_time, $version;
|
||||
global $settings, $env, $start_time, $version;
|
||||
|
||||
// Hrm, we can't seem to get this working
|
||||
// This example URL works: https://httpbin.org/response-headers?Server=httpbin&Content-Type=text%2Fplain%3B+charset%3DUTF-8&Server-Timing=sql-1%3Bdesc%3D%22MySQL%20lookup%20Server%22%3Bdur%3D100%2Csql-2%3Bdur%3D900%3Bdesc%3D%22MySQL%20shard%20Server%20%231%22%2Cfs%3Bdur%3D600%3Bdesc%3D%22FileSystem%22%2Ccache%3Bdur%3D300%3Bdesc%3D%22Cache%22%2Cother%3Bdur%3D200%3Bdesc%3D%22Database%20Write%22%2Cother%3Bdur%3D110%3Bdesc%3D%22Database%20Read%22%2Ccpu%3Bdur%3D1230%3Bdesc%3D%22Total%20CPU%22
|
||||
// ..... but setting headers here doesn't (though we haven't tried sending an identical header to the above example yet)
|
||||
// header("Server-Timing: foo;desc=\"Test\";dur=123");
|
||||
// header("Server-Timing: ".metrics2servertiming($env->perfdata));
|
||||
|
||||
if($body_template === false)
|
||||
$body_template = self::$main_content_template;
|
||||
|
|
Loading…
Reference in a new issue