Webservices log shows errors

Bug #1694909 reported by Kristina Hoeppner
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Confirmed
Medium
Unassigned

Bug Description

seen on Mahara 17.04 with an upgraded database and 1 Mahara 17.04 with a few users, but not on 17.10master with a fresh database

When going to the Web services logs, I get the following error message:

[WAR] 77 (lib/errors.php:859) Failed to get a recordset: postgres8 error: [-1: ERROR: syntax error at end of input
LINE 1: SELECT "displayname" FROM "institution" WHERE "name" = ?
                                                                  ^] in EXECUTE("SELECT "displayname" FROM "institution" WHERE "name" = ? ")Command was: SELECT "displayname" FROM "institution" WHERE "name" = ?
Call stack (most recent first):

    log_message("Failed to get a recordset: postgres8 error: [-1: E...", 8, true, true) at /home/kristina/code/1704stable/htdocs/lib/errors.php:95
    log_warn("Failed to get a recordset: postgres8 error: [-1: E...") at /home/kristina/code/1704stable/htdocs/lib/errors.php:859
    SQLException->__construct("Failed to get a recordset: postgres8 error: [-1: E...") at /home/kristina/code/1704stable/htdocs/lib/dml.php:517
    get_recordset_sql("SELECT "displayname" FROM "institution" WHERE "na...", false) at /home/kristina/code/1704stable/htdocs/lib/dml.php:828
    get_field_sql("SELECT "displayname" FROM "institution" WHERE "na...", array(size 0)) at /home/kristina/code/1704stable/htdocs/lib/dml.php:816
    get_field("institution", "displayname", "name", null) at /home/kristina/code/1704stable/htdocs/lib/institution.php:997
    institution_display_name(null) at /home/kristina/code/1704stable/htdocs/webservice/admin/webservicessearchlib.php:222
    get_log_search_results(object(stdClass)) at /home/kristina/code/1704stable/htdocs/webservice/admin/webservicessearchlib.php:39
    build_webservice_log_search_results(object(stdClass)) at /home/kristina/code/1704stable/htdocs/webservice/admin/webservicelogs.php:53

[WAR] 77 (lib/dml.php:517) Failed to get a recordset: postgres8 error: [-1: ERROR: syntax error at end of input
LINE 1: SELECT "displayname" FROM "institution" WHERE "name" = ?
                                                                  ^] in EXECUTE("SELECT "displayname" FROM "institution" WHERE "name" = ? ")Command was: SELECT "displayname" FROM "institution" WHERE "name" = ?
Call stack (most recent first):

    get_recordset_sql("SELECT "displayname" FROM "institution" WHERE "na...", false) at /home/kristina/code/1704stable/htdocs/lib/dml.php:828
    get_field_sql("SELECT "displayname" FROM "institution" WHERE "na...", array(size 0)) at /home/kristina/code/1704stable/htdocs/lib/dml.php:816
    get_field("institution", "displayname", "name", null) at /home/kristina/code/1704stable/htdocs/lib/institution.php:997
    institution_display_name(null) at /home/kristina/code/1704stable/htdocs/webservice/admin/webservicessearchlib.php:222
    get_log_search_results(object(stdClass)) at /home/kristina/code/1704stable/htdocs/webservice/admin/webservicessearchlib.php:39
    build_webservice_log_search_results(object(stdClass)) at /home/kristina/code/1704stable/htdocs/webservice/admin/webservicelogs.php:53

Revision history for this message
Ghada El-Zoghbi (ghada-z) wrote :

I did a quick analysis.

A record is getting inserted into the external_services_logs table with institution = "".

Which means, that the $WEBSERVICE_INSTITUTION variable is not getting set correctly when the user is getting authenticated.

There are 3 places where this happens:
1. htdocs/webservice/lib.php:authenticate_user() line 946 <- not the issue as all data is correct in the usr / usr_institution tables.

2. htdocs/webservice/lib.php:authenticate_user() line 1001 <- not likely.

3. htdocs/webservice/lib.php:authenticate_by_token() line 1084 <- most likely is the issue.

I think it's in the authenticate_by_token() because when I did a query of the external_tokens table, the institution field was empty (not null but "").

It would be good to know the steps used when accessing the site via the webservice.

Revision history for this message
Kristina Hoeppner (kris-hoeppner) wrote :

Hi Ghada,

Thank you for the analysis. My local site isn't hooked up to web services but just has them enabled for testing.

The only web service we would have used on the other site would be the mobile api.

Cheers
Kristina

Changed in mahara:
importance: Undecided → Medium
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.