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 1
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.

  • Similar Content

    • By luischacon
      Hello how are you, I need help on how I can solve this, update a module and now I don't know what to do

    • By Guy Incognito
      I seem to be running into a repeated fatal error in a fresh PW install version 3.0.148. I can't quite put my finger on the pattern but it seems to be around deleting image fields or removing images from certain image fields.
      This is the trace from the log generated by trying to save a page and delete an image from an image field:
      Fatal Error: Uncaught Error: Cannot access protected property Pageimage::$original in /wire/core/PageimageVariations.php:256 Stack trace: 1. /wire/core/Pageimage.php(1327): PageimageVariations->getInfo() 2. /wire/core/Wire.php(386): Pageimage->___isVariation() 3. /wire/core/WireHooks.php(823): Wire->_callMethod() 4. /wire/core/Wire.php(450): WireHooks->runHooks() 5. /wire/core/Pageimage.php(1369): Wire->__call() 6. /wire/core/Pageimage.php(399): Pageimage->getOriginal() 7. /wire/core/WireData.php(333): Pageimage->get() 8. /wire/core/PageimageVariations.php(256): Pro Line 256 of /wire/core/PageimageVariations.php Earlier in the day I was experimenting with custom fields for images for the first time and kept running into this error, thinking it was me using this feature wrong and not having time to read up I deleted the custom image fields template and went about my business. So now I don't know if I triggered an issue or whether it was never related to the custom image fields in the first place?
      Any ideas?
    • By Manuel
      Hi everybody!
      I'm new to PW and just did the beginner-tutorial “Hello Worlds”, a beginning ProcessWire tutorial --> Link
      After extending the template from the original tutorial with a page_reference-Field (Page-Field value type is configured as single page),
      PW throws a fatal error when i try to output multiple pages:
      $planets = $pages->find("template=planet, sort=-title"); foreach($planets as $planet) { echo $planet->title; echo $planet->planet_reference->title; } Should return three Pages, but throws the following error:
      When i try to output the field with a single page, everything just works fine:
      $planet = $pages->get(1018); echo $planet->title; echo $planet->planet_reference->title; I've tried to solve the problem with myself (and google), but i can't fix the error.
      Thanks a lot!

      My enviroment:
      OSX Mojave / MAMP (PHP 7.2), PW v 3.0.123
    • By cosmicsafari
      Hi all,
      Thought I had the language translation working but now when I attempt to access the language through the backend (Setup > Languages > My Language) it throws an error:
      Recoverable Fatal Error: Argument 3 passed to ProcessWire\LanguageTranslator::textdomainTemplate() must be of the type array, null given
      Can anybody shed any light on what would cause this error when trying to access my language through the settings in the backend, or attempting to view it on the frontend with its language specific URL.
      The only thing I have changed recently was moving the DB to a different location however the one exported was the one that I previoulsy had my custom language working on it previoulsy.
      Any ideas, im at a bit of a lose as to what would have caused this when it was working previously.
       
    • By blacksrv
      Hi, I got this error after login to the backend:
      Already tried to delete cache, disable all modules, update processwire to lastest version, nothing works.
      Any idea of this error?
×
×
  • Create New...