com web/people: Fetch all users once and cache it rather then making slow request per user: include/misc.php

From: Date: Mon, 30 Dec 2013 05:02:52 +0000
Subject: com web/people: Fetch all users once and cache it rather then making slow request per user: include/misc.php
Groups: php.webmaster 
Request: Send a blank email to php-webmaster+get-17904@lists.php.net to get a copy of this message
Commit: 72e7bc7e2e8c1531026dc88c651c7aebd281d954 Author: Hannes Magnusson <bjori@mongodb.com> Sun, 29 Dec 2013 21:02:52 -0800 Parents: 6e9e1f30d24695315c2b08e20a040d0fb8b6974d Branches: master Link: http://git.php.net/?p=web/people.git;a=commitdiff;h=72e7bc7e2e8c1531026dc88c651c7aebd281d954 Log: Fetch all users once and cache it rather then making slow request per user Changed paths: M include/misc.php Diff: diff --git a/include/misc.php b/include/misc.php index 8d5e970..49825f4 100644 --- a/include/misc.php +++ b/include/misc.php @@ -24,15 +24,8 @@ function findPHPUser($username) if (!$token) { $token = trim(file_get_contents("token")); } - $retval = cached("https://master.php.net/fetch/user.php?username=" . $username . "&token=" . rawurlencode($token), false, $ctx); - if (!$retval) { - $error = error_get_last(); - // Remove the function name, arguments and all that stuff... we - // really only care about whatever comes after the last colon - $message = explode(":", $error["message"]); - $errmsg = array_pop($message); - error($errmsg); - } + $url = "https://master.php.net/fetch/allusers.php?token=" . rawurlencode($token); + $retval = cached($url, false, $ctx); $json = json_decode($retval, true); if (!is_array($json)) { error("Something happend to master"); @@ -40,7 +33,13 @@ function findPHPUser($username) if (isset($json["error"])) { error($json["error"]); } - return $json; + + foreach($json as $k) { + if ($k["username"] == $username) { + return $k; + } + } + error("No such user"); } function findGitHubUser($fullname)

« previous php.webmaster (#17904) next »