Currently, null data is cached if a wrong username is given.
Enter a wrong username. The field would still save the data and cache the data with null.
Set the cache only if the data exists.
public function getUserInformation(string $doUsername): User {
$cid = 'do_username:user:' . $doUsername;
// Check if the data exist. If not, retrieve, save, and return.
$cachedData = $this->cache->get($cid);
if ($cachedData) {
return $cachedData->data;
}
$request = new UserCollectionRequest(["name" => $doUsername]);
$userData = $this->client->getEntity($request);
if ($userData->valid()) {
$this->cache->set($cid, $userData->current());
}
return $userData->current();
}
Closed: works as designed
1.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.