Jump to content

[solved] moved Local-PW online: Error=Call to a member function hasRole()


horst
 Share

Recommended Posts

Topic is solved. Reason: human error

I idiot simply have exported the wrong DB to the online installation!

-----------------------------------------------------------------------------

Hi,

have some trouble when try to move local installation online.

I have copied all files via FTP, have deleted sessions and cache files, have set write permissions to folders and updated DB-credentials.

Have transferred the complete DB from local to Online.

Online PHP version is 5.2.12-nmm4, but I also have switched it to CGI-Version 5.3.18-nmm1. It behaves exactly the same:

When try to access root '/' or '/processwire/' or any other url I get the Error:

Fatal error: Call to a member function hasRole() on a non-object in /htdocs/wire/core/Page.php on line 1275

The Line in page.php is

		$template = $this->getAccessTemplate();

var_dump($template) is NULL after that line, - $this->getAccessTemplate() tries to

       return PageAccess::getAccessTemplate($this);

// the method in PageAccess:
    /**
     * Returns the template from which we get our role/access settings from
     *
     * @return Template|null Returns null if none    
     *
     */
    public static function getAccessTemplate(Page $page) {
        $parent = self::getAccessParent($page);
        if(!$parent->id) return null;
        return $parent->template;
    }

whereas var_dump($this) at this point is:

object(Language)#216 (23) { ["isDefaultLanguage:protected"]=> bool(true)
...

the default-language!

Any help is apreciated.

Edited by horst
Link to comment
Share on other sites

Hi Ryan, :(

have tried the last Dev-Branch, with PHP 5.2 I get

Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM in /htdocs/wire/core/Modules.php on line 241

so, assume that the Dev-Branch is for PHP 5.3.+

When switching to it I have nearly same Error as before, (other Line, but same code):

Fatal error: Call to a member function hasRole() on a non-object in /htdocs/wire/core/Page.php on line 1348

I'm checking for returned NULL, and it never passes this point. The very first arrivel throws the error. When I catch it, the var_dump is:

object(Language)#219 (25) {
  ["isDefaultLanguage":protected]=>
  bool(true)
  ["template":protected]=>
  object(Template)#182 (12) {
    ["filename":protected]=>
    NULL
    ["filenameExists":protected]=>
    NULL
    ["fieldgroup":protected]=>
    object(Fieldgroup)#160 (11) {
      ["settings":protected]=>
      array(2) {
        ["id"]=>
        int(97)
        ["name"]=>
        string(8) "language"
      }
      ["removedFields":protected]=>
      NULL
      ["fieldContexts":protected]=>
      array(0) {
      }
      ["data":protected]=>
      array(2) {
        [1]=>
        object(Field)#151 (9) {
          ["settings":protected]=>
          array(5) {
            ["id"]=>
            int(1)
            ["type"]=>
            object(FieldtypePageTitleLanguage)#141 (7) {
              ["allowTextFormatters":"FieldtypeText":private]=>
              bool(true)
              ["data":protected]=>
              array(0) {
              }
              ["useFuel":protected]=>
              bool(true)
              ["className":"Wire":private]=>
              string(26) "FieldtypePageTitleLanguage"
              ["localHooks":protected]=>
              array(0) {
...

With the identical DB I have no errors on local setup. How can that be? (I have double checked the DB with dumping both to sql-files and compare with diff tool)

Link to comment
Share on other sites

@Ryan, if you want I can give you FTP- and DB-Access.

It is my new Portfolio, I have worked on the last two weeks whenever I've found time. So, many work has to be done for JS and Styles, but also a lot of PW coding what I don't want do from scratch again (if possible). :)

Link to comment
Share on other sites

have tried the last Dev-Branch, with PHP 5.2 I get
Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM in /htdocs/wire/core/Modules.php on line 241

That error translates to "Unexpected use of double colon". It's not something that should matter between PHP 5.2 and PHP 5.3, and that particular block of code hasn't changed. (though there have been other changes in Modules.php, and maybe this is a side effect?). That error can occur when there is a module file that is named differently from the class within it. This is why PW requires that a module class HelloWorld be contained in a file called HelloWorld.module. 

With the identical DB I have no errors on local setup. How can that be? (I have double checked the DB with dumping both to sql-files and compare with diff tool)

It's unusual for sure, I'm not sure what the issue could be. Do you know of any other differences in the server setup? Opcode cache or some other PHP stuff going on? It might be good for us to look at the phpinfo() output. 

Also, what 3rd party modules do you have installed?

@Ryan, if you want I can give you FTP- and DB-Access.

If you could PM me any relevant info to login via FTP, and to your PW admin, I should be able to debug this. 

  • Like 1
Link to comment
Share on other sites

Hi Ryan, many thanks for looking at this.

 ...

It's unusual for sure, I'm not sure what the issue could be. Do you know of any other differences in the server setup? Opcode cache or some other PHP stuff going on? It might be good for us to look at the phpinfo() output. 

Also, what 3rd party modules do you have installed?

I will do a phpinfo() from local install and send it to you.

The modules are:

  • ImagesManager
  • Thumbnails
  • ImageMinSize
  • HorstNogajskiPortfolio (it hooks into ImagesManager->setMetadata)
  • FieldtypeTextUnique
  • ProcessLoginHistory
  • Minify
  • ModulesManager

In meantime I have setup a second copy and have disabled most of the modules, (only ImageMinSize and FieldtypeTextUnique is installed) but with no luck.

Local it works, online same error as before.

Link to comment
Share on other sites

@Ryan: I have done a big mistake! I have exported the wrong DB-Version. :-[

I have local setup pw3b.host.local with DB pw3b

pw3c.host.local with DB pw3c

and it should be

pw3d.host.local with DB pw3d

They are different Branches of the same site.

But I can't remember why and when, I have switched pw3d.host.local to work with DB pw3c instead of 3d.

I'm so sorry that I have wasted your time!

  • Like 1
Link to comment
Share on other sites

@Ryan: I have done a big mistake! I have exported the wrong DB-Version.

No problem Horst. :) Actually I hadn't started trying to work on this yet, but was going to yesterday afternoon. Then I got your message that it sounded like the issue was resolved, so I didn't look further. But just wanted to double check that the issue is resolved and you don't still need me to look at anything there?

Link to comment
Share on other sites

No problem Horst. :) Actually I hadn't started trying to work on this yet, but was going to yesterday afternoon. Then I got your message that it sounded like the issue was resolved, so I didn't look further.

Oh, that's good!

But just wanted to double check that the issue is resolved and you don't still need me to look at anything there?

Very kind, Ryan. So with the locally used PW-Version every works fine in PHP 5.2 and 5.3. When I switch to the last PW-DEV-Branch it only works with PHP5.3 (AddHandler php53-cgi .php), but with PHP 5.2 I get this Parse-Error: unexpected T_PAAMAYIM_NEKUDOTAYIM in /htdocs/wire/core/Modules.php on line 241, (but I also have installed all modules again).

With the last stable PW-Version I don't get this Parse-Error in PHP 5.2. and everything works fine. If you are interested and want look into this you may do, but for me it is pretty fine to go with the stable Branch.

If you want to look into this, you can switch PHP in first line of htaccess, and there are three wire folders to switch between versions: wire.dev, wire.orig, and wire (the last stable). I don't need to use this installation because I have setup allready a second one that I can use. So if you want you can do with it what you want.

  • Like 1
Link to comment
Share on other sites

Thanks Horst. I can't come up with any theories on why that particular error would occur, and have never seen it anywhere else. So if it's not holding you up, I think I may wait a bit to see if anyone else reports the same thing. 

Link to comment
Share on other sites

  • 1 month later...

Hey Guys,

I'm probably the mega newbie here but I got the same error and even with this info can't figure it out.

I created a repeater field, en put that into a page, but when I do and I want to move or edit that page it gives me the following:

Error: Call to a member function hasRole() on a non-object (line 1275 of [...removed content...]/wire/core/Page.php) 
This error message was shown because you are logged in as a Superuser. Error has been logged.

is there something really obvious i'm doing wrong?

Thanks in advance,

Bram Wolf

Link to comment
Share on other sites

This is the function that is throwing that error:

/**
* Is this page public and viewable by all?
*
* This is a state that persists regardless of user, so has nothing to do with the current user.
* To be public, the page must be published and have guest view access.
*
* @return bool True if public, false if not
*
*/
public function isPublic() {
    if($this->status >= Page::statusUnpublished) return false;	
    $template = $this->getAccessTemplate();
    if(!$template->hasRole('guest')) return false;
    return true; 
}

I don't think what you are having is the intended behaviour, but try changing the status of the page before moving it. If it's unpublished, publish it. If it's published, unpublish it.

is there something really obvious i'm doing wrong?

One really obvious thing that you are doing wrong, is to show the raw error info at a public forum. There's a reason to it being shown only to superusers ;)

I will edit your post to remove the sensible information.

  • Like 1
Link to comment
Share on other sites

Thanks for removing it man ,

Please bare with my newbieness ;) I did what you suggested and removed the page, created a new one, published and it works fine :)

except for the fact that when I enter some info through my setup repeater field and view the page it doesn't show the content of the

repeater field. It only shows my the title, and the page does show up in the menu's and site maps. but not the content. Any ideas on this

specific dilemma? :)

Gr,

Bram 

Link to comment
Share on other sites

It doesn't seem to have any? This is the entire content of my body tag the page displays:



    <p id='bgtitle'>Wand panelen</p>    

    <div id="masthead" class="masthead">

        <div class="container">

            <a href='/wijdeven/'><p id='logo'>ProcessWire</p></a>
        
            <ul id='topnav'><li><a href='/wijdeven/'>Home</a></li><li><a href='/wijdeven/about/'>About</a></li><li><a class='on' href='/wijdeven/wand-panelen/'>Wand panelen</a></li><li><a href='/wijdeven/templates/'>Templates</a></li><li><a href='/wijdeven/site-map/'>Site Map</a></li><li><a href='/wijdeven/koel-panelen/'>Koel Panelen</a></li></ul>

            <ul id='breadcrumb'><li><a href='/wijdeven/'>Home</a> > </li></ul>

            <h1 id='title'>Wand panelen</h1>

            <form id='search_form' action='/wijdeven/search/' method='get'>
                <input type='text' name='q' id='search_query' value='' />
                <button type='submit' id='search_submit'>Search</button>
            </form>

            <a href='/wijdeven/site/assets/files/1/westin_interior1.jpg'><img id='photo' src='/wijdeven/site/assets/files/1/westin_interior1.232x176.jpg' alt='Westin Peachtree Atlanta hotel lobby area.' width='232' height='176' /></a>
        </div>
    </div>

    <div id="content" class="content">

        <div class="container">

            <div id="sidebar">

                
                <div class='sidebar_item'>

                    <h3>About ProcessWire</h3><p>ProcessWire is an open source CMS and web application framework aimed at the needs of designers, developers and their clients. </p><p><a href="http://processwire.com/about/'>http://processwire.com/about/" target="_blank">About ProcessWire</a><br /><a href="http://processwire.com/api/'>http://processwire.com/api/">Developer API</a><br /><a href="http://processwire.com/contact/'>http://processwire.com/contact/">Contact Us</a><br /><a href="http://twitter.com/rc_d">Follow Us on Twitter</a></p>

                </div>

            </div><!--/sidebar-->

            <div id="bodycopy">
            
                
                

            </div><!--/bodycopy-->

        </div><!--/container-->

    </div><!--/content-->

    <div id="footer" class="footer">
        <div class="container">
            <p>Powered by <a href='http://processwire.com'>ProcessWire Open Source CMS/CMF</a> © 2013 <a href="http://www.ryancramer.com">Ryan Cramer Design, LLC</a></p>
        </div>
    </div>

other than that I just published the page from the admin panel, I can't find any code on the backend of the site.

Gr,

Bram

Link to comment
Share on other sites

Hm, at this point I would say it's better that you go way back and forget this particular problem for now... One of the main ideas of processwire is that the software makes very few assumptions on what you want to do. So, you have to write code for almost anything, and that's the only way things will appear on the site. This is a great thing, since it allows you great flexibility with easy to write code (I can assure you this), but you can't expect to do things with point and click.

So, my advice is that you learn how all this works before jumping into more particular things as the repeaters. Here are some links that can help you to start:

http://wiki.processwire.com/index.php/Small_Project_Walkthrough <- best place to start

http://processwire.com/api/ <- everything you need is here

http://processwire.com/tutorials/ <- more tutorials

http://cheatsheet.processwire.com/ <- you will love this one later

  • 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

×
×
  • Create New...