Ticket #3442 (closed defect: fixed)

Opened 2 years ago

Last modified 5 months ago

role names shouldn't be gettexted in schema.php

Reported by: tenpura Assigned to: ryan
Priority: normal Milestone: 2.5
Component: Administration Version: 2.5
Severity: normal Keywords: i18n needs-patch
Cc:

Description

Description:
Currently role names are stored into database in localized character encodings. If somehow those get garbled, unserialize() will fail to retrieve the data (because of the string length mismatch) and then a login failure occurs.

Suggested Solution:
Instead of using __() for the storing data in upgrade-schema.php, use __() when we display the data. (atleast for the role names, it seems to be a common problem.)

References:
http://www.google.com/search?hl=en&q=%22capabilities.php+on+line+19%22

Attachments

translate_roles.diff (4.4 kB) - added by ryan on 02/19/08 09:01:04.

Change History

12/06/06 12:42:01 changed by markjaquith

  • milestone set to 2.2.

Sounds like a good solution, although it wouldn't fix blogs that are already broken.

Issues:

We'd need to change the role names on upgrade, and thanks to our muddled roles/capabilities system, that's not a simple SQL query... it'd have to be done in PHP.

Blogs sharing centralized user/role tables would have to be upgraded in unison (they probably would be anyway).

Maybe we can get the role/cap system changed in 2.2 to something simpler so we don't have to keep limping along with the one we have.

03/27/07 22:52:54 changed by foolswisdom

  • milestone changed from 2.2 to 2.4.

01/15/08 04:27:06 changed by thee17

  • status changed from new to closed.
  • resolution set to invalid.

01/15/08 16:55:40 changed by Nazgul

  • milestone deleted.

02/03/08 06:49:15 changed by tenpura

  • status changed from closed to reopened.
  • summary changed from Garbled role names cause login failure to role names shouldn't be gettexted in schema.php.
  • resolution deleted.
  • version changed from 2.0.5 to 2.5.
  • milestone set to 2.5.

The description is a bit old but this is still a ongoing problem, so please don't close.

I said "garbled" but this actually could be anything (e.g. database encoding conversion) that causes string length mismatch of serialized data.

02/03/08 07:00:08 changed by tenpura

  • keywords changed from needs-patch to i18n needs-patch.

02/19/08 08:29:54 changed by ryan

  • owner changed from anonymous to ryan.
  • status changed from reopened to new.

02/19/08 09:01:04 changed by ryan

  • attachment translate_roles.diff added.

02/19/08 09:02:35 changed by ryan

Patch saves the untranslated strings to the roles array stored in the DB and translates them on the fly later. Dummy _c() calls are made to get the strings in the message catalog. translate_with_context() is used for on-the-fly translation since strings are not extracted from it when creating the message catalog.

02/19/08 09:12:02 changed by nbachiyski

Very nice! It preserves backward compatibility and the common roles' translation will change with locale change.

There is a samll problem: artificially added roles will be left as-is (good thing), except for stripping the text after the last |. Probably we should document having | in role names?

02/19/08 09:15:13 changed by ryan

Yes, let's document. Plugins that deal with roles will need to account for the context .

02/19/08 12:08:38 changed by tenpura

It's cool that we can change roles' translation anytime we want. Thank you!

BTW, I get Warning: Missing argument 2 for translate_with_context().

function translate_with_context($text, $domain) {

should be like

function translate_with_context($text, $domain = 'default') {

?

02/19/08 20:28:54 changed by ryan

  • status changed from new to closed.
  • resolution set to fixed.

(In [6916]) Don't save translated role names to the DB. Instead, translate them on the fly. fixes #3442 #5537

02/19/08 20:29:49 changed by ryan

I defaulted the domain args to avoid the missing arg warnings.