Jump to content

PW suddenly can't save pages anymore


vknt
 Share

Recommended Posts

While I was editing pages I got this error suddenly. I haven't changed any .php file in between. Just editing content and saving pages.

It does show all the data corretly, but I can't save a page anymore. The browser hangs for a few seconds and then throws this error. No other error is thrown.

Error 324 (net::ERR_EMPTY_RESPONSE): The server closed the connection without sending any data.

I tried logout/login, doesn't help. Any ideas except letting the server get some sleep and check back tomorrow? Maybe I should check my hosting provider?

Thanks in advance

Valentijn

Link to comment
Share on other sites

While it's true that we could all use a little more sleep, I don't think that'll solve the problem in this case.  8) We need a more detailed error message. Take a look at what's the last entry in /site/assets/logs/errors.txt and paste it here. Or edit /site/config.php and set debug to true. Also, can you remember what the last edits that you made were? Did it involve moving pages or changing templates? Did you recently make any changes to the templates or fields used by this page? If so, please describe the changes that were made.

Link to comment
Share on other sites

- Debug is set to true. Doesn't throw an error. It's just that the server doesn't respond at all.

- in error.txt there are no error logs of yesterday.

I remember editing very fast. I had just clicked the unlock checkbox, pressed save. And then it started hanging. So I did a full page refresh via the browser refresh button. I think since that moment I had this problem.

Not sure if this info helps.

My hosting provider is also looking into it.

Link to comment
Share on other sites

Ok, hosting provider checked everything. Everything is working properly on the server. There seems to be something wrong with the mysql update mechanism, as it is only when saving pages.

I'll try to reïnstall and see what that gives. Just hope my mysqldb is nt corrupt..

Ryan I can give you access to the installation if you want to..

Link to comment
Share on other sites

If you have easy access to PhpMyAdmin, you might want to checkbox all the tables and then choose "repair" at the bottom. Just in case there is something amiss in one of the tables, that will fix it. However, always export the database to an SQL dump (also in PhpMyAdmin) before making any changes to it.

Assuming a database repair is not the issue, I would guess that we've got an infinite loop occurring somewhere, based on what you've described. What version of ProcessWire are you using (2.0 or 2.1) and do you have any 3rd party modules installed?

I'll be happy to take a closer look from here if you'd like. Just PM or email me any info I need to get to it. My email is ryan at this domain name.

Link to comment
Share on other sites

I received your email–thanks. Just took a look here and I think the problem is a circular page reference. I only encountered it on pages where multiple languages were defined. All other pages saved just fine. For instance, these 3 pages reference each other in the fields alt_lang_1 and alt_lang_2:

/revive/en/home/

/revive/nl/home/

/revive/fr/home/

(along with all the others under the language page hierarchy)

So lets say you are saving /revive/en/home/. That in turn causes /revive/nl/home/ and /revive/fr/home/ to be loaded, which in turn are both attempting to load /revive/en/home/, and each other. So we end up with a bit of a complex circular reference.

This circular reference doesn't happen when the page is being viewed or loaded because PW keeps a page cached in memory as soon as it's loaded. As a result, the circular reference can be resolved. But when saving a page, we don't work with cached data so a circular reference like that can cause a problem (an endless loop).

I would like to try and see if there is some way to solve this, but I don't want to start playing around with files on your live server unless this is a development site. Let me know? If not, I'll make a copy on my own server. I also might not be able to do it today just because I've got another deadline to meet this afternoon. But can experiment more with it tomorrow.

If you need an immediate resolution, I would solve it by only managing your references in one of the branches. For instance, let the /en/ branch maintain reference to the alternate language pages. If I understand your site's layout correctly, the circular reference isn't actually necessary and it's only creating more work. Your other pages could get the same info just by polling the /en/ version of themselves, i.e.

<?php
$en = $pages->get("alt_lang_1|alt_lang_2=$page"); 
$alt1 = $en->alt_lang_1;
$alt2 = $en->alt_lang_2; 

However, even if you take that route, I'd like to see if there's a way we can prevent PW from going into an infinite loop when it encounters this sort of circular reference. So keep a backup copy if you change it. :)

Link to comment
Share on other sites

Thankyou so much Ryan! Makes perfect sense now... :)

I've just made an export of the mysql and copying the site structure. I'll send it to you in a .zip as I rather continue the work on the site.

It's not that I don't know any other other way to do this. But I wanted to solve it with 1 .php template. In the example you give you need 2 templates, one with the lang_fields and one without. I can alway not fill it in, but I rather not have unused fields in a template.

best regards

Valentijn

Link to comment
Share on other sites

I'm currently working on a rather big/complex site with multiple languages. I created different language paths in the root. /de/ & /ch-en/, /fr/ & /fr-en/. Actually those are two different domains at the end. I solved the language switch link with having a page reference field. But there I'm doing only a one-sided reference from /de/ to a page in /ch-en/. From the english page, when loaded I do a back trace check for a page reference that links to the current page.

But I didn't know that page references are loaded when saving. Anyway, is there any drawback in doing it like this or would there be any better solution to having language pages linked? Also regarding doing a back trace, which neccessarely need to go through all other language pages, is there any drawback or performance issue when having 1000's of pages? There will be only around 100 Pages in each language trees. I know, I'll do more filtering regarding the templates to limit the find, but limit doesn't work here.

Here's my current code for the language link. Will be more complex ones all language trees are in place, also this solution wouldn't work as easy when having more than 2 languages.

   <?php

// if a page is selected in the language_page field
   if($page->language_page_en){
       echo "\n\t<li><a href='{$page->language_page_en->url}'>English</a></li> | ";
   }
   else{
// if page found with reference to current page
$de = $pages->get("/de/")->find("language_page_en=$page")->first();
if($de) echo "\n\t<li><a href='{$de->url}'>Deutsch</a></li> | ";
   }

(Edit: updated my code example, cause first one wasnt optimized.)

I'm still working on building up the german pages, and only set up few english pages for testing. So this solution seemed the most easy and straight forward, and couldn't think of another solution.

EDIT:

Just thinking a little more, I think best would be on big sites to use markup cache?

If having more than 2 language, I think possible would be to only have the "primary" language pages reference to all the other language pages, but having separate page reference field for each language. Then from the main language it would be easy to render the links, and from the other side there could be a back trace to the main language page and from there getting all the other references of other languages. Hope that all makes sense.

Link to comment
Share on other sites

Well that's what Ryan proposed to do to fix the problem. But like I said, then you have a 1 template for the main language  with x fields + 1 reference field and 1 template exactly the same without the reference.

I was looking for a solution with only 1 template.

Actually now I have a separate tree with all the references, then off course you could say I also have 2 templates. But it's only 1 output template and that's what's important to me.

Link to comment
Share on other sites

Yeah, I'm probably too strict  :)

hehe, could be. I'm mostly using "collapse if empty" option on most fields, which is a really nice feature. I think having some fields unused will not make much of a difference. I remember Ryans example site, he uses also a sidebar field, if empty it will look the parent up for the next filled sidebar and outputs it. I use that concept for background images on each page where it is used quiet prominent. In the same template I also have an optional iframe url field and pdf download references that can be set and will output after bodytext content. And even more, if children of a special accordion template is found same php will generate a accordion of them. If the layout, pagetype design concept is simple enough this works pretty well and can be extended quiet well using only one template in pw and one php file. From there I can still split up or create a more restrictive template if really needed.

Just sharing how I currently work on a site in PW cause it makes me happy. :) And I really liked to see what others come up with. Different requirements of a website need different setups, and it's always up to the one building it or using it.

Link to comment
Share on other sites

Just fixed this in the latest commit. The problem turned out to be in the Page::__clone() function. If there were page references pointing at each other, it could cause an endless clone loop. I've fixed it by preventing it from cloning Page properties that are themselves Page objects (which didn't need to be cloned anyway).

Thanks for providing me the Revive site to test with, this was hugely helpful. If you grab the latest commit, it should now work with your Revive site just fine.

Link to comment
Share on other sites

You are absolutely right, it wasn't showing up on GitHub. And yet locally it told me there was nothing to push or commit. So I had to go in and add a comment to the line in order to make something change so it could be re-committed. Must be a GitHub bug. Confirmed it's up there now. Thanks for letting me know, this change might not have shown up there for weeks otherwise.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...