psy Posted March 11, 2023 Share Posted March 11, 2023 (edited) I've been working on a a new site for weeks. $session did it's normal, wonderful stuff until today when it didn't - boom!!! $session now occasionally holds vars from one page to another. The killer is $session->location or $session->redirect. Before redirecting, the page crashes with: I went back to basics with the default theme: Spoiler <?php namespace ProcessWire; // home.php (homepage) template file. $session->set('hello', "hello from page 1"); // Primary content is the page body copy $content = $page->body; // Append navigation to child pages underneath the body copy // See the _func.php file for the renderNav() function example $content .= renderNav($page->children); // if there are images, lets choose one to output in the sidebar if(count($page->images)) { // if the page has images on it, grab one of them randomly... $image = $page->images->getRandom(); // resize it to 400 pixels wide $image = $image->width(400); // output the image at the top of the sidebar $sidebar = "<img src='$image->url' alt='$image->description' />"; // if image has a description, display it underneath if($image->description) $sidebar .= "<blockquote>$image->description</blockquote>"; // append sidebar text content if page has it $sidebar .= $page->sidebar; } else { // no images... // make sidebar contain text content if page has it $sidebar = $page->sidebar; } // basic-page template: <?php namespace ProcessWire; // basic-page.php template file print_r($_SESSION); print_r($session->getAll()); print_r($session->hello); $session->location($pages->get(1)->url); // Primary content is the page's body copy $content = $page->body; // If the page has children, then render navigation to them under the body. // See the _func.php for the renderNav example function. if($page->hasChildren) { $content .= renderNav($page->children); } // if the rootParent (section) page has more than 1 child, then render // section navigation in the sidebar (see _func.php for renderNavTree). if($page->rootParent->hasChildren > 1) { $sidebar = renderNavTree($page->rootParent, 3); // make any sidebar text appear after navigation $sidebar .= $page->sidebar; } // in default install basic-page template // on frontend, clicking menu link from home page to about page // print_r($_SESSION); Array ( [Session] => Array ( [hello] => hello from page 1 ) ) // print_r($session->getAll()); Array ( [hello] => hello from page 1 ) // print_r($session->hello); hello from page 1 // $session->location($pages->get(1)->url); Fatal error: Exception: Method WireHttp::sendStatusHeader does not exist or is not callable in this context (in /home/path/to/my/site.com/wire/core/Wire.php line 563) #0 /home/path/to/my/site.com/wire/core/Wire.php(419): ProcessWire\Wire->___callUnknown('sendStatusHeade...', Array) #1 /home/path/to/my/site.com/wire/core/WireHooks.php(952): ProcessWire\Wire->_callMethod('___callUnknown', Array) #2 /home/path/to/my/site.com/wire/core/Wire.php(484): ProcessWire\WireHooks->runHooks(Object(ProcessWire\WireHttp), 'callUnknown', Array) #3 /home/path/to/my/site.com/wire/core/Wire.php(487): ProcessWire\Wire->__call('callUnknown', Array) #4 /home/path/to/my/site.com/wire/core/Session.php(1401): ProcessWire\Wire->__call('sendStatusHeade...', Array) #5 /home/path/to/my/site.com/wire/core/Wire.php(419): ProcessWire\Session->___redirect('/', 302) #6 /home/path/to/my/site.cli in /home/path/to/my/site.com/index.php on line 64 Fatal error: Uncaught ProcessWire\WireException: Method WireHttp::sendStatusHeader does not exist or is not callable in this context in /home/path/to/my/site.com/wire/core/Wire.php:563 Stack trace: #0 /home/path/to/my/site.com/wire/core/Wire.php(419): ProcessWire\Wire->___callUnknown('sendStatusHeade...', Array) #1 /home/path/to/my/site.com/wire/core/WireHooks.php(952): ProcessWire\Wire->_callMethod('___callUnknown', Array) #2 /home/path/to/my/site.com/wire/core/Wire.php(484): ProcessWire\WireHooks->runHooks(Object(ProcessWire\WireHttp), 'callUnknown', Array) #3 /home/path/to/my/site.com/wire/core/Wire.php(487): ProcessWire\Wire->__call('callUnknown', Array) #4 /home/path/to/my/site.com/wire/core/WireShutdown.php(405): ProcessWire\Wire->__call('sendStatusHeade...', Array) #5 /home/path/to/my/site.com/wire/core/WireShutdown.php(581): ProcessWire\WireShutdown->sendFatalHea in /home/path/to/my/site.com/wire/core/Wire.php on line 563 Using ProcessWire 3.0.212 dev PHP v8.1 (tried 7.4 & 8.0 too) Error occurs in Chrome & Firefox Editing modules, eg turning TracyDebugger on/off also triggers the problem Error occurs in front and back end. Often, clicking on a link to a different page clears the error but $session still screwy. Have no idea why PW suddenly stopped correctly wiring $session. Is this a bug? Am I doing something wrong? Help & ideas on how to fix gratefully accepted. Solved: Upload a fresh copy of WireHTTP to my server. Previous version may have been corrupted in transit. Edited March 11, 2023 by psy Problem solved Link to comment Share on other sites More sharing options...
netcarver Posted March 11, 2023 Share Posted March 11, 2023 Hi @psy Have you got anything on the site that hooks into session methods? Have you had a search for any similar open or closed issues on the processwire-issues repo? There might be something there that could help. You could try turning off unknown message method exceptions via the little-known "disableUnknownMethodException" config variable - this might get you through the line doing the redirect, but it will totally obscure the real issue here. Hopefully others might have better suggestions, or @ryan might take a look. Link to comment Share on other sites More sharing options...
psy Posted March 11, 2023 Author Share Posted March 11, 2023 @netcarver Thanks for your input. Site doesn't use any hooks Searched Google, forum but not repo. Will do so now. There was an old post that was vaguely similar but didn't have an answer. See link below Turning off the error may hide the error message but, you're right, it will totally obscute the real issue. Link to comment Share on other sites More sharing options...
netcarver Posted March 11, 2023 Share Posted March 11, 2023 How about modules that might be hooking into Session methods? Link to comment Share on other sites More sharing options...
psy Posted March 11, 2023 Author Share Posted March 11, 2023 Have uninstalled: TracyDebugger LoginRegisterPro (not used anyway) Very few other modules in use and still the error, admin & fe ? Link to comment Share on other sites More sharing options...
psy Posted March 11, 2023 Author Share Posted March 11, 2023 @ryan any ideas? Nothing that involves https works, eg admin 'Save' functions, frontend redirects. Link to comment Share on other sites More sharing options...
netcarver Posted March 11, 2023 Share Posted March 11, 2023 I suppose the next thing I would try is editing the last part of the session::___redirect() function so it uses PHP to send the needed headers, taking WireHttp() out of the equation. Something like... header("Location: $url"); exit(0); Link to comment Share on other sites More sharing options...
psy Posted March 11, 2023 Author Share Posted March 11, 2023 @netcarver I tried that on the frontend and it worked but now every time it has to wire a new page, or in admin perform some http task, it fails. My error logs are filling up fast Link to comment Share on other sites More sharing options...
netcarver Posted March 11, 2023 Share Posted March 11, 2023 That was only meant as an idea for tracking down what might be at fault - obviously revert if this site is live, my apologies, I thought it was a staging server we were talking about. Link to comment Share on other sites More sharing options...
psy Posted March 11, 2023 Author Share Posted March 11, 2023 OMG solved! ? When I was digging into wire/core/WireHTTP I think the file got corrupted, maybe during an upload to my dev server (yes, still staging) Replaced it with a new copy and site is working again @netcarver truly appreciate your help and patience. 2 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now