Monday, April 15, 2013

Laravel Routes: Missing argument 1 for {closure}()

Problem:
While trying to develop quickly I set up a routing rule for Laravel that I thought was correct. But when I tried to access the page, I was met by this error:

Missing argument 1 for {closure}()

My Routing Rule looked like this:

Route::any('dashboard', array(     
    'before' => 'auth',     
    'as'     => 'base',      
    function($action){         
        return Controller::call("user@index");     
}));


Solution:
This was an oversight on my part, the closure used in the route expected an argument which would be the information obtained by any shortcuts [(:any),(:num),etc.] or regex rules. Since this particular route didn't have any captured portions of the URL, the closure also expected no arguments. My working route looks like this with the argument removed:
Route::any('dashboard', array(
    'before' => 'auth',
    'as'     => 'base', 
    function(){
        return Controller::call("user@index");
    }
));

MySQL: Prepared statement needs to be re-prepared

Problem:
While developing a web site on my development service provided by Dreamhost, I found that I would occasionally (and randomly) run into the following error:

General error: 1615 Prepared statement needs to be re-prepared

I began searching for a solution thinking it might be something with the Laravel framework. Then I found this page about a MySQL bug.

Solution:
Ultimately it appears that the best solution is to force the table cache to renew in mysql (more information about mysql repreperation), but if that is not an option, you can try forcing the table optimization or defragmentation for the table causing the issue.

This is understandably a work-around which is not idea for a production server. In the case of a production server, you can try modifying any of the following database settings:


table_open_cache 128=>16384
table_definition_cache 1024=>16384
tmp_table_size 32M=>64M
join_buffer_size 256k=>512k

If you have any more information on this issue, please post a comment below!

Thursday, April 11, 2013

BitBucket: info/refs not found: did you run git update-server-info on the server?

Problem: 
I set up a new repo on bitbucket.org for a project I've been working on and once it was ready for me to add my code, I kept getting the message:

info/refs not found: did you run git update-server-info on the server?

Solution: 
After destroying and creating my .git folder over and over trying to verify my remote path and that I had done the same steps as I had done many times before, it finally clicked what the problem might be. When I had names the repo on BitBucket.org, I had used a hyphen in the name. I changed the name to have a space instead of a hyphen and changed it enough that BitBucket accepted it as a new name. Then I repeated the steps as before and it worked as expected!

Now there are many reasons why you might get this message but hopefully this gives you a possible solution.

Good luck!