← Back to team overview

mahara-contributors team mailing list archive

[Bug 1824386] [NEW] Inappropriate comparison for DB versions

 

Public bug reported:

Relevant code from htdocs/init.php

    if (is_postgres()) {
        $okversion = '8.3';
        $dbfriendlyname = 'PostgreSQL';
    }
    else if (is_mysql()) {
        $okversion = '5.0.25';
        $dbfriendlyname = 'MySQL';
    }
    if (floatval($dbversion['version']) <  floatval($okversion)) {
        throw new ConfigSanityException(get_string('dbversioncheckfailed', 'error', $dbfriendlyname, $dbversion['version'], $okversion));
    }


floatval() on those strings will return, at best, the major version number, and while I think it's unlikely that people are going to be running 19.04 on PGSQL 8.2, right now the system wouldn't be able to detect that.

Switching out to version_compare would be a proper and safe comparison
for this.

** Affects: mahara
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Mahara
Contributors, which is subscribed to Mahara.
Matching subscriptions: Subscription for all Mahara Contributors -- please ask on #mahara-dev or mahara.org forum before editing or unsubscribing it!
https://bugs.launchpad.net/bugs/1824386

Title:
  Inappropriate comparison for DB versions

Status in Mahara:
  New

Bug description:
  Relevant code from htdocs/init.php

      if (is_postgres()) {
          $okversion = '8.3';
          $dbfriendlyname = 'PostgreSQL';
      }
      else if (is_mysql()) {
          $okversion = '5.0.25';
          $dbfriendlyname = 'MySQL';
      }
      if (floatval($dbversion['version']) <  floatval($okversion)) {
          throw new ConfigSanityException(get_string('dbversioncheckfailed', 'error', $dbfriendlyname, $dbversion['version'], $okversion));
      }

  
  floatval() on those strings will return, at best, the major version number, and while I think it's unlikely that people are going to be running 19.04 on PGSQL 8.2, right now the system wouldn't be able to detect that.

  Switching out to version_compare would be a proper and safe comparison
  for this.

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


Follow ups