Jump to content
cosmicsafari

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

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.

 

 

Share this post


Link to post
Share on other sites

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?

Share this post


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

Share this post


Link to post
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'); 
		}

	}

 

Share this post


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

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 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?
    • By antoiba86
      Well, I am trying to put the blog template like the home template but when I change the home template to the blog template the page explote. The version is processwire 3.055 and this is the website.
      http://www.antoibaprogramming.com/
      I think that the error is because that when is the home, the blog template try to look for the blog post but it didn't find anything so it crashes.
      Here is the error that it gave me.
      And here is the code. The line 660 is the "$n = $page->comments->count();"
      function ukBlogPost(Page $page, $options = array()) { $defaults = array( 'summarize' => null, // Display blog post summary rather than full post? (null=auto-detect) 'metaIcon' => 'info', 'moreIcon' => 'arrow-right', 'moreText' => __('Read more'), 'categoryIcon' => 'hashtag', 'bylineText' => __('Posted by %1$s on %2$s'), ); $options = _ukMergeOptions($defaults, $options); $title = $page->title; $date = $page->date ? $page->date : $page->createdStr; $name = $page->createdUser->name; $body = $page->body; $metaIcon = ukIcon($options['metaIcon']); $moreIcon = ukIcon($options['moreIcon']); $categoryIcon = ukIcon($options['categoryIcon']); $n = $page->comments->count(); $numComments = $n ? "<a href='$page->url#comments'>" . ukIcon('comments') . " $n</a>" : ""; if($options['summarize'] === null) { // auto-detect: summarize if current page is not the same as the blog post $options['summarize'] = page()->id != $page->id; } $categories = $page->categories->each($categoryIcon . "<a class='uk-button uk-button-text' href='{url}'>{title}</a> " ); if($options['summarize']) { // link to post in title, and use just the first paragraph in teaser mode $title = "<a href='$page->url'>$title</a>"; $body = explode('</p>', $body); $body = reset($body) . ' '; $body .= "<a href='$page->url'>$options[moreText] $moreIcon</a></p>"; $class = 'blog-post-summary'; } else { $class = 'blog-post-full'; } if($options['summarize']) { $heading = "<h2 class='uk-margin-remove'>$title</h2>"; } else { $heading = "<h1 class='uk-article-title uk-margin-remove'>$title</h1>"; } $byline = sprintf($options['bylineText'], $name, $date); // return the blog post article markup return " <article class='uk-article blog-post $class'> $heading <p class='uk-margin-small'> <span class='uk-article-meta'> $metaIcon $byline </span> <span class='categories'> $categories </span> <span class='num-comments uk-margin-small-left uk-text-muted'> $numComments </span> </p> $body </article> <hr> "; }  
      The question is how can I make to put the blog like the principal page. I don't have any idea how to do it.
    • By David Karich
      Hi, I have changed today a productive site with a PW installation in version 3.0.37 on PHP 7.1. Unfortunately, the system does not seem to run anymore. The page loads and loads and loads until the timeout (both: frontend and backend). The following error is only logged in the Error Log:
      - Premature end of script headers: index.php, referer: https://www.höhle-der-löwen.com/ - 9563#0: *21784 upstream timed out (110: Connection timed out) while reading response header from upstream - 9563#0: *21901 upstream prematurely closed connection while reading response header from upstream Does anybody have the same Problem? With PHP 7.0, everything runs smoothly.
×
×
  • Create New...