2

Any ideas why this happens?

Can't find the row containing 'core_course_get_course_content_items' in the column 'name' even if the column with id=76 contains exactly that string in 'name'. Trying to UPDATE the row with the same string, doesn't update the row ('Rows matched: 1 Changed: 0 Warnings: 0')

MariaDB [moodle]> SELECT name FROM mdl_external_functions WHERE id = 76;
+--------------------------------------+
| name                                 |
+--------------------------------------+
| core_course_get_course_content_items |
+--------------------------------------+
1 row in set (0.000 sec)

MariaDB [moodle]> SELECT * FROM mdl_external_functions WHERE name = 'core_course_get_course_content_items';
Empty set (0.000 sec)

MariaDB [moodle]> UPDATE mdl_external_functions SET name = 'core_course_get_course_content_items' WHERE id = 76;
Query OK, 0 rows affected (0.000 sec)
Rows matched: 1  Changed: 0  Warnings: 0

TABLE

CREATE TABLE `mdl_external_functions` (
  `id` bigint(10) NOT NULL AUTO_INCREMENT,
  `name` varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `classname` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `methodname` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `classpath` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `component` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
  `capabilities` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `services` varchar(1333) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `mdl_extefunc_nam_uix` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=627 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci

Compare both with HEX:

MariaDB [moodle]> SELECT HEX(name) FROM mdl_external_functions WHERE id = 76;
+--------------------------------------------------------------------------+
| HEX(name)                                                                |
+--------------------------------------------------------------------------+
| 636F72655F636F757273655F6765745F636F757273655F636F6E74656E745F6974656D73 |
+--------------------------------------------------------------------------+
1 row in set (0.000 sec)

MariaDB [moodle]> SELECT HEX('core_course_get_course_content_items');
+--------------------------------------------------------------------------+
| HEX('core_course_get_course_content_items')                              |
+--------------------------------------------------------------------------+
| 636F72655F636F757273655F6765745F636F757273655F636F6E74656E745F6974656D73 |
+--------------------------------------------------------------------------+
1 row in set (0.000 sec)

Screenshot of the Error in Moodle:

Request

Response

After setting the Log Level to Developer in Moodle got the following:

error            : Can't find data record in database table external_functions.
errorcode        : invalidrecord
stacktrace       : * line 1646 of /lib/dml/moodle_database.php: dml_missing_record_exception thrown
                   * line 1622 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()
                   * line 73 of /lib/externallib.php: call to moodle_database->get_record()
                   * line 196 of /lib/externallib.php: call to external_api::external_function_info()
                   * line 81 of /lib/ajax/service.php: call to external_api::call_external_function()

debuginfo        : SELECT * FROM {external_functions} WHERE name = ?
                   [array (
                     0 => 'core_course_get_course_content_items',
                   )]
                   Error code: invalidrecord

Probably not the best thing to do, but I just did the following and it works now:

MariaDB [moodle]> UPDATE mdl_external_functions SET name = 'abc' WHERE id = 76;
Query OK, 1 row affected (0.014 sec)
Rows matched: 1  Changed: 1  Warnings: 0

MariaDB [moodle]> UPDATE mdl_external_functions SET name = 'core_course_get_course_content_items' WHERE id = 76;
Query OK, 1 row affected (0.001 sec)
Rows matched: 1  Changed: 1  Warnings: 0
albertost
  • 21
  • 2
  • 1
    are you sure there aren't spaces at the end? – dcolazin Feb 04 '22 at 13:17
  • What's the data type of `name`? `CHAR` or `VARCHAR`? Is this a system table or a table you created? Please share the `CREATE TABLE ...` statement. – The Impaler Feb 04 '22 at 13:17
  • 1
    VARCHAR(200). No space at the end. I compared the output of SELECT HEX(name) FROM mdl_external_functions WHERE id = 76; and SELECT HEX('core_course_get_course_content_items'); both are the same – albertost Feb 04 '22 at 14:30
  • 1
    @TheImpaler CREATE TABLE added. It's a table created by a webapplication (Moodle) – albertost Feb 04 '22 at 15:28
  • @albertost Must be the client app/terminal UI. It works well for me; see fiddle at https://www.db-fiddle.com/f/bp5pKU9tacRcredw2oDUa5/0 – The Impaler Feb 04 '22 at 15:56
  • @theimpaler There is an error in the application and I can't find the row using SELECT/WHERE in the console either. I will add a screenshot. – albertost Feb 04 '22 at 16:04
  • Give it a try with the LIKE condition. – Prasanna T Feb 05 '22 at 06:39
  • 1
    Can you switch the debug level to DEVELOPER in Moodle - this will give more details about the error. Site administration > Development > Debugging - https://docs.moodle.org/310/en/Debugging#Enabling_debugging – Russell England Feb 05 '22 at 07:20
  • Shouldn't you be using `nvarchar` rather than `varchar` , as you appear to be using unicode text strings. – ChrisBD Feb 07 '22 at 10:59
  • @ChrisBD not sure. The table was created by Moodle. I installed the same version of Moodle on another server with MySQL and everything looks normal there. It seems to be related to MariaDB (10.5.13). – albertost Feb 07 '22 at 22:53
  • What's changed between your first attempt to set the `name` field and your last? Does this mean that your original problem has gone? – ChrisBD Feb 08 '22 at 08:33
  • @ChrisBD : yes, the problem is now gone. The first time I tried to set name to the same string 'core_course_get_course_content_items', but the it wasn't really changed or overwritten -> 'Rows matched: 1 Changed: 0 Warnings: 0'. The second time, I set it to something else first ('abc') and then to the string 'core_course_get_course_content_items'. – albertost Feb 08 '22 at 14:04

0 Answers0