wp-e-commerce / WP-e-Commerce

WP eCommerce - The most popular independent eCommerce platform for WordPress
https://wpecommerce.org
GNU General Public License v2.0
215 stars 216 forks source link

Fatal Error when a Controller page doesn't exist #1767

Closed omarabid closed 9 years ago

omarabid commented 9 years ago

If a controller page doesn't exist, it'll throw a Fatal Error.

For example, in checkout process, if you use the path /checkout/doesntexist, it'll throw the following error.

Fatal error: Invalid controller method: WPSC_Controller_Checkout::doesntexist() in /devl/webserver/wpec/wp-content/plugins/WP-e-Commerce/wpsc-components/theme-engine-v2/classes/router.php on line 230
omarabid commented 9 years ago

@JustinSainton Looking at the code, it seems to be done on purpose

if ( ! is_callable( array( $this->controller, $method ) ) ) {
    trigger_error( 'Invalid controller method: ' . get_class( $this->controller ) . '::' . $method . '()', E_USER_ERROR );
}

I think a Fatal Error is not appropriate. Maybe redirecting to a 404 page/page not found?

mihaijoldis commented 9 years ago

While on the 404 thing. Just crossed my mind. For example we allow the users to create a custom 404 page and we have a template or something that they can edit and that template can show products. Like if i google for glasses, end up on a product page for a wpec store that the URL is not valid like: site.com/glasses-white-product

then the 404 page will say like a Sorry the page was not found and at the bottom show products

omarabid commented 9 years ago

@misulicus I think a customisable 404 page is overthinking the issue for the moment. Woo redirects to the theme standard 404 page. The developer/user can always edit/customise his 404 page and even detect which page (store/checkout/other) the user is navigating.

@JustinSainton Should we go the same route? Just redirecting to WordPress 404?

JustinSainton commented 9 years ago

:+1: