Skip to content

Commit ec9ebe5

Browse files
committedMay 29, 2023
Addressing some PHP 8 incompatibilities - Remarkup
Summary: Updating compatibility for PHP 8.2 for remarkup-related functionality. This also resolves an issue introduced by https://secure.phabricator.com/D21860. Of all the flags when opening the zip the one I chose was not introduced in 5.2 but in 7.4 Test Plan: I rendered comments using figlet, cowsay, images, object references. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin, epriestley Differential Revision: https://secure.phabricator.com/D21866
1 parent ce3d484 commit ec9ebe5

File tree

5 files changed

+18
-9
lines changed

5 files changed

+18
-9
lines changed
 

‎.editorconfig

+7-7
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,25 @@ insert_final_newline = true
1010
max_line_length = 80
1111

1212
[.arclint]
13-
max_line_length =
13+
max_line_length = unset
1414

1515
[resources/sql/**.sql]
16-
max_line_length =
16+
max_line_length = unset
1717

1818
[scripts/install/install_*.sh]
19-
max_line_length =
19+
max_line_length = unset
2020

2121
[src/applications/differential/parser/__tests__/data/*.diff]
2222
trim_trailing_whitespace = false
2323

2424
[src/applications/differential/parser/__tests__/messages/long-title.txt]
25-
max_line_length =
25+
max_line_length = unset
2626

2727
[src/applications/diffusion/ssh/__tests__/hgwiredata/*.txt]
28-
max_line_length =
28+
max_line_length = unset
2929

3030
[externals/**]
31-
indent_style =
32-
indent_size =
31+
indent_style = unset
32+
indent_size = unset
3333
trim_trailing_whitespace = false
3434
insert_final_newline = false

‎externals/pear-figlet/Text/Figlet.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,12 @@ function loadFont($filename, $loadgerman = true)
143143
fclose($fp);
144144

145145
$zip = new ZipArchive();
146-
$open_result = $zip->open($filename, ZipArchive::RDONLY);
146+
$open_flag = 0;
147+
// The RDONLY flag was only introduced in 7.4.3.
148+
if (defined('ZipArchive::RDONLY')) {
149+
$open_flag = ZipArchive::RDONLY;
150+
}
151+
$open_result = $zip->open($filename, $open_flag);
147152
if ($open_result !== true) {
148153
return self::raiseError('Cannot open figlet font file ' .
149154
$filename . ', got error: ' . $open_result, 2);

‎src/infrastructure/markup/interpreter/PhabricatorRemarkupCowsayBlockInterpreter.php

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public function markupContent($content, array $argv) {
1515
$map = self::getCowMap();
1616

1717
$cow = idx($argv, 'cow');
18+
$cow = ($cow === null ? '' : $cow);
1819
$cow = phutil_utf8_strtolower($cow);
1920
if (empty($map[$cow])) {
2021
$cow = 'default';

‎src/infrastructure/markup/interpreter/PhabricatorRemarkupFigletBlockInterpreter.php

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public function markupContent($content, array $argv) {
1414
$map = self::getFigletMap();
1515

1616
$font = idx($argv, 'font');
17+
$font = ($font === null ? '' : $font);
1718
$font = phutil_utf8_strtolower($font);
1819
if (empty($map[$font])) {
1920
$font = 'standard';

‎src/infrastructure/markup/remarkup/PhutilRemarkupEngine.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,9 @@ private function splitTextIntoBlocks($text, $depth = 0) {
232232

233233
$lines = '';
234234
for ($ii = $min; $ii < $max; $ii++) {
235-
$lines .= $text[$ii];
235+
if (isset($text[$ii])) {
236+
$lines .= $text[$ii];
237+
}
236238
}
237239

238240
$blocks[$key]['text'] = $lines;

0 commit comments

Comments
 (0)
Failed to load comments.