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

hotfix: Proper clearing of the ID<->URI mappings #204

Merged
merged 1 commit into from
Jan 7, 2025

Conversation

Voltra
Copy link
Collaborator

@Voltra Voltra commented Jan 4, 2025

When removing the last entries of any of the two ID<->URI mappings, the cached value used to become an empty array, which in turn broke all read operations from said mapping and thus most of the features related to routing.

The bug could only occur in three situations:

  • With the hook-to-commands config option set to true, when calling any of the clear kind of 1st-party artisan commands (note that some commands like route:cache also silently call route:clear first, so these count as well)
  • When installing the package if a script call any of said 1st-party artisan commands (since the option is currently defaulting to true)
  • When deleting the last existing page

This PR addresses this issue by removing the mapping from the cache instead of caching an empty mapping. This effectively clears out the mapping and properly invalidates caches.

Fixes #198

@Voltra Voltra self-assigned this Jan 4, 2025
Copy link

what-the-diff bot commented Jan 4, 2025

PR Summary

  • Improved Cache Handling:
    The updates in the methods replaceIdToUriMapping and replaceUriToIdMapping enable better management of our application's memory cache. By checking if any new mapping is empty before replacing, we avoid unnecessary use of memory space. This results in increased efficiency and better performance of our app.

@Z3d0X Z3d0X merged commit 546de55 into Z3d0X:2.x Jan 7, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Undefined array key 1 related to PageRoutesService
2 participants