<feed xmlns='http://www.w3.org/2005/Atom'>
<title>BNW/sourcecodes, branch main</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<id>http://git.genenetwork.org/BNW/atom?h=main</id>
<link rel='self' href='http://git.genenetwork.org/BNW/atom?h=main'/>
<link rel='alternate' type='text/html' href='http://git.genenetwork.org/BNW/'/>
<updated>2026-08-24T19:33:26+00:00</updated>
<entry>
<title>Make all shell scripts executable.</title>
<updated>2026-08-24T19:33:26+00:00</updated>
<author>
<name>Frederick Muriuki Muriithi</name>
</author>
<published>2026-08-24T19:33:26+00:00</published>
<link rel='alternate' type='text/html' href='http://git.genenetwork.org/BNW/commit/?id=f7d65f6afb6867250aaa9e43d65d86af807bd552'/>
<id>urn:sha1:f7d65f6afb6867250aaa9e43d65d86af807bd552</id>
<content type='text'>
The code needs the shell scripts to be executable, otherwise the code
will raise an error (Permission Denied).
</content>
</entry>
<entry>
<title>Use new `runTerminalCommand()` wrapper to run commands.</title>
<updated>2026-08-24T19:26:00+00:00</updated>
<author>
<name>Frederick Muriuki Muriithi</name>
</author>
<published>2026-08-24T19:26:00+00:00</published>
<link rel='alternate' type='text/html' href='http://git.genenetwork.org/BNW/commit/?id=a08f24c69d35f3e82291fa4051f787964ec7bc9c'/>
<id>urn:sha1:a08f24c69d35f3e82291fa4051f787964ec7bc9c</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Add a wrapper around `proc_open(...)` to use for terminal commands.</title>
<updated>2026-08-24T18:18:34+00:00</updated>
<author>
<name>Frederick Muriuki Muriithi</name>
</author>
<published>2026-08-24T15:48:03+00:00</published>
<link rel='alternate' type='text/html' href='http://git.genenetwork.org/BNW/commit/?id=d1e617f31c2ed2900845b7ea806ab5ee647d4de0'/>
<id>urn:sha1:d1e617f31c2ed2900845b7ea806ab5ee647d4de0</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Bugfix: Fix path.</title>
<updated>2026-08-18T18:23:15+00:00</updated>
<author>
<name>Frederick Muriuki Muriithi</name>
</author>
<published>2026-08-18T18:22:53+00:00</published>
<link rel='alternate' type='text/html' href='http://git.genenetwork.org/BNW/commit/?id=6254c4b441fdbebd09e3774b9cc5d6e13a829e37'/>
<id>urn:sha1:6254c4b441fdbebd09e3774b9cc5d6e13a829e37</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Bugfix: Check that key exists before use.</title>
<updated>2026-08-18T15:05:32+00:00</updated>
<author>
<name>Frederick Muriuki Muriithi</name>
</author>
<published>2026-08-18T15:05:32+00:00</published>
<link rel='alternate' type='text/html' href='http://git.genenetwork.org/BNW/commit/?id=47e8ac233a64ad578719bd31bb24a53940e21771'/>
<id>urn:sha1:47e8ac233a64ad578719bd31bb24a53940e21771</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Bugfix: Move variable closer to usage.</title>
<updated>2026-08-18T15:03:21+00:00</updated>
<author>
<name>Frederick Muriuki Muriithi</name>
</author>
<published>2026-08-18T15:03:21+00:00</published>
<link rel='alternate' type='text/html' href='http://git.genenetwork.org/BNW/commit/?id=02c5eef4ae43c0d78ff87fb74865d087843b7484'/>
<id>urn:sha1:02c5eef4ae43c0d78ff87fb74865d087843b7484</id>
<content type='text'>
Initialise the `$TextFile` variable within the handling of the "POST"
request rather than in the global scope.
</content>
</entry>
<entry>
<title>Fix undefined $TextinFile/$keyval in bn_after_upload_gom.php</title>
<updated>2026-08-17T19:53:37+00:00</updated>
<author>
<name>Claude Sonnet 5</name>
</author>
<published>2026-08-17T19:34:21+00:00</published>
<link rel='alternate' type='text/html' href='http://git.genenetwork.org/BNW/commit/?id=9f820106d932ba6952a30d6165bc1d42a1fb7ab6'/>
<id>urn:sha1:9f820106d932ba6952a30d6165bc1d42a1fb7ab6</id>
<content type='text'>
$TextinFile was passed to move_uploaded_file() as its $to argument, but
its assignment (and the $keyval/$sid/$dir it depends on) was commented
out, so $TextinFile was always null/undefined here -- an upload
through this page could never succeed even on PHP 7.4, and on PHP 8.1+
it also triggers "Passing null to parameter #1 ($to)... is deprecated".
$keyval was similarly used (e.g. in the hidden My_key form field)
before it was ever assigned, causing an "Undefined variable" warning
that could leak into an unquoted HTML attribute if display_errors is on.

Unlike bn_file_load_gom.php (a fresh-upload entry point that mints a
new random key), this page is only reached via a redirect from
modify_structure_learning.php with an existing My_key already in the
query string. Restored the commented-out block, adapted to read
$keyval from $_GET (matching how the rest of this file already does it
further down) instead of generating a new one, so $TextinFile is a
real path before the upload block runs.

Verified empirically against PHP 8.3.28: simulating an upload request
now correctly reaches move_uploaded_file() with a real path and falls
into the file's own pre-existing "Sorry, error uploading" handling
instead of silently failing on a null argument.

Reviewed by: Frederick M Muriithi &lt;fredmanglis@gmail.com&gt;
</content>
</entry>
<entry>
<title>Guard arithmetic on file/shell-output-derived values against non-numeric strings</title>
<updated>2026-08-17T19:53:21+00:00</updated>
<author>
<name>Claude Sonnet 5</name>
</author>
<published>2026-08-17T19:32:03+00:00</published>
<link rel='alternate' type='text/html' href='http://git.genenetwork.org/BNW/commit/?id=a1f64bda77d74026d663eca91b975a6ff869d9a3'/>
<id>urn:sha1:a1f64bda77d74026d663eca91b975a6ff869d9a3</id>
<content type='text'>
PHP 8 throws a fatal TypeError for arithmetic (+ - * /) on a
non-numeric string ("Unsupported operand types"); PHP 7.4 only warned
and treated it as 0. Several files perform arithmetic directly on
values parsed from intermediate state files (nnode.txt, nrows.txt,
structure_input*.txt) or from `dot -Tplain` output, with no
is_numeric() check — safe as long as those files are well-formed, but
a crash risk if a file is missing/empty/truncated or a `dot` output
line doesn't parse as expected.

Affected: runtime_check.php ($node, $nrows), remove_variables.php and
create_tiers_gom_part1.php ($maxplist=$node-1), mat_structure.php
(matrix cell multiplication), and the four network_layout_{evd,inv}[,_2].php
files ($r_index=$node+N and the dot-output-derived $cell arithmetic in
the _2 variants).

Fix pattern: coalesce to 0 via `is_numeric($x) ? $x : 0` before the
arithmetic, matching PHP 7.4's original fallback-to-0 behavior instead
of crashing.

Verified empirically against PHP 8.3.28 with runtime_check.php and
mat_structure.php: previously, a missing/empty source file caused
  TypeError: Unsupported operand types: string - int (or string * int)
after the fix, the same missing-file scenario produces only the
pre-existing "undefined array key" warnings (same as PHP 7.4) and the
function completes and returns a value instead of crashing.

Reviewed by: Frederick M Muriithi &lt;fredmanglis@gmail.com&gt;
</content>
</entry>
<entry>
<title>Guard fopen() results with a false-check before fwrite/fprintf/fclose</title>
<updated>2026-08-17T19:53:08+00:00</updated>
<author>
<name>Claude Sonnet 5</name>
</author>
<published>2026-08-17T19:26:43+00:00</published>
<link rel='alternate' type='text/html' href='http://git.genenetwork.org/BNW/commit/?id=9cae7ea19c7c744a1ed2bd997571ec1b516a0d32'/>
<id>urn:sha1:9cae7ea19c7c744a1ed2bd997571ec1b516a0d32</id>
<content type='text'>
On PHP 7.4, calling fwrite()/fprintf()/fclose() with a false handle
(a failed fopen(), e.g. from a bad path, missing directory, or
permissions issue) just emits a warning and no-ops. On PHP 8.0+, these
functions require a resource argument and throw an uncaught TypeError
instead, turning what used to be a silent degradation into a fatal
crash of the whole request.

This patch wraps every fopen()-then-write call site in the codebase
(18 files) with an `if ($handle !== false) { ... }` check, matching
the existing pattern used elsewhere in the codebase. Where the same
$fpvar handle is threaded through shared helper functions
(enter_ban_list/banlist/whitelist, duplicated across
remove_variables_processing.php, remove_variables_processing_default.php,
modify_structure_learning.php and tier_description_processing_gom.php),
the guard was added inside those functions too for consistency, even
though the call sites are currently dead/commented-out in three of the
four files — so the same landmine doesn't reappear if that code is
ever re-enabled.

Verified empirically against PHP 8.3.28: fopen() on an unwritable path
followed by fwrite() on the resulting `false` throws
  TypeError: fwrite(): Argument #1 ($stream) must be of type resource, false given
without the guard; with the guard, the call is skipped instead of
crashing. The normal (successful fopen) path was also re-run through
mat_structure.php's structure_change() and still produces identical
output to before the change.

Reviewed by: Frederick M Muriithi &lt;fredmanglis@gmail.com&gt;
</content>
</entry>
<entry>
<title>Guard valid_keyval()/valid_input() against null input (PHP 8.1 deprecation)</title>
<updated>2026-08-17T19:52:48+00:00</updated>
<author>
<name>Claude Sonnet 5</name>
</author>
<published>2026-08-17T19:09:41+00:00</published>
<link rel='alternate' type='text/html' href='http://git.genenetwork.org/BNW/commit/?id=4825da8e49c302392fe6018862dfcdd6f91c6192'/>
<id>urn:sha1:4825da8e49c302392fe6018862dfcdd6f91c6192</id>
<content type='text'>
These two functions are the single most common entry point in the
codebase — ~30+ files call them as valid_keyval($_GET["My_key"]) or
valid_input($_POST[...]) with no isset() guard at the call site. When
the key is absent, PHP passes null straight into trim(), which is a
non-nullable string parameter. As of PHP 8.1 this triggers a
"Passing null to parameter #1 ($string) ... is deprecated" notice on
every one of those call sites, on every request missing the param.

Coalescing to '' inside the two functions themselves fixes this once,
for every caller, instead of patching every call site individually.

Verified empirically against PHP 8.3.28: valid_keyval(null) /
valid_input(null) no longer emit the trim() deprecation notice and
still return '' as before (same effective behavior as PHP 7.4).

Reviewed by: Frederick M Muriithi &lt;fredmanglis@gmail.com&gt;
</content>
</entry>
</feed>
