mahara-contributors team mailing list archive
-
mahara-contributors team
-
Mailing list archive
-
Message #53596
[Bug 1827445] [NEW] Improve efficiency when checking if a table field exists
Public bug reported:
When upgrading we use a field_exists() check to see if a table has a
certain column or not which is fine there as upgrade chunks are a one-
time execution run when users are all logged out.
However we have begun to use field_exists() within other parts of the
code and so this can get called on every page load by multiple users at
once. This requires fetching the ddl.lib file and setting ul an XMLDB
table object and an XMLDB field object which has overhead.
Instead we should just query the database directly and ask it if the
table has the column or not
So instead of doing:
require_once('ddl.php');
$table = new XMLDBTable('tablename');
$field = new XMLDBField('fieldname');
if (field_exists($table, $field)) {
...
}
We could just do:
if (column_exists('tablename', 'fieldname')) {
...
}
** 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/1827445
Title:
Improve efficiency when checking if a table field exists
Status in Mahara:
New
Bug description:
When upgrading we use a field_exists() check to see if a table has a
certain column or not which is fine there as upgrade chunks are a one-
time execution run when users are all logged out.
However we have begun to use field_exists() within other parts of the
code and so this can get called on every page load by multiple users
at once. This requires fetching the ddl.lib file and setting ul an
XMLDB table object and an XMLDB field object which has overhead.
Instead we should just query the database directly and ask it if the
table has the column or not
So instead of doing:
require_once('ddl.php');
$table = new XMLDBTable('tablename');
$field = new XMLDBField('fieldname');
if (field_exists($table, $field)) {
...
}
We could just do:
if (column_exists('tablename', 'fieldname')) {
...
}
To manage notifications about this bug go to:
https://bugs.launchpad.net/mahara/+bug/1827445/+subscriptions
Follow ups
-
[Bug 1827445] Re: Improve efficiency when checking if a table field exists
From: Cecilia Vela Gurovic, 2019-10-31
-
[Bug 1827445] A change has been merged
From: Mahara Bot, 2019-10-05
-
[Bug 1827445] A patch has been submitted for review
From: Mahara Bot, 2019-10-03
-
[Bug 1827445] A change has been merged
From: Mahara Bot, 2019-10-01
-
[Bug 1827445] A change has been merged
From: Mahara Bot, 2019-09-23
-
[Bug 1827445] Re: Improve efficiency when checking if a table field exists
From: Kristina Hoeppner, 2019-09-23
-
[Bug 1827445] A patch has been submitted for review
From: Mahara Bot, 2019-09-23
-
[Bug 1827445] A change has been merged
From: Mahara Bot, 2019-09-20
-
[Bug 1827445] A change has been merged
From: Mahara Bot, 2019-09-20
-
[Bug 1827445] Re: Improve efficiency when checking if a table field exists
From: Cecilia Vela Gurovic, 2019-09-20
-
[Bug 1827445] A patch has been submitted for review
From: Mahara Bot, 2019-09-04
-
[Bug 1827445] Re: Improve efficiency when checking if a table field exists
From: Kristina Hoeppner, 2019-05-03
-
[Bug 1827445] Re: Improve efficiency when checking if a table field exists
From: Robert Lyon, 2019-05-03
-
[Bug 1827445] Re: Improve efficiency when checking if a table field exists
From: Robert Lyon, 2019-05-03
-
[Bug 1827445] A patch has been submitted for review
From: Mahara Bot, 2019-05-03
-
[Bug 1827445] Re: Improve efficiency when checking if a table field exists
From: Robert Lyon, 2019-05-03