@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Bulk load builtin project default profile images

Summary: Depends on D19221. Ref T13106. When we fall back to default profile images for projects, bulk load them instead of doing individual queries.

Test Plan: Saw local task drop from 199 queries to 151 queries with the same actual outcome. Saw custom and default profile images on the project list page.

Maniphest Tasks: T13106

Differential Revision: https://secure.phabricator.com/D19222

+53 -13
+53 -13
src/applications/project/query/PhabricatorProjectQuery.php
··· 357 357 } 358 358 359 359 protected function didFilterPage(array $projects) { 360 + $viewer = $this->getViewer(); 361 + 360 362 if ($this->needImages) { 361 - $file_phids = mpull($projects, 'getProfileImagePHID'); 362 - $file_phids = array_filter($file_phids); 363 + $need_images = $projects; 364 + 365 + // First, try to load custom profile images for any projects with custom 366 + // images. 367 + $file_phids = array(); 368 + foreach ($need_images as $key => $project) { 369 + $image_phid = $project->getProfileImagePHID(); 370 + if ($image_phid) { 371 + $file_phids[$key] = $image_phid; 372 + } 373 + } 374 + 363 375 if ($file_phids) { 364 376 $files = id(new PhabricatorFileQuery()) 365 377 ->setParentQuery($this) 366 - ->setViewer($this->getViewer()) 378 + ->setViewer($viewer) 367 379 ->withPHIDs($file_phids) 368 380 ->execute(); 369 381 $files = mpull($files, null, 'getPHID'); 370 - } else { 371 - $files = array(); 382 + 383 + foreach ($file_phids as $key => $image_phid) { 384 + $file = idx($files, $image_phid); 385 + if (!$file) { 386 + continue; 387 + } 388 + 389 + $need_images[$key]->attachProfileImageFile($file); 390 + unset($need_images[$key]); 391 + } 372 392 } 373 393 374 - foreach ($projects as $project) { 375 - $file = idx($files, $project->getProfileImagePHID()); 376 - if (!$file) { 377 - $builtin = PhabricatorProjectIconSet::getIconImage( 378 - $project->getIcon()); 379 - $file = PhabricatorFile::loadBuiltin($this->getViewer(), 380 - 'projects/'.$builtin); 394 + // For projects with default images, or projects where the custom image 395 + // failed to load, load a builtin image. 396 + if ($need_images) { 397 + $builtin_map = array(); 398 + $builtins = array(); 399 + foreach ($need_images as $key => $project) { 400 + $icon = $project->getIcon(); 401 + 402 + $builtin_name = PhabricatorProjectIconSet::getIconImage($icon); 403 + $builtin_name = 'projects/'.$builtin_name; 404 + 405 + $builtin = id(new PhabricatorFilesOnDiskBuiltinFile()) 406 + ->setName($builtin_name); 407 + 408 + $builtin_key = $builtin->getBuiltinFileKey(); 409 + 410 + $builtins[] = $builtin; 411 + $builtin_map[$key] = $builtin_key; 381 412 } 382 - $project->attachProfileImageFile($file); 413 + 414 + $builtin_files = PhabricatorFile::loadBuiltins( 415 + $viewer, 416 + $builtins); 417 + 418 + foreach ($need_images as $key => $project) { 419 + $builtin_key = $builtin_map[$key]; 420 + $builtin_file = $builtin_files[$builtin_key]; 421 + $project->attachProfileImageFile($builtin_file); 422 + } 383 423 } 384 424 } 385 425