Route returning 500 on multi-language

Hi all,

I believe I have found a bug with custom routes when using a multi-language set up. When multi-language is set up, this simple route below will fail with a 500.

c::set('routes', array( 
 array(
    'pattern' => 'subscribe',
    'action'  => function() {
        return false;
    });
));

Note that redirecting to a page does work, but returning response objects also fails with 500.

Here is my error log:

[15-Jul-2015 07:51:39 UTC] PHP Warning:  Cannot modify header information - headers already sent by (output started at /Users/Shared/work/work_server/kirbysite/site/languages/de.php:1) in /Users/Shared/work/work_server/kirbysite/kirby/toolkit/lib/header.php on line 92
[15-Jul-2015 07:51:51 UTC] PHP Notice:  Trying to get property of non-object in /Users/Shared/work/work_server/kirbysite/kirby/branches/multilang/site.php on line 190
[15-Jul-2015 07:51:51 UTC] PHP Notice:  Trying to get property of non-object in /Users/Shared/work/work_server/kirbysite/kirby/branches/multilang/site.php on line 190
[15-Jul-2015 07:51:51 UTC] PHP Fatal error:  Call to a member function code() on a non-object in /Users/Shared/work/work_server/kirbysite/kirby/kirby.php on line 526
[15-Jul-2015 07:51:51 UTC] PHP Warning:  Cannot modify header information - headers already sent by (output started at /Users/Shared/work/work_server/kirbysite/site/languages/de.php:1) in /Users/Shared/work/work_server/net.tinkerbots/kirby/toolkit/lib/header.php on line 92

Any ideas why?

Cheers,
Peter

I’m sorry, but don’t understand what you are trying to achieve!?

As explained here you need to specify an action for your route. In your example you just do

return false;

@flokosiol thanks for your feedback.

returning false was just the simplest way of reproducing the problem.
I’m trying to call an api to subscribe to a mailing list and return the response as json.

array(
'pattern' => 'subscribe',
'method' => 'POST',
'action'  => function() {

    $email = $_POST['email'];

    $rapidmail_client = rapidmail(
      c::get('rapidmail:node_id'),
      c::get('rapidmail:recipient_list_id'),
      c::get('rapidmail:api_key')
    );
    $result = $rapidmail_client->add_recipient(
      $email
    );

    return response::json($result);

 }
)

This produces the following php error:

[15-Jul-2015 09:42:10 UTC] PHP Notice:  Trying to get property of non-object in       /Users/Shared/work/work_server/kirbysite/kirby/branches/multilang/site.php on line 190
[15-Jul-2015 09:42:10 UTC] PHP Notice:  Trying to get property of non-object in /Users/Shared/work/work_server/kirbysite/kirby/branches/multilang/site.php on line 190
[15-Jul-2015 09:42:10 UTC] PHP Fatal error:  Call to a member function code() on a non-object in /Users/Shared/work/work_server/kirbysite/kirby/kirby.php on line 526

Regards,
Peter