Mahara installation issues with MySQL 8.0.17

Bug #1845228 reported by Jota Martos
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
High
Rebecca Blundell

Bug Description

Hi,

The latest version of Mahara (19.04.1) throws the following error when running the install.php script

```
[INF] fe (admin/cli/install.php:74) Installing Mahara
[INF] fe (lib/mahara.php:237) Installing core
[DBG] fe (lib/dml.php:157) mysqli error: [1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'member BIGINT(10) NOT NULL,
[DBG] fe (lib/dml.php:157) role VARCHAR(255) NOT NULL,
[DBG] fe (lib/dml.php:157) ctime DATETIME N' at line 3] in EXECUTE("CREATE TABLE group_member (
[DBG] fe (lib/dml.php:157) `group` BIGINT(10) NOT NULL,
[DBG] fe (lib/dml.php:157) member BIGINT(10) NOT NULL,
[DBG] fe (lib/dml.php:157) role VARCHAR(255) NOT NULL,
[DBG] fe (lib/dml.php:157) ctime DATETIME NOT NULL,
[DBG] fe (lib/dml.php:157) method VARCHAR(100) NOT NULL DEFAULT 'internal',
```

The command we run during the installation process is the following one:

```
php "/mahara_folder/admin/cli/install.php" --adminpassword=PASSWORD --adminemail=EMAIL
```

We are using the latest version of MySQL (8.0.17) as database and "member" is a reserved word from that version on.

https://dev.mysql.com/doc/refman/8.0/en/keywords.html

Regarding the OS, we detected this problem in Linux and Windows (OS X is probably affected as well).

Let me know if you need more information and if you have a workaround to install the application with this version of the database.

Thanks,
Jota

Changed in mahara:
status: New → Confirmed
Revision history for this message
Rebecca Blundell (rjb-dev) wrote :

Tested on Ubuntu 16.04 with PHP7.1 and Mahara 19.04.2testing

This is an issue as of mysql 8.0.17, as pointed out above. It runs fine in previous versions of mysql.

From:
https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-17.html

ARRAY and MEMBER now are reserved words and cannot be used as identifiers without identifier quoting.

This is a big problem as it prevents Mahara from installing under mysql.

Changed in mahara:
importance: Undecided → High
Changed in mahara:
assignee: nobody → Rebecca Blundell (rjb-dev)
Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

Patch for "master" branch: https://reviews.mahara.org/10380

Revision history for this message
Rebecca Blundell (rjb-dev) wrote :

There are a number of issues related to this version of mysql, not just to do with the new reserved words. The next one I encountered is that || is deprecated and OR must be used. This changelog needs to be worked through: https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-17.html

Changed in mahara:
milestone: none → 20.04.0
Changed in mahara:
status: Confirmed → In Progress
Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/10380
Committed: https://git.mahara.org/mahara/mahara/commit/e48f88ced5feae30aebedaa8301682ab5f73f457
Submitter: Robert Lyon (<email address hidden>)
Branch: master

commit e48f88ced5feae30aebedaa8301682ab5f73f457
Author: Rebecca Blundell <email address hidden>
Date: Thu Sep 26 13:49:07 2019 +1200

Bug 1845228: Make Mahara work with mysql 8.0.17

-Add mysql reserved words 'array' and 'member'
-Remove deprecated ||, &&, ! and replace with OR, AND, NOT
Note: Use of || is deprecated unless the PIPES_AS_CONCAT SQL mode is
enabled. In that case, || signifies the SQL-standard string
concatenation operator
-Quote uses of member in SQL queries
Note: when passed in as a variable it is quoted on query construction

behatnotneeded

Change-Id: I860bac5c44dab206b70a78215a5784e6f1fe3928

Robert Lyon (robertl-9)
Changed in mahara:
status: In Progress → Fix Committed
Revision history for this message
Karna Kitab Kumar (karnakitab) wrote :
Download full text (3.3 KiB)

PHP 7.4
MySQL 8.0.17

I installed mahara after applying patches mentioned here: https://bugs.launchpad.net/mahara/+bug/1845228

But upon going to .../admin/users/institutions.php the following error popped up (debug enabled):

```
[WAR] 29 (lib/errors.php:859) Failed to get a recordset: mysqli error: [1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '|| '' || '%'
            )
            OR (
                ii.displayname LIKE ' at line 4] in EXECUTE("SELECT COUNT(ii.name)
            FROM "home_institution" ii
            WHERE(
                ii.name LIKE '%' || '' || '%'
            )
            OR (
                ii.displayname LIKE '%' || '' || '%'
            )")Command was: SELECT COUNT(ii.name)
            FROM "home_institution" ii
            WHERE(
                ii.name LIKE '%' || ? || '%'
            )
            OR (
                ii.displayname LIKE '%' || ? || '%'
            ) and values was (0:,1:)
```

```
Call stack (most recent first):

    log_message("Failed to get a recordset: mysqli error: [1064: Yo...", 8, true, true) at /.../public_html/mahara/lib/errors.php:95
    log_warn("Failed to get a recordset: mysqli error: [1064: Yo...") at /.../public_html/mahara/lib/errors.php:859
    SQLException->__construct("Failed to get a recordset: mysqli error: [1064: Yo...") at /.../public_html/mahara/lib/dml.php:540
    get_recordset_sql("SELECT COUNT(ii.name) FROM "home_insti...", array(size 2)) at /.../public_html/mahara/lib/dml.php:299
    count_records_sql("SELECT COUNT(ii.name) FROM {institutio...", array(size 2)) at /.../public_html/mahara/lib/institution.php:889
    Institution::count_members(false, true, "", 10, 0, null) at /.../public_html/mahara/lib/institution.php:1100
    build_institutions_html(false, true, "", 10, 0, null) at /.../public_html/mahara/admin/users/institutions.php:703

```

```
[WAR] 29 (lib/dml.php:540) Failed to get a recordset: mysqli error: [1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '|| '' || '%'
            )
            OR (
                ii.displayname LIKE ' at line 4] in EXECUTE("SELECT COUNT(ii.name)
            FROM "home_institution" ii
            WHERE(
                ii.name LIKE '%' || '' || '%'
            )
            OR (
                ii.displayname LIKE '%' || '' || '%'
            )")Command was: SELECT COUNT(ii.name)
            FROM "home_institution" ii
            WHERE(
                ii.name LIKE '%' || ? || '%'
            )
            OR (
                ii.displayname LIKE '%' || ? || '%'
            ) and values was (0:,1:)
```

```
Call stack (most recent first):

    get_recordset_sql("SELECT COUNT(ii.name) FROM "home_insti...", array(size 2)) at /.../public_html/mahara/lib/dml.php:299
    count_records_sql("SELECT COUNT(ii.name) FROM {institutio...", array(size 2)) at /.../public_html/mahara/lib/institution.php:889
    Institution::count_members(false, true, "", 10, 0, null) at /.../public_html/mahara/lib/institution.php:1100
    build_institutions_html(false, tr...

Read more...

Changed in mahara:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.