Jump to content
photoman355

Strange 404 after adding field value?

Recommended Posts

I've just come across a really strange problem where processwire is throwing a 404 error after I enter a value into one of my fields.  I'm sure this is probably down to my code.  

I have a set of fields that when a value is entered some output is echoed to my template.  Every field works as expected except the last field which throws the 404 after entering a value and saving the page.  

Here's the code.

 <?php 
$settings = $pages->get("/site-settings/");

if ($settings->social_facebook) echo "<li><a class='icon-small small-icon-facebook' href='{$settings->social_facebook}' target='_blank'></a></li>";
if ($settings->social_twitter) echo "<li><a class='icon-small small-icon-twitter' href='{$settings->social_twitter}' target='_blank'></a></li>";
if ($settings->social_linkedin) echo "<li><a class='icon-small small-icon-linkedin' href='{$settings->social_linkedin}' target='_blank'></a></li>";
if ($settings->social_youtube) echo "<li><a class='icon-small small-icon-youtube' href='{$settings->social_youtube}' target='_blank'></a></li>";
if ($settings->social_picasa) echo "<li><a class='icon-small small-icon-picasa' href='{$settings->social_picasa}' target='_blank'></a></li>";
if ($settings->social_upon) echo "<li><a class='icon-small small-icon-stumble' href='{$settings->social_upon}' target='_blank'></a></li>";
?>

I'm guessing there's a better way to write this but not quite sure why it's throwing an error.  I've tried deleting and recreating the last field with a different name but it still throws the same error.

Can anyone help?

Share this post


Link to post
Share on other sites

PW fields have nothing to do with 404. Its a page not found error page that always comes from when entering a url that does not exist or is not viewable.

Share this post


Link to post
Share on other sites

Thanks Soma.  I don't understand what's causing the 404 as all I'm doing is saving a field value on an admin page.  The field isn't redirecting any urls it's only a textfield to provide output for the template.  

Is there a procedure to troubleshoot?

Share this post


Link to post
Share on other sites

Ah when saving the page?

Of course if you provide more infos so we could reproduce we may be able to know whats going on.

And what does the template code have to do with it?

Share this post


Link to post
Share on other sites

so in other words you have a text field called social_upon and when you enter data into that field and save, you get a 404 error.

You should post the URL that PW is redirecting to on save;

try disabling some modules also, to account for possible conflicts; also post screenshot ?

Share this post


Link to post
Share on other sites

@Soma I only thought the template code was at fault because everything worked up until I added the new code.

@Macrura That's correct, entering data into any of the other text fields and saving works fine but for some strange reason entering data into social_upon and saving throws the 404.  This happens even if I empty one of the other fields and fill the social_upon field.  I've tried creating a new field with a different name but no joy.

For URL's the page is at mydomain.com/login/page/edit/?id=1011.  When I hit save I get the 404 error message "The page you were looking for is not found.Please use our search engine or navigation above to find the page.".  The URL on that page is exactly the same.

As I'm developing I still have the default site template and it's relevant files installed (my home.php has been modified).  My new template calls a different header, footer and template files. It's redirecting to the default install template page possibly because it's assigned as the default for 404's? 

Modules wise I don't have many installed outside the default ones just, Fieldtype Crop Image, CK Editor, HTML Purifier, Modules Manager and Process Page Delete.

Is there anything I should try?  

Share this post


Link to post
Share on other sites

mydomain.com/login/page/edit/?id=1011 ... is /login/ you PW admin/installation?

It's just I'm not sure where template files would be involved in backend editing? This is not possible I think.

What fields are they? What data do you enter extactly? The only scenarion that comes to mind is that you enter some data in that last field that is suspicious and maybe some security setting on server does not allow for posting those through a form and you get a 404... But maybe not.

Ok seeing the modules list, try deinstalling some of those like Process Page Dele, Modules Manager, HTML Purifier?

Share this post


Link to post
Share on other sites

yes it sounds like you're getting booted from the admin, or there is some error going on, perhaps with duplicates in the database...

one thing i would try is repairing the database, you can login to your phpMyAdmin and run the database repair

Share this post


Link to post
Share on other sites

@soma Yes I changed the default login from /processwire to /login mainly to make it more memorable for clients.

For setup I have 6 textfields (all use the default settings) and the last textfield is what I'm having trouble with.  I did get a little further on today.  Tried repairing the database as Macrura suggested which all checked out fine.  I then returned to the admin and entered some different data with some success.  

What I was entering before was a URL in the format "http://www.google.com" and saving the page throws an error.  I changed the entry to "www.google.com" and the page saves fine, no 404.  Very strange.  Next I changed the last field from a textfield to a URL.  Now when I go back to the admin page in question the URL field re-writes the last entry from "www.google.com" to  "http://www.google.com".  When I hit save I get the 404 again.

It's clearly something to do with the "http://" part of the entry.  Soma you suggested this could be server security. Can you explain a bit more?

Just something else to add.  I'm currently testing out the multisite install and this particular database is a clone from another of my PW sites.  I just exported the database from a master site and imported into a new database via phpmyadmin.  I don't know if this is significant or not?  

Share this post


Link to post
Share on other sites
It's clearly something to do with the "http://" part of the entry.

I'm assuming the 404 you are getting is an Apache one rather than a ProcessWire one. You are seeing mod_security in action. When mod_security gets in the way of legitimate content management, then it's configured in an overly agressive manner. I would ask your host to loosen things up a bit, or if they can't, have them disable mod_security for your account. 

  • Like 1

Share this post


Link to post
Share on other sites

Aha that would make sense as my hosting company has been pretty poor of late.  Many thanks for the info Ryan.  How would I tell if this is definitely an Apache 404 vs a Processwire one?  

I've been in touch and asked them to lighten up the security rules and they said they've changed them but I'm still having issues.  Before I go back to them I thought I'd try to disable mod_security using htaccess.  I added "SecFilterEngine Off" to htaccess but after adding it locks me out of my PW site.  I don't have much experience on the server side so I've probably tried to change completely the wrong setting.

Is there a correct way to manually disable mod_security so I can check this is definitely the problem?  I have access to cpanel if that helps.

Share this post


Link to post
Share on other sites
 How would I tell if this is definitely an Apache 404 vs a Processwire one?  

The ProcessWire 404 will look like your site. The Apache 404 will look like plain text. Though I actually think this is mod_security either way. 

Is there a correct way to manually disable mod_security so I can check this is definitely the problem?

I think this is something that only your host can answer. Though if someone else knows better, hopefully they will reply. 

Share this post


Link to post
Share on other sites

Many thanks Ryan.  The 404 the page in question is a site-settings page that has no associated template file.  Would a processwire 404 from this page not be output as plain text anyway as there's no header and footer or would a 404 still show the admin header and footer?

I'm sure you're right in saying it's mod_security anyway.  My hosting company are useless :)

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Peter Knight
      Hi guys
      is there a checklist of items I should consider for diagnosing a series of pages which display a 404 error?
      Basically I have built a Blog and all my posts are under a folder called 'Posts'. Some of these pages successfully display while others display a 404 page. 
      This is what I have confirmed so far...
      1. All pages are within the same root folder 'Posts'
      2. All pages have the same template and fields completed
      3. All pages have the same properties under Settings > Who can access this page
      4. Pages have no redirects in place
      5. Pages have no special characters or anything funky in the URL slug
      There are no errors showing in the log either so I am stuck 😕
      Thanks
    • By Pip
      Hi, Everyone! 
      I'm currently working on a page reference field and set it for multiple pages (AsmSelect) for the input. Is there a way for me to add an image field (aka Avatar) and the title of page in the radio button? 
      I used the field name enclosed in the { }. Didn't work. It appeared a text instead. 
      Thanks in advance and hope to hear from you soon!
    • By EyeDentify
      Hello dear PW gurus.

      I have stumbled over a strange error that i all of sudden got when trying to upload an image to a images field on a page.
      There where images allready stored in the field that i wanted to keep, but during the upload the error apear and after that all images are gone from the field and i can´t upload any, i just get the error every time.
      I am running ProcessWire 3.0.153 dev.
      Update:
      After looking in the assets folder i find the folder for the page and the image files seems to be there including the ones i tried to upload when the error occured.
      But they don´t show up in the images field in the page editor.
       
      The error reported:
       
      SQLSTATE[01000]: Warning: 1265 Data truncated for column 'ratio' at row 1 And here is a screenshot of the event:

      The TracyDebugger Error reporting:

      I hope you fine folks could point me in a direction.
      But it seems our old pal set_time_limit() is back.

      Regards, EyeDentify
    • By EyeDentify
      Hello Dear PW Gurus.

      Hope you fair well in these Corona Crisis times.

      Anyhow, i have a problem with a Cryptic error message that shows up when i am trying to Delete images out of a Images field.
      The Error message does say a little but it does not make sense to me why i can´t delete the images because of it.

      Is it some permission issue perhaps?

      I will attach screenshots of it and what i did prior to it.
      I am from sweden so ignore the funny words here and there.

      Hope you all can send me on the right track.
      i am running PW 3.0.139 on this install.

      Step1:

      Step 2: Select the images with the trashcan symbol

       
      Step 3: Cryptic Error message

      I am scratching my head on this one, have not seen this before.

      Thankfull for all help.
      /EyeDentify
    • By DV-JF
      Hey all, hope you're feeling well these days!
      Short question: Under "Setup > Templates" it's possible to sort the templates by last modified. Is this possible for fields view to?
      Long explanation:
      Currently I am in the process of programming a reusable template and often have to copy several fields & templates from different PW installations into my "master version".
      Therefore it would be good to see already in the field list when the last modification has taken place.
      Stay healthy & don't forget to wash you hands - many greets!
×
×
  • Create New...