Skip to content
This repository has been archived by the owner on Jan 30, 2025. It is now read-only.

Fix: (one of) fatal error "No entry was found for 'comingSoon'" #929

Closed
wants to merge 1 commit into from

Conversation

BrianHenryIE
Copy link
Contributor

PHP Fatal error:  Uncaught NewfoldLabs\Container\NotFoundException: No entry was found for "comingSoon" identifier. in /.../vendor/newfold-labs/container/includes/Container.php:111
Stack trace:
#0 /.../vendor/newfold-labs/container/includes/Container.php(133): NewfoldLabs\Container\Container->raw('comingSoon')
#1 /.../inc/RestApi/SettingsController.php(178): NewfoldLabs\Container\Container->get('comingSoon')
#2 /.../inc/RestApi/SettingsController.php(51): Bluehost\RestApi\SettingsController->get_current_settings()

Recent commit 70f155c queries the container for comingSoon and calls methods is_enabled(), enable() and disable() on the result.

But where it is added to the container is comingsoon not comingSoon.

$bluehost_module_container->set(
'comingsoon',
array(
'admin_app_url' => admin_url( 'admin.php?page=bluehost#/home' ),
'template_h1' => __( 'Coming Soon!', 'wp-plugin-bluehost' ),
'template_h2' => __( 'A New WordPress Site', 'wp-plugin-bluehost' ),
'template_footer_t' => sprintf(
/* translators: %1$s is replaced with opening link tag taking you to bluehost.com/wordpress, %2$s is replaced with closing link tag, %3$s is replaced with opening link tag taking you to login page, %4$s is replaced with closing link tag, %5$s is replaced with opening link tag taking you to my.bluehost.com, %6$s is replaced with closing link tag */
esc_html__( 'A %1$sBluehost%2$s powered website. Is this your website? Log in to %3$sWordPress%4$s or %5$sBluehost%6$s.', 'wp-plugin-bluehost' ) . ' ',
'<a href="' . esc_url( $wordpress_hosting_page ) . '" target="_blank" rel="noopener noreferrer nofollow">',
'</a>',
'<a href="' . esc_url( wp_login_url() ) . '">',
'</a>',
'<a href="' . esc_url( $my_panel ) . '" target="_blank" rel="noopener noreferrer nofollow">',
'</a>'
),
'template_page_title' => sprintf(
/* translators: %s: Blog name */
__( '%s &mdash; Coming Soon', 'wp-plugin-bluehost' ),
esc_html( get_option( 'blogname' ) )
),
'admin_bar_text' => '<div style="background-color: #FEC101; color: #000; padding: 0 1rem;">' . __( 'Coming Soon Active', 'wp-plugin-bluehost' ) . '</div>',
'admin_notice_text' => sprintf(
/* translators: %1$s is replaced with the opening link tag to preview the page, and %2$s is replaced with the closing link tag, %3$s is the opening link tag, %4$s is the closing link tag. */
__( 'Your site is currently displaying a %1$scoming soon page%2$s. Once you are ready, %3$slaunch your site%4$s.', 'wp-plugin-bluehost' ),
'<a href="' . get_home_url() . '?preview=coming_soon" title="' . __( 'Preview the coming soon landing page', 'wp-plugin-bluehost' ) . '">',
'</a>',
'<a href="' . esc_url( admin_url( 'admin.php?page=bluehost&nfd-target=coming-soon-section#/settings' ) ) . '">',
'</a>'
),
'template_styles' => esc_url( BLUEHOST_PLUGIN_URL . 'assets/styles/coming-soon.css' ),
)
);

When I change it to use comingSoon in both places, the container returns the array that has been registered, but then the code attempts to call the is_enabeld() method which does not exist.

Proposed changes

This PR changes container()->get( 'comingSoon' )->is_enabled() to container()->has( 'comingSoon' ).

Type of Change

  • Bugfix (non-breaking change which fixes an issue)

Checklist

  • I have read the CONTRIBUTING doc
  • Linting and tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

Where enable() and disable() are called will still cause a crash.

The Coming Soon module itself uses lowercase $container->has( 'comingsoon' ) at includes/ComingSoon.php:46

I don't see a class with those methods so I'm not sure exactly how this should be working.

Copy link

cypress bot commented Feb 1, 2024

6 failed and 1 flaky tests on run #6830 ↗︎

6 302 43 0 Flakiness 1

Details:

Merge 4fa5bb0 into f51c559...
Project: Bluehost Brand Plugin Commit: 64ddb300fc ℹ️
Status: Failed Duration: 20:06 💡
Started: Feb 1, 2024 12:23 AM Ended: Feb 1, 2024 12:43 AM
Failed  vendor/newfold-labs/wp-module-coming-soon/tests/cypress/integration/coming-soon.cy.js • 1 failed test

View Output Video

Test Artifacts
Coming Soon > Launching launches site Test Replay Screenshots Video
Failed  vendor/newfold-labs/wp-module-ecommerce/tests/cypress/integration/Home/commerceHomePage.cy.js • 1 failed test

View Output Video

Test Artifacts
Commerce Home Page- Live Mode > Verify presense of Ready to go to next level? canvas Test Replay Screenshots Video
Failed  vendor/newfold-labs/wp-module-ecommerce/tests/cypress/integration/Store/storePage.cy.js • 1 failed test

View Output Video

Test Artifacts
Store Page- WooCommerce is deactivated/uninstalled > Verify Store and its sub tabs should have Install WooCommerce buttons Test Replay Screenshots Video
Failed  vendor/newfold-labs/wp-module-onboarding/tests/cypress/integration/3-ecommerce-onboarding-flow/basic-info.cy.js • 3 failed tests

View Output Video

Test Artifacts
Basic Info Page > Check for the short URL tooltip & Modal exists when we use URL shortner Test Replay Screenshots Video
Basic Info Page > Check for twitter or instagram id starting with `@` to convert it to URL Test Replay Screenshots Video
Basic Info Page > Check if Social Media URL checks are done Test Replay Screenshots Video
Flakiness  tests/cypress/integration/help.cy.js • 1 flaky test

View Output Video

Test Artifacts
Help Page > Is Accessible Test Replay Screenshots Video

Review all test suite changes for PR #929 ↗︎

@@ -175,7 +175,7 @@ public function get_current_settings() {
}

$settings = array(
'comingSoon' => container()->get( 'comingSoon' )->is_enabled(),
'comingSoon' => container()->has( 'comingSoon' ),
Copy link
Member

Choose a reason for hiding this comment

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

This changes the meaning behind the comingSoon property. The has() check just looks to see if the service is registered in the container. We should look into why the coming soon service doesn't exist yet and fix that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I wrote that first then realised there was more going on than i quite understood.

@circlecube
Copy link
Member

The lower case comingsoon is used to pass the strings to the container which the module loads up here: https://github.com/newfold-labs/wp-module-coming-soon/blob/main/includes/ComingSoon.php#L46 It's an array of translatable strings from the plugin (we wanted these strings to come from the plugins rather than the module so they could be translated)

The uppercase part is the coming soon service that is added to the container. It's set up here: https://github.com/newfold-labs/wp-module-coming-soon/blob/main/includes/API/ComingSoon.php#L37 Here it's an object which exposes the enable and disable methods.

Perhaps we're beating ourselves and the SettingsController loads before the modules have loaded and set up comingSoon service on the container. Thoughts @wpscholar?

@wpscholar
Copy link
Member

@circlecube I'm not sure what might have changed, as I tested this, and it worked fine before. But yes, my guess is that the code is triggering before the container is fully set up.

@circlecube
Copy link
Member

We discussed this recently and it is no longer needed.

@circlecube circlecube closed this May 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants