@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.

In summary interfaces, don't render very large inline remarkup details for unit test messages

Summary: Ref T10635. An install with large blocks of remarkup (4MB) in test details is reporting slow page rendering. This is expected, but I've mostly given up on fighting this unless I absolutely have to. Degrade the interface more aggressively.

Test Plan:
- Submitted a large block of test details in remarkup format.
- Before patch: they rendered inline.
- After patch: degraded display.
- Verified small blocks are not changed.

{F7180727}

{F7180728}

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T10635

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

+81 -9
+78 -6
src/applications/harbormaster/storage/build/HarbormasterBuildUnitMessage.php
··· 179 179 180 180 $is_text = ($format !== self::FORMAT_REMARKUP); 181 181 $is_remarkup = ($format === self::FORMAT_REMARKUP); 182 + $message = null; 182 183 183 184 $full_details = $this->getUnitMessageDetails(); 185 + $byte_length = strlen($full_details); 184 186 185 - if (!strlen($full_details)) { 187 + $text_limit = 1024 * 2; 188 + $remarkup_limit = 1024 * 8; 189 + 190 + if (!$byte_length) { 186 191 if ($summarize) { 187 192 return null; 188 193 } 189 - $details = phutil_tag('em', array(), pht('No details provided.')); 194 + $message = phutil_tag('em', array(), pht('No details provided.')); 190 195 } else if ($summarize) { 191 196 if ($is_text) { 192 197 $details = id(new PhutilUTF8StringTruncator()) 193 - ->setMaximumBytes(2048) 198 + ->setMaximumBytes($text_limit) 194 199 ->truncateString($full_details); 195 200 $details = phutil_split_lines($details); 196 201 ··· 201 206 202 207 $details = implode('', $details); 203 208 } else { 204 - $details = $full_details; 209 + if ($byte_length > $remarkup_limit) { 210 + $uri = $this->getURI(); 211 + 212 + if ($uri) { 213 + $link = phutil_tag( 214 + 'a', 215 + array( 216 + 'href' => $uri, 217 + 'target' => '_blank', 218 + ), 219 + pht('View Details')); 220 + } else { 221 + $link = null; 222 + } 223 + 224 + $message = array(); 225 + $message[] = phutil_tag( 226 + 'em', 227 + array(), 228 + pht('This test has too much data to display inline.')); 229 + if ($link) { 230 + $message[] = $link; 231 + } 232 + 233 + $message = phutil_implode_html(" \xC2\xB7 ", $message); 234 + } else { 235 + $details = $full_details; 236 + } 205 237 } 206 238 } else { 207 239 $details = $full_details; ··· 212 244 $classes = array(); 213 245 $classes[] = 'harbormaster-unit-details'; 214 246 215 - if ($is_remarkup) { 247 + if ($message !== null) { 248 + // If we have a message, show that instead of rendering any test details. 249 + $details = $message; 250 + } else if ($is_remarkup) { 216 251 $details = new PHUIRemarkupView($viewer, $details); 217 252 } else { 218 253 $classes[] = 'harbormaster-unit-details-text'; 219 254 $classes[] = 'PhabricatorMonospaced'; 220 255 } 221 256 222 - return phutil_tag( 257 + $warning = null; 258 + if (!$summarize) { 259 + $warnings = array(); 260 + 261 + if ($is_remarkup && ($byte_length > $remarkup_limit)) { 262 + $warnings[] = pht( 263 + 'This test result has %s bytes of Remarkup test details. Remarkup '. 264 + 'blocks longer than %s bytes are not rendered inline when showing '. 265 + 'test summaries.', 266 + new PhutilNumber($byte_length), 267 + new PhutilNumber($remarkup_limit)); 268 + } 269 + 270 + if ($warnings) { 271 + $warning = id(new PHUIInfoView()) 272 + ->setSeverity(PHUIInfoView::SEVERITY_WARNING) 273 + ->setErrors($warnings); 274 + } 275 + } 276 + 277 + $content = phutil_tag( 223 278 'div', 224 279 array( 225 280 'class' => implode(' ', $classes), 226 281 ), 227 282 $details); 283 + 284 + return array( 285 + $warning, 286 + $content, 287 + ); 228 288 } 229 289 230 290 public function getUnitMessageDisplayName() { ··· 260 320 ); 261 321 262 322 return implode("\0", $parts); 323 + } 324 + 325 + public function getURI() { 326 + $id = $this->getID(); 327 + 328 + if (!$id) { 329 + return null; 330 + } 331 + 332 + return urisprintf( 333 + '/harbormaster/unit/view/%d/', 334 + $id); 263 335 } 264 336 265 337 public function save() {
+3 -3
src/applications/harbormaster/view/HarbormasterUnitPropertyView.php
··· 72 72 } 73 73 74 74 $name = $message->getUnitMessageDisplayName(); 75 - $id = $message->getID(); 75 + $uri = $message->getURI(); 76 76 77 - if ($id) { 77 + if ($uri) { 78 78 $name = phutil_tag( 79 79 'a', 80 80 array( 81 - 'href' => "/harbormaster/unit/view/{$id}/", 81 + 'href' => $uri, 82 82 ), 83 83 $name); 84 84 }