Jump to content

nixsofar

Members
  • Posts

    13
  • Joined

  • Last visited

Posts posted by nixsofar

  1. There might be an obvious answer, but I can't figure it out:

    I have an admin page containing custom HTML, based on the ProcessSimpleAdminPage module

    As intended, it shows an extra tab in the admin area next to "Pages", "Setup", "Modules", "Access" for the superuser.

    There is a role "editor" with permissions that let them only see the "Pages" tab.

    How can I achieve that such an "editor" can also see the custom tab in addition to "Pages"?

  2. Edit This was the second time I had a hard time debugging a mysterious "processwire error". My lesson:

    I will keep in mind that there are circumstances when neither pw, php nor the server software can give me appropriate error messages or log entries.

    So first thing if firefox tells me 'Unable to complete this request due to an error' next time will be checking config.php for syntax errors

    $ php -l site/config.php
    

    and if I get an empty server response because of an apache segfault like "The connection was reset" (http) or "Secure Connection Failed" (https) I'll very carefully check all my own code in site/templates. If necessary, by disabling and re-enabling script by script.

     

    --

    Found my stupid error. It was in this little function in _func.php that should retrieve the second level parent of a page:

    function getsubpar($page){
        $parid = $page->parent->id;
        ## if($parid == 1){  ##### WRONG! CAUSES APACHE SEGFAULT
        if($parid <= 1){
            return $page;
        }else  {
            $subpar = getsubpar($page->parent);
            return $subpar;
        }
    }
    

    With parent id 0 it would recurse forever. Can't expect error messages from a crashed Apache module. Still strange the crash happened exactly at this line in TemplateFile.php

    There might be a better way to get these subparents, but pw is working again, problem solved.

    Thanks to all!

    • Like 2
  3. I have an odd issue with PW 2.7.2 on a Debian 8.4 server, Apache 2.4.10, PHP 5.6.19-0+deb8u1

    From a certain point I was getting an empty server response when calling any page (Firefox http: "The connection was reset", https: "Secure Connection Failed" / "The connection to the server was reset while the page was loading.")

    I've tracked it down to wire/core/TemplateFile.php, line 180  

    require($_filename);
    

    I can exit ok before this line, but an exit() at the next line won't be reached
     

    Except for the debug lines, all files in the wire directory tree are left unchanged   

    Additionally I've checked all files for syntax errors

    $ find . -regex '^.*\.\(php\|module\|inc\)$'|grep -v '\.phpstorm\.meta\.php' | xargs -i php -l {} | grep -v 'No syntax errors'
    

    after having had a similar experience as a result of a typo in config.php

    This is the context:

    wire/core/TemplateFile.php
    
    154     /**
    155      * Render the template -- execute it and return it's output
    156      *
    157      * @return string The output of the Template File
    158      * @throws WireException if template file doesn't exist
    159      *
    160      */
    161     public function ___render() {
    162 
    163         if(!$this->filename) return '';
    164         if(!file_exists($this->filename)) {
    165             $error = "Template file does not exist: '$this->filename'";
    166             if($this->throwExceptions) throw new WireException($error);
    167             $this->error($error);
    168             return '';
    169         }
    170 
    171         $this->savedDir = getcwd();
    172 
    173         chdir(dirname($this->filename));
    174         $fuel = array_merge($this->getArray(), self::$globals); // so that script can foreach all vars to see what's there
    175 
    176         extract($fuel);
    177         ob_start();
    178         foreach($this->prependFilename as $_filename) {
    179                 if($this->halt)break;
    180                 die( "regular exit here");                                            ###### DEBUG
    181                 require($_filename);                            ####### PROBLEM HERE! ######
    182                 die("won't exit here - empty server response instead");               ###### DEBUG
    183 
    184         }
    185         if(!$this->halt) require($this->filename);
    186         foreach($this->appendFilename as $_filename) {
    187             if($this->halt) break;
    188             require($_filename);
    189         }
    190         $out = "\n" . ob_get_contents() . "\n";
    191         ob_end_clean();
    192 
    193         if($this->savedDir) chdir($this->savedDir);
    194 
    195         return trim($out);
    196     }
    

    Any ideas how to debug this?

  4. Thanks for your answers! And the hint about the google search. Unfortunately, it doesn't deliver any result for $pages->add (except this very post here.)

    Highly praised as the API cheatsheet is everywhere, I'd really suggest either to keep it exhaustive or to add a notice that it isn't.

    Asking newbies to dig in the source code for extremely convenient functions like this is not really an option in my eyes.

    Just my opinion.

    Still very excited and thankful about PW!

  5. Hi!

    New to Processwire, built one site with it and a great big fan already.

    Not that it was too hard to figure this one out, but where in the reference docs would I find the syntax of

    $newpage = $pages->add ( template, parent, url, array ( field => content, ... )

    besides the generic $a->add($item)?

    Don't want to miss anything similar

×
×
  • Create New...