Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

Crash on your blog page if you include /home in the path #1235

Open
ghost opened this issue Dec 10, 2017 · 34 comments
Open

Crash on your blog page if you include /home in the path #1235

ghost opened this issue Dec 10, 2017 · 34 comments

Comments

@ghost
Copy link

ghost commented Dec 10, 2017

Summary

When creating a static homepage, anchor creates a slug to whatever you name it. "/home" for example.
If you have a blog or page page for your blog and you type:
www.example.com/home/blog or www.example.com/home/page depending on whichever you created anchor crashes.

Expected Behaviour

a simple 404 error page.

Actual Behaviour

This only happens when you exactly do the steps listed above. It won't happen if you type www.example.com/home/something_else. If you do that, anchor works fine.

Error Message

require(/home2/zsqr5wfq/public_html/themes/gravity/page.php): failed to open stream: No such file or directory

The error has been logged in /anchor/errors.log

Uncaught Exception
require(/home2/zsqr5wfq/public_html/themes/gravity/page.php): failed to open stream: No such file or directory

Origin
system/view.php on line 87
Trace
#0 /home2/zsqr5wfq/public_html/system/view.php(87): System\Error::native(2, 'require(/home2/...', '/home2/zsqr5wfq...', 87, Array)
#1 /home2/zsqr5wfq/public_html/system/view.php(87): require()
#2 /home2/zsqr5wfq/public_html/system/route.php(160): System\View->render()
#3 /home2/zsqr5wfq/public_html/system/router.php(152): System\Route->run()
#4 /home2/zsqr5wfq/public_html/system/start.php(46): System\Router->dispatch()
#5 /home2/zsqr5wfq/public_html/index.php(35): require('/home2/zsqr5wfq...')
#6 {main}

Setup

  • Anchor version: 12.1
  • Server setup: php7.1
  • URL redacted
@CraigChilds94
Copy link
Member

CraigChilds94 commented Dec 11, 2017

@14u2ponder Thanks for spotting this one, have you tried version0.12.3?

@ghost
Copy link
Author

ghost commented Dec 11, 2017

I'd like to but I don't know how to install 12.3

@ghost
Copy link
Author

ghost commented Dec 14, 2017

@CraigChilds94 have you not been able to recreate the issue? Also while I know you're busy is there anybody here that can show me how to install 12.3. I've asked several times to no avail.

@TheBrenny
Copy link
Member

@14u2ponder Are the instructions on the front page not working for you? ☹️

@ghost
Copy link
Author

ghost commented Dec 30, 2017

@TheBrenny the last time I tried to install it it didn't have the Vendor folder included, so it would not install. So I assumed that there was an upgrade procedure which the last time I tried to do that you had to replace the system folder and then import your database over. I don't know if 12.3 is either an upgrade or a standalone product is my point and maybe you have to use bowser to install it, which I don't really know a lot about bowser. So....

@TheBrenny
Copy link
Member

TheBrenny commented Dec 30, 2017

If you download master/anchor/routes/admin.php and master/anchor/libraries/update.php and replace the files in your setup with these ones, then log into the Admin Panel and direct yourself to www.yoursite.com/admin/upgrade and follow the prompts, hopefully magic should happen and you'll be set to grab the latest Anchor automagically...

Back to the main point of the issue though (😅)... This is going to sound like a really stupid question, but in your themes directory, can you confirm the you have a page.php file? I have a feeling that you're using a custom page file for your home, and the posts page uses its own PHP file...

@ghost
Copy link
Author

ghost commented Dec 30, 2017

@TheBrenny I AM using a custom file for my homepage. page-home.php and in the meta I have home pointed to home. I also have a posts.php file that is pointed to post page. I re-named the slug "blog." You can see it here: deleted

I am still working on the pages so they look broken, they aren't. It is just incomplete.

@TheBrenny
Copy link
Member

So does that mean this issue is resolved, considering it was sounding like you made your blog with a slug of /home/blog?

@ghost
Copy link
Author

ghost commented Dec 30, 2017

@TheBrenny I can see how it might seem that way. But actually, I was testing the fact that, in anchor, when you create a static home page with page-home.php your homepage can resolve to the slug of /home. Such as: redacted If you do this (and follow me here) and then type some gibberish after that: redacted you will receive a 404 error message. LIKE YOU ARE supposed to.

However, if you type: redacted (or presumably PAGE, if you have not renamed your post page) this will break anchors 404 error system and you will get an uncaught exception.
Is this clear?

@ghost
Copy link
Author

ghost commented Dec 30, 2017

My thinking is that it SHOULD just 404 error it. Or maybe there could be a way to redirect it to /blog instead of /home/blog. But I don't really know how you guys want to handle this because honestly most people don't use the slug /home and would not need /home/blog to resolve. Me personally, I don't want or need the /home slug but I know it is a part of anchor.

@TheBrenny
Copy link
Member

AAaaaaaahhhh.. I get it. I understand!

I've backtracked what's going on, and it's because the conditionals on this line aren't quite working as they should. That's because we're testing for things and then having "hope". That's the best way I can explain it.

Anyway, if you change that line to this:

if ((!$page->parent and $last) or ($page->parent and !$last) or ($page->parent and $last->id != $page->parent)) {

then you should have it fixed. Give it a go, and tell me what happens! 😄

@ghost
Copy link
Author

ghost commented Dec 30, 2017

Okay, I will today a little later and I will post the results. Leave it to me to test something stupid, lol.

@ghost
Copy link
Author

ghost commented Dec 30, 2017

Well, I am still on 12.1. I think it might be too much for me to switch over to 12.3 right now, and not sure it is too worth it yet. When I look at my site.php this is what I see:

Route::get('(:all)', function($uri) {
	if( ! $page = Page::slug($slug = basename($uri))) {
		return Response::create(new Template('404'), 404);
	}

	if($page->redirect) {
		return Response::redirect($page->redirect);
	}

	Registry::set('page', $page);

	if($page->status != 'published') {
		if(!Auth::user()) {
			return Response::create(new Template('404'), 404);
		}
	}

	return new Template('page');
});

@TheBrenny
Copy link
Member

A little bit upward I've identified how to upgrade a little easier than the manual method. I can only point you in the right direction and hope that I didn't screw up somewhere.

@ghost
Copy link
Author

ghost commented Dec 30, 2017

Yeah, but I think it requires me to replace the anchor folder, because when I tried it, it locked me out of my site meta, so I figured that at the very least I would need to do something else. What i did was replace those two files like you said and went to my admin page and was looking for upgrade in site meta, but I got an error so I gave up, lol.

The admin page worked, as far as it goes, but the site meta threw an error, so I don't know.

@ghost
Copy link
Author

ghost commented Dec 30, 2017

@TheBrenny hey bren, I tried the update again: at first I was using update rather than upgrade. Once I used the correct file, I got this
2017-12-30

@TheBrenny
Copy link
Member

TheBrenny commented Dec 31, 2017 via email

@ghost
Copy link
Author

ghost commented Dec 31, 2017

@TheBrenny Sadly, the rabbit hole continues. Here is the error I get. Figure 1 is with the old status.php file. Figure 2 is the new status.php file. Same error.

2017-12-31

2017-12-31 1

@ghost
Copy link
Author

ghost commented Dec 31, 2017

@TheBrenny Hey, I figured this out. I was copying and pasting the code into a notepad ++ file because I didn't see a clone button, and I added an extra space in my upgrade.php file at the top before <php line. Once I fixed that it worked.

But I have a question, I see that when I clicked update it is running and I see it downloaded a folder: Anchor_update to my public_html, is it going to complete everything for me and how long does it take for that to happen?

@TheBrenny
Copy link
Member

If you click update, it should do everything automagically. Should take no more than 10 minutes, and that's being generous. If you don't get any feedback, that's when I'd get a little bit concerned. Did you get anything from your page?

@ghost
Copy link
Author

ghost commented Jan 1, 2018

@TheBrenny All it did was download a folder called anchor_update and I let it go for probably 20 minutes. It never did nothing else. And it kept saying updating... and the little anchor symbol was rotating. Nothing else happened. Maybe it has something to do with my server. I'm on hostgator, I don't know.

@TheBrenny
Copy link
Member

Oooh. Now this one is interesting! I feel it requires a new thread, though...

Either way, I'll ask a few questions in a sec, I just need to track down the code where things might be going wrong...

@TheBrenny
Copy link
Member

@14u2ponder Can you open up the Dev Inspector (F12 on Chrome) and then click update? There should be something with a whole bunch of "|-|"s in it. It could be an object. Can you send through that?

@ghost
Copy link
Author

ghost commented Jan 1, 2018

@TheBrenny I'll try it. Do you want me to post the results, in other words?

@ghost
Copy link
Author

ghost commented Jan 1, 2018

@TheBrenny Actually, that was wrong I was using edge. Here is the screen for chrome.
2018-01-01 1

@ghost
Copy link
Author

ghost commented Jan 1, 2018

@TheBrenny here are some more screens
2018-01-01 2

2018-01-01 3

2018-01-01 4

@TheBrenny
Copy link
Member

What's the response tab on that XHR look like?

@ghost
Copy link
Author

ghost commented Jan 1, 2018

@TheBrenny I think I sent that in the last image. It looks like it is waiting but the content was downloaded, see far right on the image above.

@ghost
Copy link
Author

ghost commented Jan 1, 2018

Here I found something for you here.
Uncaught error!!!!!!!!!!
2018-01-01 5

@ghost
Copy link
Author

ghost commented Jan 1, 2018

@TheBrenny Another screen.

2018-01-01 6

@TheBrenny
Copy link
Member

It looks like the ZipArchive PHP extension isn't installed on your system. I'll see if we can drop the reliance on ZipArchive.

@ghost
Copy link
Author

ghost commented Jan 1, 2018

Okay, thanks!

@ghost
Copy link
Author

ghost commented Jan 3, 2018

@TheBrenny quick question. I think I can enable Archive_Zip (0.1.2) from my php pear packages. Is this what you are referring to?

@ghost
Copy link
Author

ghost commented Jan 3, 2018

@TheBrenny well I tried it and it didn't work, so

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants