Skip to content

Conversation

@wilsonge
Copy link
Contributor

@wilsonge wilsonge commented May 23, 2021

Pull Request for Issue # .

Summary of Changes

Adds support for the onBeforeRender and onAfterRender events to the API. It should be noted our core plugin correctly checks for html document types or if in site/admin modes in most places. The only exception to this is the cache plugin. However I think this won't change much because we don't call onAfterRoute in the API which does all the initialisation anyhow.

Adds support for offline mode to the API - if the site is in offline mode the API now should not be made available to users who cannot access it alongside an appropriate 503 status code

Testing Instructions

Turn on Offline mode. Before this PR check that the API is accessible. After PR you get a 503 error code.

For the Plugin events this should be as easy as dropping some test functions into an existing plugin.

Documentation Changes Required

N/A

@wilsonge wilsonge changed the title Add offline mode support in the API [4.0] Add offline mode support in the API May 23, 2021
@richard67
Copy link
Member

Testing instructions
Turn on API mode.

@wilsonge I assume you meant "offline mode" and not "API mode", or there is a new feature "API mode" in J4 of which I don't know yet.

@richard67
Copy link
Member

@wilsonge It seems you have to adjust the API tests to the changes in this PR. Currently they fail with:

1) BasicCest: Test route not found
 Test  tests/Codeception/api/BasicCest.php:testRouteNotFound
 Step  See response code is 404
 Fail  Expected HTTP Status Code: 404 (Not Found). Actual Status Code: 503 (Service Unavailable)
Failed asserting that 503 matches expected 404.

@wilsonge
Copy link
Contributor Author

Yup I did mean Offline mode - fixed that. Will look at tests tonight :)

@wilsonge
Copy link
Contributor Author

Tests fixed

@alikon
Copy link
Contributor

alikon commented May 25, 2021

humm got 500 shoduln't be 503 ?

{
    "errors": [
        {
            "code": 500,
            "title": "Internal server error",
            "detail": "Joomla\\CMS\\Application\\Exception\\OfflineWebsiteException: This site is down for maintenance.<br />Please check back again soon. in /var/www/html/cloud/libraries/src/Application/ApiApplication.php:162\nStack trace:\n#0 /var/www/html/cloud/libraries/src/Application/CMSApplication.php(284): Joomla\\CMS\\Application\\ApiApplication->render()\n#1 /var/www/html/cloud/api/includes/app.php(54): Joomla\\CMS\\Application\\CMSApplication->execute()\n#2 /var/www/html/cloud/api/index.php(31): require_once('/var/www/html/c...')\n#3 {main}"
        }
    ]
}

@wilsonge wilsonge force-pushed the feature/offline-mode-api branch from 163f7df to 8501b40 Compare May 29, 2021 22:29
@wilsonge
Copy link
Contributor Author

Fixed

@alikon
Copy link
Contributor

alikon commented Jun 4, 2021

something is going wrong in your merge

$errors->registerHandler(new InstallLanguageExceptionHandler);

fe93f16

@alikon
Copy link
Contributor

alikon commented Jun 5, 2021

i dunno if this was already there...
anyway with
core.login.offline = false and wrong request articlesx
got this from postman

Screenshot from 2021-06-05 11-07-57

my usual dirty hack wilsonge#67

@wilsonge
Copy link
Contributor Author

wilsonge commented Jun 5, 2021

That one is a bit hacky :) will debug when I’m in front of my laptop this evening. May be there’s nothing better but 🤷‍♂️

@Hackwar Hackwar removed the psr12 label Feb 21, 2023
@Hackwar Hackwar added the Feature label Apr 6, 2023
@HLeithner HLeithner changed the base branch from 4.3-dev to 5.0-dev May 8, 2023 15:03
@HLeithner
Copy link
Member

This pull request has been automatically rebased to 5.0-dev. No new features will be merged into Joomla! 4.3 series. Joomla! 4.4 series is a bridge release to make migration from Joomla! 4 to 5 as smooth as possible.

@HLeithner HLeithner marked this pull request as draft September 17, 2023 17:14
@HLeithner HLeithner changed the base branch from 5.0-dev to 5.1-dev September 30, 2023 22:52
@HLeithner
Copy link
Member

This pull request has been automatically rebased to 5.1-dev.

@HLeithner HLeithner changed the base branch from 5.1-dev to 5.2-dev April 24, 2024 09:10
@HLeithner
Copy link
Member

This pull request has been automatically rebased to 5.2-dev.

@HLeithner HLeithner changed the title [4.0] Add offline mode support in the API [5.2] Add offline mode support in the API Apr 24, 2024
@joomla-cms-bot joomla-cms-bot added PR-5.2-dev and removed Language Change This is for Translators labels Apr 24, 2024
@laoneo laoneo removed their assignment May 31, 2024
@HLeithner HLeithner changed the base branch from 5.2-dev to 5.3-dev September 2, 2024 08:54
@HLeithner
Copy link
Member

This pull request has been automatically rebased to 5.3-dev.

@HLeithner HLeithner changed the title [5.2] Add offline mode support in the API [5.3] Add offline mode support in the API Sep 2, 2024
@Hackwar Hackwar removed the PR-5.2-dev label Sep 3, 2024
@HLeithner HLeithner changed the base branch from 5.3-dev to 6.0-dev March 4, 2025 17:23
@HLeithner
Copy link
Member

This pull request has been automatically rebased to 6.0-dev.

@HLeithner HLeithner changed the title [5.3] Add offline mode support in the API [6.0] Add offline mode support in the API Mar 4, 2025
@rdeutz rdeutz removed the PR-5.3-dev label Mar 5, 2025
@HLeithner HLeithner changed the base branch from 6.0-dev to 6.1-dev August 31, 2025 12:01
@HLeithner
Copy link
Member

This pull request has been automatically rebased to 6.1-dev.

@HLeithner HLeithner changed the title [6.0] Add offline mode support in the API [6.1] Add offline mode support in the API Aug 31, 2025
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.