Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.0] Fixes the missing modified start and end date filter to articled API endpoint #45142

Merged
merged 15 commits into from
Mar 24, 2025

Conversation

laoneo
Copy link
Member

@laoneo laoneo commented Mar 15, 2025

Summary of Changes

Adds two new filter options to the articles list endpoint. The new modified_start and modified_end filters do allow to fetch articles which are modified within a date range. This is a common use case in API's, as it allows consumers to fetch only the delta which has changed since the last sync and not always the full list of articles. The following example fetches only articles which are edited within February 2025:

GET /api/index.php/v1/content/articles?filter[modified_start]=2025-02-01&filter[modified_start]=2025-02-28

Testing Instructions

  • Create an article with the modified date before February 2025
  • Create an article with the modified date after February 2025

Use tools like postman to execute the following curl command against the joomla installation with the patch:

curl -g "https://{web site}/api/index.php/v1/content/articles?filter[modified_start]=2025-02-01&filter[modified_start]=2025-02-28" -H "Authorization: Bearer {your token}"

Actual result BEFORE applying this Pull Request

All articles are returned.

Expected result AFTER applying this Pull Request

Only the article which was modified after the first February is returned.

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

@laoneo laoneo changed the title [5.3] Add modified start and end date filter to articled API endpoint [5.3] Fixes the missing modified start and end date filter to articled API endpoint Mar 16, 2025
@alikon
Copy link
Contributor

alikon commented Mar 16, 2025

I have tested this item ✅ successfully on 2493253


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45142.

@exlemor
Copy link

exlemor commented Mar 16, 2025

I have tested this item ✅ successfully on 2493253

Thanks to @alikon's and @richard67's help, I was able to successfully test this via Postman!


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45142.

@QuyTon
Copy link
Contributor

QuyTon commented Mar 16, 2025

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45142.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Mar 16, 2025
@muhme
Copy link
Contributor

muhme commented Mar 16, 2025

I have tested this item ✅ successfully on 2493253

Tested with local Joomla 5.3-dev on macOS

  • Before applying this PR:
    • Overall System Tests 538 passed
    • Tested API with HTTP Status 200 (unknown filters are ignored)
      • curl -w "\nHTTP Status: %{http_code}\n" --header "X-Joomla-Token:${token}" "${baseUrl}/api/index.php/v1/content/articles"
      • curl -w "\nHTTP Status: %{http_code}\n" --header "X-Joomla-Token:${token}" "${baseUrl}/api/index.php/v1/content/articles?filter[modified_start]=2025-02-01&filter[modified_end]=2025-02-28"
  • After applying this PR with Patch Tester
    • Overall System Tests 539 passed (including the new one)
    • Created three articles january, february and march and changed modified date in database to 15th and time to 12:00:00
    • checked
      • curl -w "\nHTTP Status: %{http_code}\n" --header "X-Joomla-Token:${token}" "${baseUrl}/api/index.php/v1/content/articles?filter[modified_start]=2025-02-01&filter[modified_end]=2025-02-28" # Get only february article
      • curl -w "\nHTTP Status: %{http_code}\n" --header "X-Joomla-Token:${token}" "${baseUrl}/api/index.php/v1/content/articles?filter[modified_start]=2025-01-01&filter[modified_end]=2025-04-01" # Get all three articles
      • curl -w "\nHTTP Status: %{http_code}\n" --header "X-Joomla-Token:${token}" "${baseUrl}/api/index.php/v1/content/articles?filter[modified_start]=2025-02-01" # February and March article
      • curl -w "\nHTTP Status: %{http_code}\n" --header "X-Joomla-Token:${token}" "${baseUrl}/api/index.php/v1/content/articles?filter[modified_end]=2025-02-01" # Only January article
      • curl -w "\nHTTP Status: %{http_code}\n" --header "X-Joomla-Token:${token}" "${baseUrl}/api/index.php/v1/content/articles?filter[modified_start]=2025-01-15%2012:00:00&filter[modified_end]=2025-03-15%2012:00:00" # All three articles
      • curl -w "\nHTTP Status: %{http_code}\n" --header "X-Joomla-Token:${token}" "${baseUrl}/api/index.php/v1/content/articles?filter[modified_start]=2025-01-15%2012:00:00&filter[modified_end]=2025-03-15%2011:59:59" # January + February article
      • curl -w "\nHTTP Status: %{http_code}\n" --header "X-Joomla-Token:${token}" "${baseUrl}/api/index.php/v1/content/articles?filter[modified_start]=2025-01-15%2012:00:00" # all three
      • curl -w "\nHTTP Status: %{http_code}\n" --header "X-Joomla-Token:${token}" "${baseUrl}/api/index.php/v1/content/articles?filter[modified_start]=2025-01-15%2012:00:01" # only februrary and march article
        This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45142.

brianteeman and others added 11 commits March 19, 2025 07:37
During the build process off a new release or update we remove various files that should not or do not need to be distributed

This PR extends the list of files to be removed from the libraries/vendor folder to include

.drone.yml
.drone.jsonnet

Examples can be seen in most of the libraries/vendor/joomla folders

Signed-off-by: BrianTeeman <[email protected]>
Co-authored-by: Quy Ton <[email protected]>
* Update php-tuf to version 5.3

* revert composer change
_this is an AI generated explanation_

The warning Only the first byte will be assigned to the string offset occurs because $temp1 is being treated as a string, and assigning a value to $temp1[$i] attempts to modify a specific character (byte) of the string. However, the value being assigned (random_int(0, 99999999)) is an integer, which is incompatible with this operation.

Root Cause:
In PHP, when you use array-like syntax (e.g., $temp1[$i]) on a variable that has not been explicitly declared as an array, PHP may treat it as a string. In this case, $temp1 is being treated as a string, and $temp1[$i] is interpreted as modifying a specific character of the string. Since random_int(0, 99999999) generates an integer, PHP raises a warning because you cannot assign an integer to a specific byte of a string.

Fix:
To resolve this issue, you need to explicitly declare $temp1 as an array before using it. This ensures that $temp1[$i] is treated as an array element rather than a string offset.

Explanation of the Fix:
Explicit Declaration:

$temp1 = []; ensures that $temp1 is treated as an array from the start.
This avoids PHP's automatic type juggling, which might treat $temp1 as a string if it is not explicitly declared.
Assigning Values:

$temp1[$i] = random_int(0, 99999999); now correctly assigns the random integer to the $ith index of the $temp1 array.

Summary:
This fix ensures that $temp1 is treated as an array, eliminating the warning and allowing the code to function as intended.

Signed-off-by: BrianTeeman <[email protected]>
Don't use the deprecated CMS Filesystem but the framework package
@rdeutz rdeutz changed the title [5.3] Fixes the missing modified start and end date filter to articled API endpoint [6.0] Fixes the missing modified start and end date filter to articled API endpoint Mar 21, 2025
@rdeutz rdeutz changed the base branch from 5.3-dev to 6.0-dev March 21, 2025 16:15
@rdeutz rdeutz self-requested a review as a code owner March 21, 2025 16:15
@joomla-cms-bot joomla-cms-bot added Composer Dependency Changed NPM Resource Changed This Pull Request can't be tested by Patchtester labels Mar 24, 2025
@softforge softforge added this to the Joomla! 6.0.0 milestone Mar 24, 2025
@softforge softforge merged commit 3e35108 into joomla:6.0-dev Mar 24, 2025
3 of 4 checks passed
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Mar 24, 2025
@softforge
Copy link
Contributor

Thank you @laoneo and the testers for all your work

laoneo added a commit to Digital-Peak/joomla-cms that referenced this pull request Mar 25, 2025
laoneo added a commit that referenced this pull request Mar 25, 2025
@laoneo laoneo deleted the api/content/modified branch March 25, 2025 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.