Default locale in console commands is always en_us rather than the site default The default (and only) locale for my site is en, however, when trying to query the ElementService from a console command without specifying the locale in the criteria, the locale used in the query is en_us. As such, the query returns no results. For example:

&lt;?php
namespace Craft;

class ShoppingCommand extends BaseCommand {

    public function actionListOrders() {
        $c = craft()-&gt;elements-&gt;getCriteria(ElementType::Entry);
        $c-&gt;section = 'orders';
        $c-&gt;limit = 5;
        foreach($c as $o) {
            print $o-&gt;id . ": " . $o-&gt;title . "\n";
        }
    }
}


prints nothing, even though there are entries present for the default locale en.

Printing out the query object print_r(craft()-&gt;elements-&gt;buildElementsQuery($c)); shows the :locale parameter being passed to the sql query as en_us. But this locale doesn't even exist for the site (select * from craft_locales shows only en).

The only way I could find to work around this is by adding the site's default locale to the criteria manually with:

$c-&gt;locale = craft()-&gt;i18n-&gt;getPrimarySiteLocale();


However, since the query works find without this when run in a controller, I'm skeptical that it should be needed. Is this is a bug, or is there some extra configuration i'm missing? Having some parameter to specify the locale to use for commands would make sense in mutli-locale environments, but I would still expect the default to be the site's default rather than en_us.
Turns out this is actually a bug, too.

It's going to end up being more involved to fix than a build release probably warrants, though, so it'll have to wait for the upcoming 2.3 release to get a proper fix.

In the meantime, you'll be able to get by with your workaround of manually setting it.

$c-&gt;locale = craft()-&gt;i18n-&gt;getPrimarySiteLocale();