Array reset warning prevents pagination

Created on 24 June 2021, over 3 years ago
Updated 27 July 2023, about 1 year ago

Problem/Motivation

Making a GET request via the module throws a PHP Warning:

Warning: reset() expects parameter 1 to be array, string given in Canvas->_getNextURL() (line 125 of /var/www/html/sites/all/modules/contrib/canvas_api/includes/canvas_api.inc).

This is due to the fact that the "link" header returned by the API is a string, not an array. As a result, the _getNextURL() method of the Canvas object never returns a value an no data beyond the first page of results is gathered.

Additionally, when the reset() call is bypassed, the iterative API call for further results fails due to an old function call: `$this->client->get()` that is no longer present in the class.

Steps to reproduce

Make a GET API call with display errors on; PHP Warning is thrown and only the first page of results is returned.

Proposed resolution

Treat link header like a string instead of array; fix deprecated class method.

Remaining tasks

Post a patch.

User interface changes

None

API changes

None

Data model changes

See patch.

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States tkiehne

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024