Jump to content

Method Page::render does not exist... sitewide on every page?


cosmicsafari
 Share

Recommended Posts

Hi all,

Starting work for a new client, so pulled down a copy of their existing PW site.

All looks normal in terms of the codebase structure, set it up as I would normally for any PW site yet I everytime I attempt to view a page I get:

Quote

Error: Exception: Method Page::render does not exist or is not callable in this context (in /path/to/website/public/wire/core/Wire.php line 416)

#0 /path/to/website/public/wire/core/Page.php(1475): Wire->___callUnknown('render', Array)
#1 /path/to/website/public/wire/core/Wire.php(348): Page->___callUnknown('render', Array)
#2 /path/to/website/public/wire/core/WireHooks.php(548): Wire->_callMethod('___callUnknown', Array)
#3 /path/to/website/public/wire/core/Wire.php(373): WireHooks->runHooks(Object(Page), 'callUnknown', Array)
#4 /path/to/website/public/wire/core/Wire.php(374): Wire->__call('callUnknown', Array)
#5 /path/to/website/public/wire/modules/Process/ProcessPageView.module(205): Wire->__call('render', Array)
#6 /path/to/website/public/wire/core/Wire.php(348): ProcessPageView->___execute(true)

From what I can gather its running PW version 2.8.

On the live environment where I copied it from and its working fine, they are apparently running PHP 7.1 whereas I am running PHP 7.3 locally, just incase that may be a cause for the issue.

Any ideas as nothing seems obvious to me at this point.

 

 

Link to comment
Share on other sites

16 hours ago, dragan said:

I would try to upgrade PW. If that doesn't solve it, switch to PHP 7.1 locally and see if the error persists.

Is this only in debug mode or also when disabled? Backend is fine?

It occurs regardless of the debug settings and happens on every page, can't access admin login page to get any further.

I'm just about to try it out on a machine running PHP 5.6, out of curiosity to see whether I run into the same error.

From doing some more investigations, I think it may be related to a custom module which appears to use a lot of web hooks.

Link to comment
Share on other sites

So I have done some more digging with this one and worked backwords to find that the issue appears to be the one of the many $page->render calls within ProcessPageView.module, within the __execute method to be precise.

Aside from that im still completely stumped as to why it wouldn't be callable.

Find it quite strange as at first I thought maybe it couldn't get the page object in order to run the render method, but I added in some logging within ProcessPageView.module around the offending lines of code. I can get the page title & according to gettype() its an object, so im well confused at this point. ?

The code of the __execute method, including my added logging incase its of any use:

	public function ___execute($internal = true) {

	    error_log('ProcessPageView');
	
		if(!$internal) return $this->executeExternal();

		$this->responseType = self::responseTypeNormal;
		$config = $this->config; 
		$debug = $config->debug; 
		if($config->usePoweredBy !== null) header('X-Powered-By:' . ($config->usePoweredBy ? ' ProcessWire CMS' : ''));
		if(is_array($config->pageNumUrlPrefixes)) foreach($config->pageNumUrlPrefixes as $prefix) {
			$this->pageNumUrlPrefixes[$prefix] = $prefix;
		}
		if(!count($this->pageNumUrlPrefixes)) {
			$prefix = $this->config->pageNumUrlPrefix;
			if(strlen($prefix)) $this->pageNumUrlPrefixes[$prefix] = $prefix;
		}

		$this->pages->setOutputFormatting(true); 
		if($debug) Debug::timer('ProcessPageView.getPage()'); 
		$page = $this->getPage();

		if($page && $page->id) {
			if($debug) Debug::saveTimer('ProcessPageView.getPage()', $page->path); 
			$page->setOutputFormatting(true); 
			$_page = $page;
			$page = $this->checkAccess($page); 
			if(!$page || $_page->id == $config->http404PageID) {
				return $this->pageNotFound($_page, $this->requestURL, true, 'access not allowed');
			}
			
			if(!$this->delayRedirects) {
				$this->checkProtocol($page); 
				if($this->redirectURL) $this->session->redirect($this->redirectURL);
			}
			
			$this->wire('page', $page); 
			$this->ready();
			$page = $this->wire('page'); // in case anything changed it
			
			if($this->delayRedirects) {
				$this->checkProtocol($page); 
				if($this->redirectURL) $this->session->redirect($this->redirectURL);
			}

			try {
				$this->wire()->setStatus(ProcessWire::statusRender);

				if($this->requestFile) {
					
					$this->responseType = self::responseTypeFile;
					$this->sendFile($page, $this->requestFile);
					
				} else {

					$contentType = $page->template->contentType;
                    error_log('Page: '.$page->title);
					error_log(gettype($page));
					if($contentType) {
						if(strpos($contentType, '/') === false) {
							if(isset($config->contentTypes[$contentType])) {
								$contentType = $config->contentTypes[$contentType];
							} else {
								$contentType = '';
							}
						}
						if($contentType) header("Content-Type: $contentType");
					}

					if($config->ajax) {
						$this->responseType = self::responseTypeAjax;
						return $page->render();

					} else {
                        error_log('ERRORS AT THIS POINT');
						return $page->render();
					}
				}

			} catch(Wire404Exception $e) {
				return $this->pageNotFound($page, $this->requestURL, false, '404 thrown during render');
			}

		} else {
			return $this->pageNotFound(new NullPage(), $this->requestURL, true, 'requested page resolved to NullPage'); 
		}

	}

 

Link to comment
Share on other sites

Managed to solve my issue, documenting what I done here for others and future reference.

So basically I never actually figured out the specifics of what was causing the fatal error, however as mentioned previously it did seem related to the custom module that was setting up numerous webhooks.

After trying numerous things, I ended up deleting the contents of the cache table within the database, which got rid of my inital fatal error and let me render pages.

Now that I could see pages, albeit with some errors I was able to then log into the backend. Wherein I refreshed the module cache which appears to have resolved the issue.

Hopefully the above will be of use to someone in future... more than likely myself as I have a habit of running into the same odd errors. ?

  • Like 2
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

×
×
  • Create New...