← Back to team overview

mahara-contributors team mailing list archive

[Bug 1966816] [NEW] Uggrading causes an error around the supportadmin filed not being present

 

Public bug reported:

When trying to upgrade from an older version we can encounter this problem at the step
lib/db/upgrade.php line 2276 - Updating description text block image src attributes missing text parameter in url

Failed to get a recordset: postgres9 error: [-1: ERROR:  column
u.supportadmin does not exist

This is because the upgrade step that happens at 2021121500 calls a
function that has a change in it for support admins but the db column
isn't added until 2022031500

We need to adjust the function to only contain the new db column once
site is newer than 2022031500

diff --git a/htdocs/lib/user.php b/htdocs/lib/user.php
index 1f3be84148..cc4cdf19f9 100644
--- a/htdocs/lib/user.php
+++ b/htdocs/lib/user.php
@@ -1981,9 +1981,13 @@ function load_user_institutions($userid) {
 
     $logoxs = db_column_exists('institution', 'logoxs') ? ',i.logoxs' : '';
     $tags = db_column_exists('institution', 'tags') ? ',i.tags' : '';
+    $supportadmin = '';
+    if (get_config('version') > 2022031500) {
+        $supportadmin = ' u.supportadmin,';
+    }
     if ($userid !== 0 && $institutions = get_records_sql_assoc('
         SELECT u.institution, ' . db_format_tsfield('ctime') . ',' . db_format_tsfield('u.expiry', 'membership_expiry') . ',
-               u.studentid, u.staff, u.admin, u.supportadmin, i.displayname, i.theme, i.registerallowed, i.showonlineusers,
+               u.studentid, u.staff, u.admin,' . $supportadmin . ' i.displayname, i.theme, i.registerallowed, i.showonlineusers,
                i.allowinstitutionpublicviews, i.logo' . $logoxs . ', i.style, i.licensemandatory, i.licensedefault,
                i.dropdownmenu, i.skins, i.suspended' . $tags . '
         FROM {usr_institution} u INNER JOIN {institution} i ON u.institution = i.name

** Affects: mahara
     Importance: High
         Status: Confirmed

** Changed in: mahara
   Importance: Undecided => High

** Changed in: mahara
    Milestone: None => 22.04.0

** Changed in: mahara
       Status: New => Confirmed

-- 
You received this bug notification because you are a member of Mahara
Contributors, which is subscribed to Mahara.
Matching subscriptions: mahara-contributors
https://bugs.launchpad.net/bugs/1966816

Title:
  Uggrading causes an error around the supportadmin filed not being
  present

Status in Mahara:
  Confirmed

Bug description:
  When trying to upgrade from an older version we can encounter this problem at the step
  lib/db/upgrade.php line 2276 - Updating description text block image src attributes missing text parameter in url

  Failed to get a recordset: postgres9 error: [-1: ERROR:  column
  u.supportadmin does not exist

  This is because the upgrade step that happens at 2021121500 calls a
  function that has a change in it for support admins but the db column
  isn't added until 2022031500

  We need to adjust the function to only contain the new db column once
  site is newer than 2022031500

  diff --git a/htdocs/lib/user.php b/htdocs/lib/user.php
  index 1f3be84148..cc4cdf19f9 100644
  --- a/htdocs/lib/user.php
  +++ b/htdocs/lib/user.php
  @@ -1981,9 +1981,13 @@ function load_user_institutions($userid) {
   
       $logoxs = db_column_exists('institution', 'logoxs') ? ',i.logoxs' : '';
       $tags = db_column_exists('institution', 'tags') ? ',i.tags' : '';
  +    $supportadmin = '';
  +    if (get_config('version') > 2022031500) {
  +        $supportadmin = ' u.supportadmin,';
  +    }
       if ($userid !== 0 && $institutions = get_records_sql_assoc('
           SELECT u.institution, ' . db_format_tsfield('ctime') . ',' . db_format_tsfield('u.expiry', 'membership_expiry') . ',
  -               u.studentid, u.staff, u.admin, u.supportadmin, i.displayname, i.theme, i.registerallowed, i.showonlineusers,
  +               u.studentid, u.staff, u.admin,' . $supportadmin . ' i.displayname, i.theme, i.registerallowed, i.showonlineusers,
                  i.allowinstitutionpublicviews, i.logo' . $logoxs . ', i.style, i.licensemandatory, i.licensedefault,
                  i.dropdownmenu, i.skins, i.suspended' . $tags . '
           FROM {usr_institution} u INNER JOIN {institution} i ON u.institution = i.name

To manage notifications about this bug go to:
https://bugs.launchpad.net/mahara/+bug/1966816/+subscriptions



Follow ups