Skip to content

Removed experimental URL cache#22441

Merged
daniellockyer merged 1 commit intomainfrom
remove-url-cache
Mar 20, 2025
Merged

Removed experimental URL cache#22441
daniellockyer merged 1 commit intomainfrom
remove-url-cache

Conversation

@daniellockyer
Copy link
Contributor

fix https://linear.app/ghost/issue/ENG-1803/remove-url-cache-code

  • this feature is experimental and was designed in order to speed up our URL service init by storing a cache of the object
  • however, it was never really finished and we've had a few bugs with it
  • to avoid further issues, this commit removes it
  • along the way, I've discovered that our tests REQUIRE the URL cache in order to pass, which I thought was weird. Turns out it's because they incorrectly set cache values into the URL service that are outdated, which meant our snapshots are wrong
  • this is why several of the snapshots have been updated, because URLs have changed
  • sadly this commit touches so many files, but this feature was really spread around the codebase
  • this technically removes test util API support for a split backend/frontend but that wasn't properly finished. I'd like to get that working, but first we need to unpick the mess we've got ourselves into

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 11, 2025

Walkthrough

The changes remove the use of the frontend parameter and all related cache-handling logic from the core boot procedures and URL service. The initCore and bootGhost functions no longer accept or propagate a frontend parameter, which results in the removal of conditional URL cache initialization. The LocalFileCache class and all references to it, including its instantiation in the URL service, have been eliminated. Configuration files have been updated to remove any entries related to URL caching, and feature flag references have been adjusted accordingly. In addition, several test utilities and test suites have been modified to simplify the startup of Ghost by removing default values related to caching, ensuring consistency with the updated core logic.

Possibly related PRs

Suggested labels

browser-tests

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4ffb70c69d2ce5a20f4038c3a593df378d1a35c9 and 1c9de2f.

⛔ Files ignored due to path filters (7)
  • ghost/core/test/e2e-api/admin/__snapshots__/config.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-api/admin/__snapshots__/pages.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-api/admin/__snapshots__/posts.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-api/content/__snapshots__/posts.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-webhooks/__snapshots__/posts.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/integration/services/email-service/__snapshots__/cards.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/regression/api/admin/__snapshots__/authentication.test.js.snap is excluded by !**/*.snap
📒 Files selected for processing (21)
  • ghost/core/core/boot.js (3 hunks)
  • ghost/core/core/server/services/url/LocalFileCache.js (0 hunks)
  • ghost/core/core/server/services/url/UrlService.js (2 hunks)
  • ghost/core/core/server/services/url/index.js (1 hunks)
  • ghost/core/core/shared/config/env/config.testing-browser.json (1 hunks)
  • ghost/core/core/shared/config/env/config.testing-mysql.json (1 hunks)
  • ghost/core/core/shared/config/env/config.testing.json (1 hunks)
  • ghost/core/core/shared/labs.js (0 hunks)
  • ghost/core/test/e2e-api/admin/sso.test.js (1 hunks)
  • ghost/core/test/e2e-api/admin/utils.js (1 hunks)
  • ghost/core/test/e2e-api/content/utils.js (1 hunks)
  • ghost/core/test/regression/api/admin/utils.js (1 hunks)
  • ghost/core/test/regression/api/content/utils.js (1 hunks)
  • ghost/core/test/unit/server/services/url/LocalFileCache.test.js (0 hunks)
  • ghost/core/test/unit/shared/config/loader.test.js (0 hunks)
  • ghost/core/test/unit/shared/labs.test.js (2 hunks)
  • ghost/core/test/utils/e2e-framework.js (6 hunks)
  • ghost/core/test/utils/e2e-utils.js (1 hunks)
  • ghost/core/test/utils/fixtures/urls/resources.json (0 hunks)
  • ghost/core/test/utils/fixtures/urls/urls.json (0 hunks)
  • ghost/core/test/utils/url-service-utils.js (1 hunks)
💤 Files with no reviewable changes (6)
  • ghost/core/core/shared/labs.js
  • ghost/core/test/utils/fixtures/urls/resources.json
  • ghost/core/core/server/services/url/LocalFileCache.js
  • ghost/core/test/unit/shared/config/loader.test.js
  • ghost/core/test/unit/server/services/url/LocalFileCache.test.js
  • ghost/core/test/utils/fixtures/urls/urls.json
🚧 Files skipped from review as they are similar to previous changes (13)
  • ghost/core/test/e2e-api/admin/sso.test.js
  • ghost/core/core/shared/config/env/config.testing-mysql.json
  • ghost/core/core/shared/config/env/config.testing.json
  • ghost/core/core/shared/config/env/config.testing-browser.json
  • ghost/core/test/regression/api/content/utils.js
  • ghost/core/test/utils/e2e-utils.js
  • ghost/core/test/regression/api/admin/utils.js
  • ghost/core/test/e2e-api/admin/utils.js
  • ghost/core/test/e2e-api/content/utils.js
  • ghost/core/core/server/services/url/index.js
  • ghost/core/test/utils/url-service-utils.js
  • ghost/core/test/unit/shared/labs.test.js
  • ghost/core/core/boot.js
🧰 Additional context used
🧬 Code Definitions (1)
ghost/core/test/utils/e2e-framework.js (1)
ghost/core/test/utils/e2e-utils.js (1) (1)
  • startGhost (205-240)
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: Ghost-CLI tests
  • GitHub Check: Database tests (Node 20.11.1, sqlite3)
  • GitHub Check: Regression tests (Node 20.11.1, sqlite3)
  • GitHub Check: Unit tests (Node 22.13.1)
  • GitHub Check: Database tests (Node 22.13.1, mysql8)
  • GitHub Check: Regression tests (Node 20.11.1, mysql8)
  • GitHub Check: Unit tests (Node 20.11.1)
  • GitHub Check: Database tests (Node 20.11.1, mysql8)
  • GitHub Check: Unit tests (Node 18.12.1)
  • GitHub Check: Database tests (Node 18.12.1, mysql8)
🔇 Additional comments (9)
ghost/core/test/utils/e2e-framework.js (6)

81-81: Default configuration updated to enable frontend by default.

The default configuration for startGhost has been changed to enable the frontend by default. This aligns with the PR objective of removing the experimental URL cache which was previously controlled by the frontend parameter.


222-224: Simplified agent creation by removing customizable boot options.

The getAdminAPIAgent function has been simplified to remove the options parameter and directly call startGhost() without custom boot options. This change is part of removing the experimental URL cache support which previously allowed splitting backend/frontend.


246-246: Simplified getMembersAPIAgent to use default Ghost configuration.

Similar to the AdminAPIAgent change, the function now uses the default Ghost configuration without custom boot options, supporting the removal of the experimental URL cache.


268-268: Simplified getWebmentionsAPIAgent to use default Ghost configuration.

The WebmentionsAPIAgent creation now uses the default Ghost configuration, removing URL cache customization options.


290-290: Simplified getGhostAPIAgent to use default Ghost configuration.

The GhostAPIAgent creation process has been streamlined to use the default Ghost configuration.


312-312: Simplified getAgentsForMembers to use default Ghost configuration.

The function now starts Ghost with default settings, supporting the removal of the URL cache feature.

ghost/core/core/server/services/url/UrlService.js (3)

28-28: Simplified constructor by removing cache parameter.

The constructor has been streamlined by removing the cache parameter, which is a key part of removing the experimental URL cache feature mentioned in the PR objectives.


299-308: Simplified init method by removing URL cache logic.

The init method has been significantly simplified by:

  1. Removing all cache-related logic
  2. Directly initializing event listeners for resources
  3. Fetching resources without any cache-related checks
  4. Always starting the queue after fetching resources

This change aligns with the PR objective of removing the experimental URL cache that was causing issues.


310-311: Removed cache-related logic from shutdown method.

The shutdown method has been simplified to remove all cache-related logic, which is consistent with the overall removal of the URL cache feature.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (4)
ghost/core/core/boot.js (1)

85-85: Removed frontend parameter from initCore signature.

This simplifies the function’s interface and avoids confusion about the service initialization paths. Ensure that other modules referencing initCore with a frontend argument are updated.

ghost/core/test/utils/e2e-framework.js (3)

81-81: Defaulting frontend to true.

Enabling the frontend by default can lead to slightly slower tests if the frontend isn’t needed. Consider selectively disabling it for tests that only need the backend to optimize runtime.


246-246: getMembersAPIAgent also calls startGhost() unconditionally.

Unifying agent creation reduces duplication. Ensure coverage or add tests that verify if a backend-only startup still works if needed.


312-312: getAgentsForMembers no longer composes bootOptions.

Similar to other agents, removing bootOptions centralizes the logic in startGhost. Fine for maintenance; watch out for any test requiring custom options.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bbe6128 and 55e95f03839324922fa05ad938d70a165e5da2a3.

⛔ Files ignored due to path filters (7)
  • ghost/core/test/e2e-api/admin/__snapshots__/config.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-api/admin/__snapshots__/pages.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-api/admin/__snapshots__/posts.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-api/content/__snapshots__/posts.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-webhooks/__snapshots__/posts.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/integration/services/email-service/__snapshots__/cards.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/regression/api/admin/__snapshots__/authentication.test.js.snap is excluded by !**/*.snap
📒 Files selected for processing (21)
  • ghost/core/core/boot.js (3 hunks)
  • ghost/core/core/server/services/url/LocalFileCache.js (0 hunks)
  • ghost/core/core/server/services/url/UrlService.js (2 hunks)
  • ghost/core/core/server/services/url/index.js (1 hunks)
  • ghost/core/core/shared/config/env/config.testing-browser.json (1 hunks)
  • ghost/core/core/shared/config/env/config.testing-mysql.json (1 hunks)
  • ghost/core/core/shared/config/env/config.testing.json (1 hunks)
  • ghost/core/core/shared/labs.js (0 hunks)
  • ghost/core/test/e2e-api/admin/sso.test.js (1 hunks)
  • ghost/core/test/e2e-api/admin/utils.js (1 hunks)
  • ghost/core/test/e2e-api/content/utils.js (1 hunks)
  • ghost/core/test/regression/api/admin/utils.js (1 hunks)
  • ghost/core/test/regression/api/content/utils.js (1 hunks)
  • ghost/core/test/unit/server/services/url/LocalFileCache.test.js (0 hunks)
  • ghost/core/test/unit/shared/config/loader.test.js (0 hunks)
  • ghost/core/test/unit/shared/labs.test.js (2 hunks)
  • ghost/core/test/utils/e2e-framework.js (6 hunks)
  • ghost/core/test/utils/e2e-utils.js (1 hunks)
  • ghost/core/test/utils/fixtures/urls/resources.json (0 hunks)
  • ghost/core/test/utils/fixtures/urls/urls.json (0 hunks)
  • ghost/core/test/utils/url-service-utils.js (1 hunks)
💤 Files with no reviewable changes (6)
  • ghost/core/core/shared/labs.js
  • ghost/core/core/server/services/url/LocalFileCache.js
  • ghost/core/test/utils/fixtures/urls/urls.json
  • ghost/core/test/unit/server/services/url/LocalFileCache.test.js
  • ghost/core/test/utils/fixtures/urls/resources.json
  • ghost/core/test/unit/shared/config/loader.test.js
🔇 Additional comments (24)
ghost/core/core/shared/config/env/config.testing.json (1)

78-79: Removal of urlCache path is appropriate for the cache feature deprecation

The removal of the urlCache path from the configuration aligns with the PR objective of completely removing the experimental URL cache feature that was never fully developed and has been causing bugs.

ghost/core/core/shared/config/env/config.testing-mysql.json (1)

82-83: Removal of urlCache path is consistent with overall PR objective

The removal of the urlCache configuration entry in this MySQL-specific testing config is consistent with the complete removal of the experimental URL cache feature across the codebase.

ghost/core/core/shared/config/env/config.testing-browser.json (1)

81-82: Consistent removal of urlCache configuration

This change aligns with the other configuration files, ensuring the urlCache feature is consistently removed across all testing environments.

ghost/core/test/e2e-api/admin/sso.test.js (1)

12-13: Explicit model initialization addresses test dependency issues

Adding the explicit model initialization is a good fix to ensure tests don't rely on the now-removed URL cache. According to the PR objectives, tests were unexpectedly relying on the URL cache, and this change helps decouple the tests from that dependency.

ghost/core/test/unit/shared/labs.test.js (5)

36-37: Feature flag name replaced as part of URL cache removal

The urlCache feature flag has been replaced with NestPlayground in the test setup. This is consistent with the PR objective of removing the experimental URL cache feature.


42-43: Feature flag name updated in expected output check

The test now checks for NestPlayground instead of urlCache in the expected output, which maintains the test coverage while removing references to the URL cache.


47-47: isSet check updated to use new feature flag name

The labs.isSet() check is now using the new NestPlayground feature flag name instead of urlCache, which is consistent with the overall changes in this PR.


55-56: Feature flag name replaced in another test case

The urlCache feature flag has been consistently replaced with NestPlayground in this test case as well, ensuring all tests are updated accordingly.


65-65: Negative check for feature flag updated

The negative check for the feature flag has been properly updated to use NestPlayground instead of urlCache, completing the rename across all test cases.

ghost/core/core/server/services/url/index.js (1)

3-3: URL service initialization simplified by removing cache parameter

The UrlService is now instantiated without a cache parameter, which aligns with the PR's objective of removing the experimental URL cache feature. This simplifies the URL service initialization and maintenance.

ghost/core/test/e2e-api/content/utils.js (1)

100-100:

Details

✅ Verification successful

Removed default frontend/backend configuration

The default configuration that set backend: true and frontend: false has been removed, and the method now directly passes the overrides parameter to testUtils.startGhost(). This change is part of removing the URL cache functionality, as the frontend parameter was previously used for cache initialization.

Let's verify the default values in the underlying startGhost method to ensure this change doesn't cause unexpected behavior:


🏁 Script executed:

#!/bin/bash
# Check the default values in the startGhost method

# Look for how startGhost handles its options
rg -A 15 "startGhost = async \(options\)" ghost/core/test/utils/

Length of output: 1117


Clarification on Default Configuration in startGhost

After verifying the underlying defaults in ghost/core/test/utils/e2e-utils.js, it appears that the startGhost method now merges options with defaults of { backend: true, frontend: true, ... }. The removal of the explicit configuration in ghost/core/test/e2e-api/content/utils.js (i.e. directly passing overrides to testUtils.startGhost()) is intentional and relies on these defaults.

  • The previous inline defaults (which reportedly set frontend: false) have been replaced. The current implementation defaults to frontend: true, as defined in e2e-utils.js.
  • This change supports the removal of the URL cache functionality since frontend initialization is now handled via the merged defaults in the underlying method.

The code change seems safe as long as the tests are expected to run with both backend and frontend enabled by default.

ghost/core/test/utils/e2e-utils.js (1)

136-136:

Details

✅ Verification successful

Removed URL cache configuration from URL service initialization

The urlServiceUtils.init() call no longer includes the urlCache parameter, which was previously set based on the frontend state. This is consistent with the PR's goal of completely removing the URL cache functionality, simplifying the service initialization.

Let's check how the urlServiceUtils.init() method has been updated to handle the absence of this parameter:


🏁 Script executed:

#!/bin/bash
# Check the implementation of urlServiceUtils.init

# Look for the init method definition
rg -A 10 "init\(\s*\{?.*?\}?\s*\)" ghost/core/test/utils/url-service-utils.js

Length of output: 281


URL Service Initialization Cleanup Verified

The removal of the URL cache parameter is correctly implemented. The verification confirms that the urlServiceUtils.init() call in both the e2e utilities and the URL service utilities now simply calls urlService.init(); without the previously passed urlCache parameter. This is in line with the PR's goal of eliminating the URL cache functionality.

  • Confirmed in ghost/core/test/utils/url-service-utils.js that the method now calls urlService.init(); without additional parameters.
  • The change in ghost/core/test/utils/e2e-utils.js at line 136 is consistent with this update.
ghost/core/test/e2e-api/admin/utils.js (1)

245-246: Default parameters removed in line with URL cache removal

This change removes the default parameters that were previously setting backend: true and frontend: false, now directly passing the overrides to testUtils.startGhost. This simplification aligns with the PR objective to remove the experimental URL cache feature.

ghost/core/test/regression/api/admin/utils.js (1)

209-210: Default parameters removed to simplify API

Similar to the other test utility files, this change removes the default parameters for backend and frontend that were previously merged with overrides. The simplification is consistent with the PR's goal of removing the URL cache functionality.

ghost/core/test/utils/url-service-utils.js (1)

19-21: URL cache parameter removed from init method

The init method has been modified to no longer accept or pass the urlCache parameter to the URL service. This change directly implements the PR objective of removing the experimental URL cache functionality that was causing issues.

ghost/core/test/regression/api/content/utils.js (1)

105-106: Consistent removal of default parameters

This change maintains consistency with other test utility files by removing the default parameters for backend and frontend. This simplification is part of the systematic removal of the URL cache feature across the codebase.

ghost/core/core/boot.js (2)

117-117: Unconditional urlService.init() call looks valid.

Since the caching logic is removed, directly calling urlService.init() streamlines boot and ensures the URL service is always ready. No issues here.


560-560: Updated initCore call without frontend.

Confirm that all references are aligned and no tests rely on the previous signature. Otherwise, this change is consistent with the removal of caching.

ghost/core/test/utils/e2e-framework.js (4)

222-222: Param signature simplified in getAdminAPIAgent.

The function no longer accepts additional parameters, relying solely on the default boot configuration. This is fine, but confirm that tests which relied on custom boot options are updated.


224-224: Invoking startGhost() without manual overrides.

This is consistent with enabling the frontend by default. Verify that any specialized test scenarios still pass with the new defaults.


268-268: getWebmentionsAPIAgent streamlined similarly.

No further concerns; consistent with the pattern established in other agents.


290-290: getGhostAPIAgent also simplified.

Approach parallels the other agent creation methods. No issues found.

ghost/core/core/server/services/url/UrlService.js (2)

29-29: Removed options parameter from the constructor.

Dropping the cache parameter clarifies the constructor. Ensure no leftover references to the old options.cache exist.


310-319: Simplified init method by removing caching logic.

  1. Initializes event listeners and fetches resources directly.
  2. Immediately starts the queue without conditional checks for caching.

This reduces complexity and potential for out-of-sync caches.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
ghost/core/core/server/services/url/UrlService.js (1)

320-321: Empty shutdown method

The shutdown method has been emptied, likely because it previously contained cache-related cleanup logic that is no longer needed.

However, consider whether this method is still needed at all. If it no longer serves any purpose, it might be cleaner to remove it entirely.

-async shutdown() {
-}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 55e95f03839324922fa05ad938d70a165e5da2a3 and 55d23a9.

⛔ Files ignored due to path filters (7)
  • ghost/core/test/e2e-api/admin/__snapshots__/config.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-api/admin/__snapshots__/pages.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-api/admin/__snapshots__/posts.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-api/content/__snapshots__/posts.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-webhooks/__snapshots__/posts.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/integration/services/email-service/__snapshots__/cards.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/regression/api/admin/__snapshots__/authentication.test.js.snap is excluded by !**/*.snap
📒 Files selected for processing (21)
  • ghost/core/core/boot.js (3 hunks)
  • ghost/core/core/server/services/url/LocalFileCache.js (0 hunks)
  • ghost/core/core/server/services/url/UrlService.js (2 hunks)
  • ghost/core/core/server/services/url/index.js (1 hunks)
  • ghost/core/core/shared/config/env/config.testing-browser.json (1 hunks)
  • ghost/core/core/shared/config/env/config.testing-mysql.json (1 hunks)
  • ghost/core/core/shared/config/env/config.testing.json (1 hunks)
  • ghost/core/core/shared/labs.js (0 hunks)
  • ghost/core/test/e2e-api/admin/sso.test.js (1 hunks)
  • ghost/core/test/e2e-api/admin/utils.js (1 hunks)
  • ghost/core/test/e2e-api/content/utils.js (1 hunks)
  • ghost/core/test/regression/api/admin/utils.js (1 hunks)
  • ghost/core/test/regression/api/content/utils.js (1 hunks)
  • ghost/core/test/unit/server/services/url/LocalFileCache.test.js (0 hunks)
  • ghost/core/test/unit/shared/config/loader.test.js (0 hunks)
  • ghost/core/test/unit/shared/labs.test.js (2 hunks)
  • ghost/core/test/utils/e2e-framework.js (6 hunks)
  • ghost/core/test/utils/e2e-utils.js (1 hunks)
  • ghost/core/test/utils/fixtures/urls/resources.json (0 hunks)
  • ghost/core/test/utils/fixtures/urls/urls.json (0 hunks)
  • ghost/core/test/utils/url-service-utils.js (1 hunks)
💤 Files with no reviewable changes (6)
  • ghost/core/test/unit/shared/config/loader.test.js
  • ghost/core/core/shared/labs.js
  • ghost/core/test/utils/fixtures/urls/resources.json
  • ghost/core/core/server/services/url/LocalFileCache.js
  • ghost/core/test/unit/server/services/url/LocalFileCache.test.js
  • ghost/core/test/utils/fixtures/urls/urls.json
🚧 Files skipped from review as they are similar to previous changes (14)
  • ghost/core/core/shared/config/env/config.testing-mysql.json
  • ghost/core/test/e2e-api/admin/sso.test.js
  • ghost/core/core/shared/config/env/config.testing.json
  • ghost/core/core/shared/config/env/config.testing-browser.json
  • ghost/core/test/regression/api/admin/utils.js
  • ghost/core/test/utils/e2e-utils.js
  • ghost/core/test/unit/shared/labs.test.js
  • ghost/core/test/regression/api/content/utils.js
  • ghost/core/test/e2e-api/admin/utils.js
  • ghost/core/test/utils/url-service-utils.js
  • ghost/core/test/e2e-api/content/utils.js
  • ghost/core/core/boot.js
  • ghost/core/core/server/services/url/index.js
  • ghost/core/test/utils/e2e-framework.js
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Setup
🔇 Additional comments (2)
ghost/core/core/server/services/url/UrlService.js (2)

28-28: Constructor signature simplified by removing cache parameter

The constructor has been simplified by removing the cache parameter, which aligns with the PR objective of removing the experimental URL cache. This change makes the service's initialization more straightforward.


309-318: Init method streamlined to remove cache-related logic

The init method has been significantly simplified by:

  1. Removing the urlCache parameter
  2. Directly initializing event listeners and fetching resources
  3. Starting the queue unconditionally

This change eliminates potential issues related to stale cache data and makes the initialization process more predictable.

@daniellockyer daniellockyer force-pushed the remove-url-cache branch 2 times, most recently from 7b2a417 to fbc44c6 Compare March 19, 2025 13:25
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
ghost/core/core/server/services/url/UrlService.js (3)

310-311: Consider removing empty shutdown method

The shutdown method has been emptied of all cache-related logic but remains in the codebase. Since it no longer performs any operations, consider removing it entirely to improve code cleanliness.

-async shutdown() {
-}

13-17: Update class documentation

The class documentation should be updated to reflect that the URL service no longer uses a cache, as this was a significant feature that has now been removed.

 /**
  * The url service class holds all instances in a centralized place.
  * 
  * It's the public API you can talk to.
  * 
  * It will tell you if the url generation is in progress or not.
+ * 
+ * Note: URL caching functionality has been removed.
  */

21-27: Update constructor JSDoc comment

The JSDoc comment for the constructor still references the removed cache parameter. Update it to reflect the current parameter list (which is now empty).

 /**
  *
- * @param {Object} [options]
- * @param {Object} [options.cache] - cache handler instance
- * @param {Function} [options.cache.read] - read cache by type
- * @param {Function} [options.cache.write] - write into cache by type
  */
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7b2a41788d206b1df622c74d9ea14736d5b5800a and fbc44c687c58964e1ed9809e688fe26addb301a1.

⛔ Files ignored due to path filters (7)
  • ghost/core/test/e2e-api/admin/__snapshots__/config.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-api/admin/__snapshots__/pages.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-api/admin/__snapshots__/posts.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-api/content/__snapshots__/posts.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-webhooks/__snapshots__/posts.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/integration/services/email-service/__snapshots__/cards.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/regression/api/admin/__snapshots__/authentication.test.js.snap is excluded by !**/*.snap
📒 Files selected for processing (21)
  • ghost/core/core/boot.js (3 hunks)
  • ghost/core/core/server/services/url/LocalFileCache.js (0 hunks)
  • ghost/core/core/server/services/url/UrlService.js (2 hunks)
  • ghost/core/core/server/services/url/index.js (1 hunks)
  • ghost/core/core/shared/config/env/config.testing-browser.json (1 hunks)
  • ghost/core/core/shared/config/env/config.testing-mysql.json (1 hunks)
  • ghost/core/core/shared/config/env/config.testing.json (1 hunks)
  • ghost/core/core/shared/labs.js (0 hunks)
  • ghost/core/test/e2e-api/admin/sso.test.js (1 hunks)
  • ghost/core/test/e2e-api/admin/utils.js (1 hunks)
  • ghost/core/test/e2e-api/content/utils.js (1 hunks)
  • ghost/core/test/regression/api/admin/utils.js (1 hunks)
  • ghost/core/test/regression/api/content/utils.js (1 hunks)
  • ghost/core/test/unit/server/services/url/LocalFileCache.test.js (0 hunks)
  • ghost/core/test/unit/shared/config/loader.test.js (0 hunks)
  • ghost/core/test/unit/shared/labs.test.js (2 hunks)
  • ghost/core/test/utils/e2e-framework.js (6 hunks)
  • ghost/core/test/utils/e2e-utils.js (1 hunks)
  • ghost/core/test/utils/fixtures/urls/resources.json (0 hunks)
  • ghost/core/test/utils/fixtures/urls/urls.json (0 hunks)
  • ghost/core/test/utils/url-service-utils.js (1 hunks)
💤 Files with no reviewable changes (6)
  • ghost/core/core/shared/labs.js
  • ghost/core/test/unit/shared/config/loader.test.js
  • ghost/core/core/server/services/url/LocalFileCache.js
  • ghost/core/test/utils/fixtures/urls/resources.json
  • ghost/core/test/utils/fixtures/urls/urls.json
  • ghost/core/test/unit/server/services/url/LocalFileCache.test.js
🚧 Files skipped from review as they are similar to previous changes (14)
  • ghost/core/test/e2e-api/admin/sso.test.js
  • ghost/core/test/regression/api/admin/utils.js
  • ghost/core/test/e2e-api/admin/utils.js
  • ghost/core/test/utils/e2e-utils.js
  • ghost/core/core/server/services/url/index.js
  • ghost/core/test/regression/api/content/utils.js
  • ghost/core/core/shared/config/env/config.testing-browser.json
  • ghost/core/test/unit/shared/labs.test.js
  • ghost/core/test/utils/url-service-utils.js
  • ghost/core/core/shared/config/env/config.testing.json
  • ghost/core/test/e2e-api/content/utils.js
  • ghost/core/core/boot.js
  • ghost/core/test/utils/e2e-framework.js
  • ghost/core/core/shared/config/env/config.testing-mysql.json
🔇 Additional comments (2)
ghost/core/core/server/services/url/UrlService.js (2)

28-28: Constructor signature simplified appropriately

The constructor has been properly updated to remove the cache parameter, aligning with the PR objective of removing the experimental URL cache functionality. This change simplifies the class instantiation and removes unnecessary dependencies.


299-308: Init method successfully simplified

The init method has been streamlined by removing all cache-related logic, now focusing solely on initializing event listeners, fetching resources, and starting the queue. This change makes the initialization process more straightforward and predictable.

@daniellockyer daniellockyer force-pushed the remove-url-cache branch 2 times, most recently from a32ff11 to 4ffb70c Compare March 19, 2025 15:44
fix https://linear.app/ghost/issue/ENG-1803/remove-url-cache-code

- this feature is experimental and was designed in order to speed up our
  URL service init by storing a cache of the object
- however, it was never really finished and we've had a few bugs with it
- to avoid further issues, this commit removes it
- along the way, I've discovered that our tests REQUIRE the URL cache in
  order to pass, which I thought was weird. Turns out it's because they
  incorrectly set cache values into the URL service that are outdated, which
  meant our snapshots are wrong
- this is why several of the snapshots have been updated, because URLs
  have changed
- sadly this commit touches so many files, but this feature was really
  spread around the codebase
- this technically removes test util API support for a split
  backend/frontend but that wasn't properly finished. I'd like to get
  that working, but first we need to unpick the mess we've got ourselves
  into
@daniellockyer daniellockyer merged commit 74a5842 into main Mar 20, 2025
26 checks passed
@daniellockyer daniellockyer deleted the remove-url-cache branch March 20, 2025 07:55
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.

1 participant