Skip to content
This repository was archived by the owner on Jul 17, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
LifterLMS REST API Changelog
============================

v1.0.5 - 2026-04-10
-------------------

##### Updates and Enhancements

+ Handle removal of depreciated SQL_CALC_FOUND_ROWS for counting query results.


v1.0.4 - 2026-04-10
-------------------

Expand Down
2 changes: 1 addition & 1 deletion class-lifterlms-rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class LifterLMS_REST_API {
*
* @var string
*/
public $version = '1.0.4';
public $version = '1.0.5';

/**
* Constructor.
Expand Down
4 changes: 2 additions & 2 deletions i18n/lifterlms-rest.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# This file is distributed under the GPLv3.
msgid ""
msgstr ""
"Project-Id-Version: LifterLMS REST API 1.0.4\n"
"Project-Id-Version: LifterLMS REST API 1.0.5\n"
"Report-Msgid-Bugs-To: https://lifterlms.com/my-account/my-tickets\n"
"Last-Translator: Team LifterLMS <team@lifterlms.com>\n"
"Language-Team: Team LifterLMS <team@lifterlms.com>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2026-04-10T12:22:26+00:00\n"
"POT-Creation-Date: 2026-04-10T13:45:41+00:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: llms/dev 0.2.1\n"
"X-Domain: lifterlms\n"
Expand Down
12 changes: 10 additions & 2 deletions includes/class-llms-rest-api-keys-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,24 @@ protected function parse_args() {
* @since 1.0.0-beta.1
* @since 1.0.0-beta.16 Use `$this->sql_select_columns({columns})` to determine the columns to select.
* @since 1.0.0-beta.22 Renamed from `preprare_query()`.
* @since 1.0.5 Set `$this->count_query` for found results without `SQL_CALC_FOUND_ROWS`.
*
* @return string
*/
protected function prepare_query() {

global $wpdb;

$from = "FROM {$wpdb->prefix}lifterlms_api_keys";
$where = $this->sql_where();

if ( ! $this->get( 'no_found_rows' ) ) {
$this->count_query = "SELECT COUNT(*) {$from} {$where}";
}

return "SELECT {$this->sql_select_columns( 'id' )}
FROM {$wpdb->prefix}lifterlms_api_keys
{$this->sql_where()}
{$from}
{$where}
{$this->sql_orderby()}
{$this->sql_limit()};";

Expand Down
12 changes: 10 additions & 2 deletions includes/class-llms-rest-webhooks-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,24 @@ protected function parse_args() {
* @since 1.0.0-beta.1
* @since 1.0.0-beta.16 Use `$this->sql_select_columns({columns})` to determine the columns to select.
* @since 1.0.0-beta.22 Renamed from `preprare_query()`.
* @since 1.0.5 Set `$this->count_query` for found results without `SQL_CALC_FOUND_ROWS`.
*
* @return string
*/
protected function prepare_query() {

global $wpdb;

$from = "FROM {$wpdb->prefix}lifterlms_webhooks";
$where = $this->sql_where();

if ( ! $this->get( 'no_found_rows' ) ) {
$this->count_query = "SELECT COUNT(*) {$from} {$where}";
}

return "SELECT {$this->sql_select_columns( 'id' )}
FROM {$wpdb->prefix}lifterlms_webhooks
{$this->sql_where()}
{$from}
{$where}
{$this->sql_orderby()}
{$this->sql_limit()};";

Expand Down
31 changes: 21 additions & 10 deletions includes/server/class-llms-rest-enrollments-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,7 @@ protected function prepare_items_query( $prepared_args = array(), $request = nul
* @since 1.0.0-beta.4 Enrollment's post_id and student_id casted to integer.
* @since 1.0.0-beta.10 Added subquery to retrieve the enrollments trigger.
* @since 1.0.0-beta.18 Fixed wrong trigger retrieved when multiple trigger were present for the same user,post pair.
* @since 1.0.5 Replaced `SQL_CALC_FOUND_ROWS` / `FOUND_ROWS()` with a separate `COUNT(DISTINCT)` query.
*
* @param array $query_args Array of collection arguments.
* @param WP_REST_Request $request Optional. Full details about the request. Default null.
Expand Down Expand Up @@ -989,19 +990,18 @@ protected function get_objects_query( $query_args, $request = null ) {

$query = new stdClass();

$select_found_rows = empty( $query_args['no_found_rows'] ) ? esc_sql( 'SQL_CALC_FOUND_ROWS' ) : '';

// the query.
$query->items = $wpdb->get_results(
$wpdb->prepare(
"
SELECT {$select_found_rows} DISTINCT upm.post_id AS post_id, upm.user_id as student_id, upm.updated_date as date_created, upm2.updated_date as date_updated, upm2.meta_value as status, upm3.meta_value as etrigger
FROM {$wpdb->prefix}lifterlms_user_postmeta AS upm
$from_joins_where = "FROM {$wpdb->prefix}lifterlms_user_postmeta AS upm
JOIN {$updated_date_status} as upm2 ON upm.post_id = upm2.post_id AND upm.user_id = upm2.user_id
JOIN {$trigger} as upm3 ON upm.post_id = upm3.post_id AND upm.user_id = upm3.user_id
WHERE upm.meta_key = '_start_date'
AND upm.{$id_column} = %d
{$filter}
{$filter}";

$query->items = $wpdb->get_results(
$wpdb->prepare(
"
SELECT DISTINCT upm.post_id AS post_id, upm.user_id as student_id, upm.updated_date as date_created, upm2.updated_date as date_updated, upm2.meta_value as status, upm3.meta_value as etrigger
{$from_joins_where}
{$order}
{$limit};
",
Expand All @@ -1023,7 +1023,18 @@ protected function get_objects_query( $query_args, $request = null ) {
}
}

$query->found_results = empty( $query_args['no_found_rows'] ) ? absint( $wpdb->get_var( 'SELECT FOUND_ROWS()' ) ) : $count; // no-cache ok.
if ( empty( $query_args['no_found_rows'] ) ) {
$query->found_results = absint(
$wpdb->get_var( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
$wpdb->prepare(
"SELECT COUNT(DISTINCT upm.post_id, upm.user_id) {$from_joins_where}",
array( $query_args['id'] )
)
)
);
} else {
$query->found_results = $count;
}

return $query;

Expand Down
2 changes: 1 addition & 1 deletion lifterlms-rest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Plugin Name: LifterLMS REST API
* Plugin URI: https://lifterlms.com/
* Description: REST API feature plugin for the LifterLMS Core.
* Version: 1.0.4
* Version: 1.0.5
* Author: LifterLMS
* Author URI: https://lifterlms.com/
* Text Domain: lifterlms
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lifterlms-rest",
"version": "1.0.4",
"version": "1.0.5",
"description": "REST API feature plugin for the LifterLMS Core.",
"author": "LifterLMS",
"homepage": "https://lifterlms.com/",
Expand Down
2 changes: 1 addition & 1 deletion spec/openapi.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
openapi: 3.0.0
info:
version: 1.0.4
version: 1.0.5
title: LifterLMS REST API
description: >-
# Introduction
Expand Down
Loading