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

Bug: 404 error page override with cache #2391

Closed
crustamet opened this issue Nov 8, 2019 · 10 comments · Fixed by #2406
Closed

Bug: 404 error page override with cache #2391

crustamet opened this issue Nov 8, 2019 · 10 comments · Fixed by #2406
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@crustamet
Copy link
Contributor

TypeError
Argument 1 passed to CodeIgniter\CodeIgniter::cachePage() must be an instance of Config\Cache, null given, called in /projects/ci4/system/CodeIgniter.php on line 960

@crustamet crustamet added the bug Verified issues on the current code behavior or pull requests that will fix them label Nov 8, 2019
@crustamet crustamet changed the title Bug: 404 error page override with cachpage not working im getting a 500 internal server error Bug: 404 error page override with cache Nov 8, 2019
@dafriend
Copy link
Contributor

dafriend commented Nov 9, 2019

It would be helpful to know exactly which version of CI4 you are using. I cannot find a commit where that function is on line 960, so my first suggestion is making sure you are using a current release.

It would also be helpful to see the code you are executing that leads to error.

@crustamet
Copy link
Contributor Author

It is the latest update please search for this function cachePage in system/Codeigniter.php
line : 959 where it is get called.
and 615 where the method is defined.

@crustamet
Copy link
Contributor Author

@crustamet
Copy link
Contributor Author

I overrided the Error Page and cache the error page.

That is it.

@crustamet
Copy link
Contributor Author

You understand or i need a more exemplified with code to show..
I think it is very straight forward.

Override the Error from the config with your controller.
and inside that Error default function you simply just put $this->cachePage(60);

You will get the error i posted up top.

@dafriend
Copy link
Contributor

The call $this->cachePage(60) is made from a controller?

@crustamet
Copy link
Contributor Author

Yes.. and From the Error override controller.

@dafriend
Copy link
Contributor

dafriend commented Nov 13, 2019

@crustamet,
Please confirm. You did something like this?

$routes->set404Override('App\Errors::show404');

I would really like to see the code

From the Error override controller.

@crustamet
Copy link
Contributor Author

Yes wait i was testing some stuff but i know for sure what is the problem..

So i have this setup

$routes->set404Override('App\Controllers\Errors::showErrorPage');

With this Controller

class Errors extends Controller
{
	public function showErrorPage()
	{
		$this->cachePage(360);

		$this->ViewData['LayoutView'] = 'Frontpanel/Errors/Errors';
	
		echo view('master', $this->ViewData);
	}
}

if i remove $this->cachePage(360); the error does not show

@dafriend
Copy link
Contributor

Thanks. I am able to reproduce the problem. Now to figure out why.

lonnieezell added a commit that referenced this issue Nov 15, 2019
…che-error

Fix issue #2391 CodeIgniter::display404errors()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants