The property argument of language_default() is at best laughable in these days of object chaining. It was really supposed to be a quick convenience feature, but its more like cruft that is already not used consistently in code (some places already use the proper object chaining syntax). We can just get rid of this and use it as a simpler API.

Parent issue

#1260488: META: Introduce real language APIs

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tstoeckler’s picture

Status: Needs review » Needs work
+++ b/includes/bootstrap.inc
@@ -2558,14 +2558,13 @@ function language_list($field = 'language') {
+  return variable_get('language_default', (object) array('language' => 'en', 'name' => 'English', 'native' => 'English', 'direction' => 0, 'enabled' => 1, 'plurals' => 0, 'formula' => '', 'domain' => '', 'prefix' => '', 'weight' => 0, 'javascript' => ''));

In terms of "modernizing" can we split that out into separate lines, while we're at it?

Otherwise looks very good.

Gábor Hojtsy’s picture

Status: Needs work » Needs review
FileSize
5.31 KB

Looks good?

tstoeckler’s picture

Status: Needs review » Reviewed & tested by the community

Awesome, thanks!

sun’s picture

+++ b/includes/bootstrap.inc
@@ -2558,14 +2558,28 @@ function language_list($field = 'language') {
+function language_default() {
+  return variable_get(
+    'language_default',

Hold on - we're storing a full object in a variable...?

Hope there's already a follow-up issue to clean that up.

20 days to next Drupal core point release.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 8.x. Thanks!

Gábor Hojtsy’s picture

@sun: added #1272862: Clean up default language handling with some background info, your feedback is very welcome!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

sun’s picture

Issue tags: +API clean-up
Gábor Hojtsy’s picture

Issue tags: +language-base

Tagging for base language system.