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

Memes: Do not pass a null string to imagettfbbox() for above or below parameter

Summary:
`imagettfbbox()` expects a string as its 4th parameter but people can construct URIs with the expected string parameter missing.
Thus check first via `phutil_nonempty_string()`.

```
ERROR 8192: imagettfbbox(): Passing null to parameter #4 ($string) of type string is deprecated at [/var/www/html/phorge/phorge/src/applications/macro/engine/PhabricatorMemeEngine.php:335]
```

Closes T16318

Test Plan:
* Go to http://phorge.localhost/macro/meme/?__path__=%2fmacro%2fmeme%2f&above=above&macro=baoanan and make sure the "macro" parameter is an existing meme
* Get a PhutilAggregateException followup exception instead (for different reasons)

Reviewers: O1 Blessed Committers, avivey

Reviewed By: O1 Blessed Committers, avivey

Subscribers: avivey, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T16318

Differential Revision: https://we.phorge.it/D26447

+19 -17
+19 -17
src/applications/macro/engine/PhabricatorMemeEngine.php
··· 332 332 $all_fit = true; 333 333 $text_metrics = array(); 334 334 foreach ($texts as $key => $text) { 335 - $box = imagettfbbox($cursor, 0, $font, $text); 336 - $height = abs($box[3] - $box[5]); 337 - $width = abs($box[0] - $box[2]); 335 + if (phutil_nonempty_string($text)) { 336 + $box = imagettfbbox($cursor, 0, $font, $text); 337 + $height = abs($box[3] - $box[5]); 338 + $width = abs($box[0] - $box[2]); 338 339 339 - // This is the number of pixels below the baseline that the 340 - // text extends, for example if it has a "y". 341 - $descend = $box[3]; 340 + // This is the number of pixels below the baseline that the 341 + // text extends, for example if it has a "y". 342 + $descend = $box[3]; 342 343 343 - if (($height + $margin_y) > $dim_y) { 344 - $all_fit = false; 345 - break; 346 - } 344 + if (($height + $margin_y) > $dim_y) { 345 + $all_fit = false; 346 + break; 347 + } 347 348 348 - if (($width + $margin_x) > $dim_x) { 349 - $all_fit = false; 350 - break; 351 - } 349 + if (($width + $margin_x) > $dim_x) { 350 + $all_fit = false; 351 + break; 352 + } 352 353 353 - $text_metrics[$key]['width'] = $width; 354 - $text_metrics[$key]['height'] = $height; 355 - $text_metrics[$key]['descend'] = $descend; 354 + $text_metrics[$key]['width'] = $width; 355 + $text_metrics[$key]['height'] = $height; 356 + $text_metrics[$key]['descend'] = $descend; 357 + } 356 358 } 357 359 358 360 if ($all_fit || $best === null) {