knop-project / knop

Web application framework for Lasso 8 and 9
18 stars 46 forks source link

Demo site doesn't work #128

Closed monsterlane closed 7 years ago

monsterlane commented 7 years ago

Followed the instructions for Lasso 9. When I try to load the demo site all I see is this:

Error:

An unhandled failure during a web request

Error Code: -9948

Error Message: Definition Not Found: knop_lang(-default=string, -fallback=boolean) Candidates were: knop_lang(default::string =?, fallback::boolean =?)

Any idea what I'm doing wrong? I filled out the DB credentials and set it on my instance in Lux. I renamed the apache.conf to .htaccess and put it in the web root with all the demo files.

johansolve commented 7 years ago

This was fixed in https://github.com/knop-project/knop/commit/67f2e75346449b8ef521fecee9df6abddea89dd5 in the 9.3 branch

monsterlane commented 7 years ago

Oh sorry I checked the releases tab but I didn't check the list of branches. I've replaced all the files with ones from the 9.3 branch and now I'm getting this error:

Error:

An unhandled failure during a web request

Error Code: -9948

Error Message: Definition Not Found: knop_database->select(array) Candidates were: knop_database->select(search::array, sql::string, keyfield::string =?, keyvalue =?, inlinename::string =?), knop_database->select(-search::array =?, -sql::string =?, -keyfield::string =?, -keyvalue =?, -inlinename::string =?)

I can browse the customer table from my instance in Lux and I'm using the same user/pass in cfg__global.inc. It doesn't seem like it has a connection?

stevepiercy commented 7 years ago

Unfortunately the demo files have not kept up with the updates to the 9.3.x branch.

PR's are welcome.

monsterlane commented 7 years ago

Ok this is my first time using Lasso any clue's on what to look for? I'm lost at the moment. I was hoping to get the demo running so I can try to make sense of the framework.

johansolve commented 7 years ago

In _library/lib_customer_list.inc, change line 20 so that the search array is a named param, like this:

    $d -> select(-search=$searchparams);

The same for other occurences of ->select

monsterlane commented 7 years ago

Thanks! I've made that change in _library/lib_customer_list.inc and _library/lib_advanced_list.inc and most of the site is working. When I go to the login page and submit the form I see this:

Error:

An unhandled failure during a web request

Error Code: -9948

Error Message: Definition Not Found: knop_form->username()
johansolve commented 7 years ago

->username is a shortcut to ->getvalue('username'). Shortcuts of that kind (using _unknowntag) are no longer supported in knop9 due to issues with signatures in method definitions

johansolve commented 7 years ago

The old Knop reference at http://knop.nu/ can be helpful, but keep in mind that it's not updated for knop9.

monsterlane commented 7 years ago

Thanks again! I changed the two lines in _action/act_login.inc and now I can submit the form but then it errors out again with this:

Error:

An unhandled failure during a web request

Error Code: -9948

Error Message: Definition Not Found: knop_user->firstname()
Error Detail:
Line    Char    File
2   55  //Users/jonathan/Sites/spiri/public//_content/cnt_login.inc

I tried changing that to knop_user -> getvalue('firstname') but it didn't like that either.

monsterlane commented 7 years ago

Figured it out, the site works now. Line 2 in _content/cnt_login.inc should be this:

<p>[$lang_ui -> loggedinas(-replace=array($s_user -> getdata('firstname'), $s_user -> getdata('lastname')))]</p>

monsterlane commented 7 years ago

Another bug:

        [if ( $message->size );]
            <p class="message">
                [iterate( $message, var( 'messageitem' ) );
                    loop_count > 1 ? '<br>\n';

                    if ( $messageitem->type == 'pair' );
                        $messageitem = ( '<span class="' + ( $messageitem->first) + '">' + ( $messageitem->second ) + '</span>' );
                    /if;

                    $messageitem;
                /iterate]
            </p>
        [/if]
stevepiercy commented 7 years ago

@monsterlane can you elaborate on "another bug" by providing the error stack?

Where does the code snippet above come from?

FWIW, I'm finally working through the Knop 9 demo site bugs.

stevepiercy commented 7 years ago

@monsterlane I believe this is not an issue with the code, but with the database.

Knop tries to insert a record for Customers Simple form:

INSERT INTO `knopdemo`.`customer`
(`firstname`,`lastname`,`email`,`password`,`enabled`,`keyfield`)
VALUES ('h','h','h','demo','1','F881752F-AFE5-4833-BF6E-E783E6972B91')

Note that there is another field that disallows the insertion of NULL for a text field. This is just wrong. A text field cannot have an explicit default value, so one should allow NULL so that an implicit default value of NULL may be inserted when no value for the text column is supplied. See https://dev.mysql.com/doc/refman/5.7/en/data-type-defaults.html

This should fix the issue:

ALTER TABLE `knopdemo`.`customer` CHANGE COLUMN `message` `message` text;

I noted that on MySQL 5.5, I was able to insert a new record via the Customers Simple form, but not on MySQL 5.7. Perhaps something changed between those versions, too, or my servers have different settings for strict mode.

I'm closing this issue via: fa942ec56f52ffa7bb0ff0899971dd536a2e7866

Feel free to open a new issue with a reproducible example and error messages.