SQL:Can't find row with SELECT WHERE (VARCHAR column) Moodle: Error "Can't find data record in database table external_functions."

Viewed 217

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
0 Answers
Related