MySQL Error 1048 - GlobalArea() in 404 page

Permalink
Hi,

I try to customize my 404 page.

I added the line in site_theme_path.

My theme customize this page.

ok, but for this 404 page I've got this MYSQL Error :
An unexpected error occurred.
mysql error: [1048: Column 'cID' cannot be null] in EXECUTE("INSERT INTO Areas (cID,arHandle,arIsGlobal) VALUES (NULL,'About Us','1')")


These errors appear for GlobalArea() set in elements/footer.php which is includes in view.php.

These errors only appear for page_not_found.php ; working good for login.php

Thanks in advance for your support.

mOoSh

moosh
 
137degrees replied on at Permalink Reply
137degrees
Hi, did you find a solution? I have the same problem.
Thanks
Sam
moosh replied on at Permalink Reply
moosh
I didn't found a solution... :-(
TheRealSean replied on at Permalink Reply
TheRealSean
I am also getting the same problem looks like a bug
TheRealSean replied on at Permalink Reply
TheRealSean
A work around, is to open up the global areas single page copy it into your models folder

This seems to be an issue with pages not having a page id thus the reason its having trouble entering its id in the database, all I have done is put a check in place and if its blank set it to tbe the id of the page not found,

.note do not leave the page_not_found in edit mode.

I don't know if this is the best route, probably not, but it will give you a custom 404 page without displaying the error.

I also don't know if this will then serve the 404 header?

//default
   public function display() {
      $c = Page::getCurrentPage();
      parent::getOrCreate($c, $this->arHandle, 1);      
      parent::display($c);
   }


//modified
   public function display() {
      $c = Page::getCurrentPage();
         if(!$c->getColletionID())
         {
            $c = Page::getByPath("/page_not_found");
         }
      parent::getOrCreate($c, $this->arHandle, 1);      
      parent::display($c);
   }
137degrees replied on at Permalink Reply
137degrees
Thanks for your reply @TheRealSean.
Any chance you could clarify what you mean by the global areas single page?

Do you mean copy the single page page_not_found.php into the models folder?
And then in which file does your modified code go?

Or is there some other global areas file that I should modify?

Sorry - C5 newbie here.
TheRealSean replied on at Permalink Reply
TheRealSean
yes sorry, concrete appears to have stopped telling me when people reply?

I was referring to the file found in
/concrete/models/global_area.php

But as Westhouseit, has said it does appear to be tied to the pretty url's that fix is a much better solution :)
westhouseit replied on at Permalink Reply
Thanks. This doesn't work in 5.5, but a simple modification fixes the problem:

public function display() {
      $c = Page::getCurrentPage();
         if(!$c->cID)
         {
            $c = Page::getByPath("/page_not_found");
         }
      parent::getOrCreate($c, $this->arHandle, 1);      
      parent::display($c);
   }
westhouseit replied on at Permalink Reply
This seems to happen when Pretty URLs is enabled and URLs with index.php are used.

Try this:

Open /config/site.php

Add this line at the bottom:

define('URL_REWRITING_ALL',true);
westhouseit replied on at Permalink Reply
Okay, not completely fixed. This works for 404 errors that involve the first part of the path being valid, e.g.

domain.com/articles/hjdskghdslkg

But fails for

domain.com/hjdskghdslkg

So the fix above by TheRealSean is still needed.
137degrees replied on at Permalink Reply
137degrees
Thanks westhouseit - as always you are mr fixit. Thanks too to TheRealSean for your fix suggestions.
andrew replied on at Permalink Reply
andrew
I've done a bit of work in the latest github check-in that should address this. It looks like the page not found page wasn't getting set properly in the request object.
senshidigital replied on at Permalink Reply
senshidigital
Hi all,

I am getting this mysql error on a site's 404 page, it's on version 5.6.0.2. None of these fixes are working. Any help please?

Cheers!
foster replied on at Permalink Reply
foster
I've updated my site to 5.5.1 - took me a while to realize I needed to implement Andrew's edits in updates/concrete5.5.1/concrete/libraries/view.php

Thanks for the fix! Glad to say after putting the new code in the right place, everything works as I was hoping.

-Foster
TheRealSean replied on at Permalink Reply
TheRealSean
I think I may be missing the fix in there. I tried copying the libaries/view over to my root but still get the same problem? do I need to replace the content within the view?

Or are there more locations I need to be editing

Thanks
- Sean
paradigmthreads replied on at Permalink Reply
I'm in the same boat here. Not sure which fix I need to be implementing. Tried it in updates/concrete/models/global_area.php but no luck. Can anyone provide a definitive little guide? :P

Thanks