Issue maintenance

Issue maintenance script brought in by PR#1081 seems to have a feature to reference related encounters(?) or a specific form. However the query silently fails as forms.issue_id table is missing.

...
...
...
// Build html tab data for each visit form linked to this issue.
$tabcontents = '';
if ($issue) {
    $vres = sqlStatement(
        "SELECT f.id, f.encounter, f.form_name, f.form_id, f.formdir, fe.date " .
        "FROM forms AS f, form_encounter AS fe WHERE " .
        "f.pid = ? AND f.issue_id = ? AND f.deleted = 0 AND " .
        "fe.pid = f.pid and fe.encounter = f.encounter " .
        "ORDER BY fe.date DESC, f.id DESC",
        array($thispid, $issue)
    );
    while ($vrow = sqlFetchArray($vres)) {
        $formdir = $vrow['formdir'];
...
...
...

Any idea if the feature would be usable in standard code?

Hmm, forms.issue_id should be there. I see it in database.sql and sql/5_0_0-to-5_0_1_upgrade.sql.

Haven’t looked too close or can’t explain but I’v seen over the last several times I upgrade where upgrade will miss items. Forcing a second run.

I have a feeling sql_upgrade.php is not doing enough error checking.