New! Checkout our new Forums homepage! Follow the latest activity in eZ Publish Forums on Share.ez.no, Projects.ez.no and StackOverflow.com


@ezecosystem
ezecosystem pushed to master in ezecosystem/ezpublish-kernel Oct 9, 2018
2 commits to master
10/09/2018 11:59 am   eZecosystem @ GitHub   Mirror   Link  
@ezecosystem
ezecosystem pushed to master in ezecosystem/ezpublish-api Oct 9, 2018
2 commits to master
10/09/2018 11:59 am   eZecosystem @ GitHub   Mirror   Link  
@ezecosystem
ezecosystem pushed to master in ezecosystem/ezplatform-site-api Oct 9, 2018
2 commits to master
10/09/2018 11:59 am   eZecosystem @ GitHub   Mirror   Link  
@ezecosystem
ezecosystem pushed to master in ezecosystem/ezplatform Oct 9, 2018
2 commits to master
  • @brookinsconsulting 6dd4cfd
    Merge remote-tracking branch 'upstream/master'
  • @sunpietro f971658
    EZP-29675: Correct JMS translations config to exclude node_modules fo…
10/09/2018 11:59 am   eZecosystem @ GitHub   Mirror   Link  

Using the Right Debugging Tools

A while ago, we updated the MongoDB PHP driver's embedded C library to a new version. The C library handles most of the connection management and other low level tasks that the PHP driver needs to successfully talk to MongoDB deployments, especially in replicated environments where servers might disappear for maintenance or hardware failures.

After upgrading the C library from 1.12 to 1.13 we noticed that one of the PHP driver's tests was failing:

derick@singlemalt:~/dev/php/derickr-mongo-php-driver $ make test TESTS=tests/atlas.phpt
…
====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
Atlas Connectivity Tests [tests/atlas.phpt]
=====================================================================

When running the test manually, we get:

derick@singlemalt:~/dev/php/mongodb-mongo-php-driver $ php tests/atlas.phpt
--TEST--
Atlas Connectivity Tests
--SKIPIF--
skip Atlas tests not wanted
--FILE--
PASS
mongo-php-driver/src/libmongoc/src/libmongoc/src/mongoc/mongoc-cluster.c:1852 mongoc_cluster_fetch_stream_single():
        precondition failed: scanner_node && !scanner_node->retired
Aborted

That was not good news.

The atlas.phpt test tests whether the PHP driver (through the C driver) can connect to a set of different deployments of Atlas, MongoDB's Database as a Service platform. The test makes sure we can talk to an Atlas replica set, a sharded cluster, a free tier replica set, as well as TLS 1.1 and TLS 1.2 specific deployments. The test started failing when connecting to the second provided URI (the sharded cluster).

At first I thought this was caused by the upgrade from version 1.12 to 1.13 of the C driver, but that didn't end up being the case. Let's see how we got to finding and fixing this bug.

First of all, I started GDB to see where it was failing:

derick@singlemalt:~/dev/php/mongodb-mongo-php-driver $ gdb --args php tests/atlas.phpt
GNU gdb (Debian 8.1-4+b1) 8.1
…
Reading symbols from php...done.
(gdb) run
Starting program: /usr/local/php/7.3dev/bin/php tests/atlas.phpt
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
--TEST--
Atlas Connectivity Tests
--FILE--
PASS
mongo-php-driver/src/libmongoc/src/libmongoc/src/mongoc/mongoc-cluster.c:1852 mongoc_cluster_fetch_stream_single():
        precondition failed: scanner_node && !scanner_node->retired

Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
51      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.

This shows that the C driver bailed out due to a specific assertion on line 1852 of mongoc-cluster.c. This assertion reads:

BSON_ASSERT (scanner_node && !scanner_node->retired);

Which didn't really say a lot. The next thing to try is then to make a backtrace in GDB with the bt command. This revealed:

(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007ffff41472f1 in __GI_abort () at abort.c:79
#2  0x00007ffff32cdcf1 in mongoc_cluster_fetch_stream_single (
        cluster=0x555556ba8e68, server_id=2, reconnect_ok=true, error=0x555556b95858)
        at mongo-php-driver/src/libmongoc/src/libmongoc/src/mongoc/mongoc-cluster.c:1852
#3  0x00007ffff32cd9df in _mongoc_cluster_stream_for_server (
        cluster=0x555556ba8e68, server_id=2, reconnect_ok=true, cs=0x0, reply=0x7fffffff9ee0, error=0x555556b95858)
        at mongo-php-driver/src/libmongoc/src/libmongoc/src/mongoc/mongoc-cluster.c:1762
#4  0x00007ffff32cdbe6 in mongoc_cluster_stream_for_server (
        cluster=0x555556ba8e68, server_id=2, reconnect_ok=true, cs=0x0, reply=0x7fffffff9ee0, error=0x555556b95858)
        at mongo-php-driver/src/libmongoc/src/libmongoc/src/mongoc/mongoc-cluster.c:1826
#5  0x00007ffff32ddb0a in _mongoc_cursor_fetch_stream (cursor=0x555556b95700)
        at mongo-php-driver/src/libmongoc/src/libmongoc/src/mongoc/mongoc-cursor.c:647
#6  0x00007ffff32e12a0 in _prime (cursor=0x555556b95700)
        at mongo-php-driver/src/libmongoc/src/libmongoc/src/mongoc/mongoc-cursor-find.c:40
#7  0x00007ffff32df22c in _call_transition (cursor=0x555556b95700)
        at mongo-php-driver/src/libmongoc/src/libmongoc/src/mongoc/mongoc-cursor.c:1146
#8  0x00007ffff32df54b in mongoc_cursor_next (cursor=0x555556b95700, bson=0x7fffffffa038)
        at mongo-php-driver/src/libmongoc/src/libmongoc/src/mongoc/mongoc-cursor.c:1214
#9  0x00007ffff332511c in phongo_cursor_advance_and_check_for_error (cursor=0x555556b95700)
        at mongo-php-driver/php_phongo.c:742
#10 0x00007ffff33253d9 in phongo_execute_query (
        client=0x555556ba8e60, namespace=0x7fffeaeb5d58 "test.test", zquery=0x7ffff38201c0, options=0x0,
        server_id=1, return_value=0x7ffff38200f0, return_value_used=1)
        at mongo-php-driver/php_phongo.c:810
#11 0x00007ffff3342cc3 in zim_Manager_executeQuery (execute_data=0x7ffff3820160, return_value=0x7ffff38200f0)
        at mongo-php-driver/src/MongoDB/Manager.c:492
#12 0x0000555555e41d16 in execute_internal (execute_data=0x7ffff3820160, return_value=0x7ffff38200f0)
        at /home/derick/dev/php/php-src.git/Zend/zend_execute.c:2328
…

At first glance, I couldn't really see anything wrong with this backtrace, and was still puzzled why it would abort. I decided to go for a lunch time walk and have a look at it again. I always find that walks are good for clearing my mind.

After the walk, and a cuppa tea, I looked at the backtrace again, and noticed the following curiosity:

#4  0x00007ffff32cdbe6 in mongoc_cluster_stream_for_server (
        cluster=0x555556ba8e68, server_id=2, reconnect_ok=true, cs=0x0, reply=0x7fffffff9ee0, error=0x555556b95858)
        at mongo-php-driver/src/libmongoc/src/libmongoc/src/mongoc/mongoc-cluster.c:1826

vs:

#10 0x00007ffff33253d9 in phongo_execute_query (
        client=0x555556ba8e60, namespace=0x7fffeaeb5d58 "test.test", zquery=0x7ffff38201c0, options=0x0,
        server_id=1, return_value=0x7ffff38200f0, return_value_used=1)
        at mongo-php-driver/php_phongo.c:810

In frame #10 the server_id variable is 1, whereas in frame #4 later on, the server_id variable is 2. These should have been the same.

The server ID is determined by the C driver when selecting a server to send a read or write operation to, and refers to a specific server's connection ID. The PHP driver uses this server ID when executing the query through the phongo_execute_query function, which calls the C driver's mongoc_collection_find_with_opts. The latter accepts as 3rd argument a bson_t value with options to use while executing a query. These options include the pre-selected server ID, so that the C driver does not attempt to reselect a server:

cursor = mongoc_collection_find_with_opts(collection, query->filter, query->opts,
        phongo_read_preference_from_zval(zreadPreference TSRMLS_CC));

I decided to investigate which options the PHP driver was sending to mongoc_collection_find_with_opts. A while ago I developed a GDB helper function, about which I wrote in pretty-printing BSON. I sourced this helper within my GDB instance, and switched to frame #10 to inspect the value of the query options:

(gdb) source ~/dev/php/mongodb-mongo-php-driver/src/libmongoc/.gdbinit
(gdb) frame 10

The function call uses the options from the query struct query->opts, so I used the printbson helper function to display its contents:

(gdb) printbson query->opts

Which showed:

$11 = "!\000\000\000\020serverId\000\002\000\000\000\020serverId\000\001", '\000' 
INLINE (len=33)
{
        'serverId' : NumberInt("2"),
        'serverId' : NumberInt("1")
}

There are not supposed to be two conflicting serverId elements. Unlike PHP's arrays, bson_t values can have the same key appear multiple times. Although the C driver had selected server ID 1 for this query, server 2 was used because it was the first serverId element in the options struct. But why where there two values in the first place?

If you look at the PHP test, you see the following:

executeQuery('test.test', $query));
                …
        } catch(Exception $e) {
                …
        }
}
?>

From this follows that we create the Query object, assign it to $query, and then use the same variable for each iteration. Somehow, we were not resetting the query options back to default before we used them, resulting in a duplicate serverId field. Once we figured out the problem, creating the fix was easy enough: Make sure we use a clean query->opts struct before we pass it to the mongoc_collection_find_with_opts function.

Debugging this issue was made lot easier by having the right debugging tools, and this case shows that spending time on writing the GDB helper function printbson earlier in the year paid off. With this bug fixed, we could release a new patch version of the MongoDB Driver for PHP.

Happy hacking!

10/09/2018 04:26 am   derickrethans.nl   Mirror   Link  
@ezpublishlegacy
ezpublishlegacy pushed to master in ezpublishlegacy/LegacyBridge Oct 8, 2018
1 commit to master
10/08/2018 12:19 pm   eZPublishLegacy @ GitHub   Mirror   Link  
@ezecosystem
ezecosystem pushed to master in ezecosystem/Sylius Oct 8, 2018
2 commits to master
  • @pamil 52833ef
    Merge pull request Sylius#9798 from SyliusBot/crowdin/master-2018-10-…
  • 593bc18
    [Translations] Updated translations from Crowdin
10/08/2018 12:05 pm   eZecosystem @ GitHub   Mirror   Link  

Last week, we announced the dates of the next edition of the French SymfonyLive conference, March 28-29. Today we're very pleased to announce that the conference website is now online! Early bird registration is open as well as the Call For Papers. You can start submit your talk proposals (in French) for the conference. CFP will be open until December 17th (included). We encourage you to submit several talk proposals to increase your chances of selection. All the CFP criteria are available on the conference website. All the talk proposals will be studied regardless of your ethnic origin, gender identity, religion, sexual orientation... You never spoke at a conference before? That's neither a criterion of selection. If you never spoke at a conference before and you are selected to speak at the conference, we'll help you and work with you on your talk, slides; we'll organize rehearsals... We have a speaker mentoring program for unexperienced and experienced speakers and we'd be pleased to help you with your talk!

Early bird registration is open until December 17th (included). You can register for the 2 days of conference on March 28-29 for 239€ (breakfast, lunch, food for both days and your free conference t-shirt are included)! We organize pre-conference workshops on March 26-27, the workshops' topics will be announced soon, stay tuned!

We are also very pleased to announce that all the videos from SymfonyLive Paris 2018 edition are now online on our YouTube channel. Watch all the talks from the last edition!

We can't wait to meet the French Symfony community at SymfonyLive Paris 2019! Stay tuned for more information about our pre-conference workshops soon!


La semaine dernière, nous avons annoncé les dates de la prochaine édition de la conférence SymfonyLive Paris, les 28 et 29 mars 2019. Aujourd'hui, nous sommes ravis de vous annoncer que le site de la conférence est désormais en ligne ! Les inscriptions early bird sont ouvertes ainsi que le Call For Papers. Vous pouvez dès à présent soumettre vos propositions de sujet (en français) pour la conférence. Le CFP est ouvert jusqu'au 17 décembre (inclus). Nous vous encourageons à soumettre plusieurs propositions de sujets pour augmenter vos chances de sélection. Tous les critères relatifs au CFP sont disponibles sur le site de la conférence. Toutes les propositions de sujet seront étudiées, peu importe votre origine ethnique, genre, religion, orientation sexuelle... Vous n'avez jamais été speaker ? Ce n'est pas non plus un critère de sélection ! Si vous n'avez jamais été speaker auparavant et que vous êtes choisi pour être speaker de la conférence, nous aurons le plaisir de vous aider à construire votre sujet, vos slides ; nous pourrons également organiser des répétitions... Nous avons créé un programme de mentoring pour aider tous les speakers (débutants et confirmés) et nous serions ravis de pouvoir vous aider si vous rencontrez la moindre difficulté avec votre sujet.

Les inscriptions early bird sont ouvertes jusqu'au 17 décembre (inclus). Vous pouvez vous inscrire pour les 2 journées de conférence des 28 et 29 mars pour 239€ (les petits-déjeuners, déjeuners et boissons pour chaque journée de conférence ainsi que votre t-shirt officiel de la conférence sont inclus) ! Nous organisons des formations pré-conférence les 26 et 27 mars, les sujets des formations seront annoncés très prochainement, ne les manquez pas !

Nous sommes également très heureux de vous annoncer que toutes les vidéos du SymfonyLive Paris 2018 sont désormais en ligne sur notre chaîne YouTube. Regardez dès à présent toutes les vidéos de la dernière édition de la conférence !

Nous avons hâte de retrouver la communauté francophone de Symfony au SymfonyLive Paris 2019 ! Restez à l'écoute pour ne pas manquer les informations sur nos formations pré-conférence !


Be trained by Symfony experts - 2018-10-10 Clichy - 2018-10-15 Paris - 2018-10-15 Paris
10/08/2018 08:21 am   Symfony Blog   Mirror   Link  

This week, Symfony 3.4.17 and 4.1.6 maintenance versions were released. Meanwhile, we continued deprecating features in preparation for the upcoming Symfony 4.2 version, such as simple_preauth and simple_form and the "--env" and "--no-debug" console options. Lastly, next week the Symfony Loves PHP USA 2018 conference will gather the American Symfony and PHP communities in San Francisco to learn about the latest and best developments with Symfony and PHP.

Symfony development highlights

2.8 changelog:

3.4 changelog:

  • 22aec24: [DependencyInjection] fixed error in dumped container
  • 8e1f381: [DependencyInjection] fixed dumping setters before their inlined instances
  • 636eb9e: [Finder] fixed root directory access for ftp/sftp wrapper

4.1 changelog:

  • 3ae327c: [FrameworkBundle] don't suggest hidden services in debug:container and debug:autowire commands
  • b1f462f: [Console] fixed clearing sections containing questions

Master changelog:

  • 9610d10: [Form] added a cause when a CSRF error has occurred
  • 38655bd: [Cache] added RedisClusterProxy to create lazy connections to Redis clusters
  • 3b604ff: [Validator] pre-check constraint validator dependencies
  • 104e922: [DependencyInjection] improved ServiceLocatorTagPass service matching
  • 679f8d9: [Translation] marked getFallbackLocales() as internal
  • 7cc7c71: [Security] deprecated simple_preauth and simple_form in favor of Guard
  • 64727c1: [FrameworkBundle] deprecated the "--env" and "--no-debug" console options
  • 5a0cad2: [Serializer] object class resolver
  • 3e7b029: [Serialized] allowed configuring the serialized name of properties through metadata
  • e0cb452: [WebServerBundle] deprecated relying on --env in server:start and server:run

Newest issues and pull requests

They talked about us

Upcoming Symfony Events

Call to Action


Be trained by Symfony experts - 2018-10-10 Clichy - 2018-10-15 Paris - 2018-10-15 Paris
10/07/2018 04:32 am   Symfony Blog   Mirror   Link  
@ezecosystem
ezecosystem pushed to master in ezecosystem/Sylius Oct 7, 2018
2 commits to master
  • @lchrusciel 298b77b
    Merge pull request Sylius#9789 from adrienlucas/autoconfigure-fixtures
  • @adrienlucas d5e5699
    [FixtureBundle] Add autoconfiguration for instance of FixtureInterface
10/07/2018 12:05 am   eZecosystem @ GitHub   Mirror   Link  
@ezpublishlegacy
ezpublishlegacy pushed to master in ezpublishlegacy/TagsBundle Oct 6, 2018
2 commits to master
10/06/2018 12:30 pm   eZPublishLegacy @ GitHub   Mirror   Link  
@ezecosystem
ezecosystem pushed to master in ezecosystem/TagsBundle Oct 6, 2018
2 commits to master
10/06/2018 12:06 pm   eZecosystem @ GitHub   Mirror   Link  
@ezecosystem
ezecosystem pushed to master in ezecosystem/Sylius Oct 6, 2018
2 commits to master
10/06/2018 12:06 pm   eZecosystem @ GitHub   Mirror   Link  

News

eZ Platform 2.3 Available

The autumn release of eZ Platform v2.3 has arrived! This release introduces updated and new features, such as, a Content Scheduler Block, Image Asset field type, Form Builder, Personalization block and much more. Read the full announcement here.

Other notable releases include XmlText field type for eZ Platform and Legacy:

Webinar: Discover eZ Platform v2.3

Join us on October 10th, 2018 at 10:00 am ET/ 3:00 pm CET as Product Marketing Manager, Amit takes us on a tour of eZ Platform v2.3. What you'll learn:

  • Live demo of eZ Platform v2.3 and its new features
  • New features such as scheduler block, form builder manager, asset field type, and more.

Register now, and learn all about the new release!

Product Feedback

A few weeks ago we introduced a new channel on Slack where you can provide product feedback, apart from the existing channels. We are adding another way for you to provide product feedback, through the newly launched Product Feedback Portal, available at ezplatform.com/Product-Feedback.

This new Portal provides insight to what is already on the radar for Product Management. You can leave feedback to items already on this roadmap, or you can suggest something new.

How does it work? On the Portal, you will find ‘tiles’ with a topic title and description. Click on a tile and select ‘Nice-to-have’,’Important’ or ‘Critical’. Once you select one of these options, you can also leave a comment, and finally your email. Or you can use the button on the top-right to provide feedback for something not listed on the Portal yet.

In Other News:

Resources

Symfony 3.4.16 Conflict

Symfony 3.4.16 has been added as conflicting version to ezplatform meta for composer updates as of October 2. Reported by Felix Laate on Slack, running a composer update can leave you with the following error:

"Type error: Argument 1 passed to Twig_Environment::addExtension() must implement interface Twig_ExtensionInterface, boolean given"

The solution is a downgrade with the following command: composer require symfony/symfony:3.4.15

Looking for a bundle compatible with eZ Platform? Check out: https://ezplatform.com/Bundles.

Social Media

Follow us on Twitter, Facebook, LinkedIn, Google+, or YouTube, and join our Community for any help with eZ Platform or community-related questions.

Find eZ at These Events

For more events, make sure to check out this list.

Each week we publish a roundup of highlights from the eZ ecosystem. If you have any news or events to share, please contact me.

(Lead image credit: Steve Snodgrass, CC)

10/05/2018 01:56 pm   ez.no/About-eZ/Blog   Mirror   Link  

News

eZ Platform 2.3 Available

The autumn release of eZ Platform v2.3 has arrived! This release introduces updated and new features, such as, a Content Scheduler Block, Image Asset field type, Form Builder, Personalization block and much more. Read the full announcement here.

Other notable releases include XmlText field type for eZ Platform and Legacy:

Webinar: Discover eZ Platform v2.3

Join us on October 10th, 2018 at 10:00 am ET/ 3:00 pm CET as Product Marketing Manager, Amit takes us on a tour of eZ Platform v2.3. What you'll learn:

  • Live demo of eZ Platform v2.3 and its new features
  • New features such as scheduler block, form builder manager, asset field type, and more.

Register now, and learn all about the new release!

Product Feedback

A few weeks ago we introduced a new channel on Slack where you can provide product feedback, apart from the existing channels. We are adding another way for you to provide product feedback, through the newly launched Product Feedback Portal, available at ezplatform.com/Product-Feedback.

This new Portal provides insight to what is already on the radar for Product Management. You can leave feedback to items already on this roadmap, or you can suggest something new.

How does it work? On the Portal, you will find ‘tiles’ with a topic title and description. Click on a tile and select ‘Nice-to-have’,’Important’ or ‘Critical’. Once you select one of these options, you can also leave a comment, and finally your email. Or you can use the button on the top-right to provide feedback for something not listed on the Portal yet.

In Other News:

Resources

Symfony 3.4.16 Conflict

Symfony 3.4.16 has been added as conflicting version to ezplatform meta for composer updates as of October 2. Reported by Felix Laate on Slack, running a composer update can leave you with the following error:

"Type error: Argument 1 passed to Twig_Environment::addExtension() must implement interface Twig_ExtensionInterface, boolean given"

The solution is a downgrade with the following command: composer require symfony/symfony:3.4.15

Looking for a bundle compatible with eZ Platform? Check out: https://ezplatform.com/Bundles.

Social Media

Follow us on Twitter, Facebook, LinkedIn, Google+, or YouTube, and join our Community for any help with eZ Platform or community-related questions.

Find eZ at These Events

For more events, make sure to check out this list.

Each week we publish a roundup of highlights from the eZ ecosystem. If you have any news or events to share, please contact me.

(Lead image credit: Steve Snodgrass, CC)

10/05/2018 01:56 pm   eZ Systems News   Mirror   Link  
@ezpublishlegacy
ezpublishlegacy pushed to master in ezpublishlegacy/TagsBundle Oct 5, 2018
2 commits to master
10/05/2018 12:36 pm   eZPublishLegacy @ GitHub   Mirror   Link  
@ezpublishlegacy
ezpublishlegacy pushed to master in ezpublishlegacy/phpunit Oct 5, 2018
2 commits to master
10/05/2018 12:32 pm   eZPublishLegacy @ GitHub   Mirror   Link  
@ezpublishlegacy
ezpublishlegacy pushed to master in ezpublishlegacy/LegacyBridge Oct 5, 2018
2 commits to master
  • @andrerom f551da3
    Merge branch '1.4'
  • @andrerom aaadbea
    Make sure to detect bool parameters & cast to int for URLGenerator usage
10/05/2018 12:23 pm   eZPublishLegacy @ GitHub   Mirror   Link  
@ezpublishlegacy
ezpublishlegacy pushed to master in ezpublishlegacy/ezstudio Oct 5, 2018
2 commits to master
  • @lserwatka fa74e85
    Merge remote-tracking branch 'upstream/master'
  • @lserwatka 8d4a860
    Merge branch '2.2'
10/05/2018 12:17 pm   eZPublishLegacy @ GitHub   Mirror   Link  
@ezpublishlegacy
ezpublishlegacy pushed to master in ezpublishlegacy/ezpublish-legacy Oct 5, 2018
2 commits to master
10/05/2018 12:13 pm   eZPublishLegacy @ GitHub   Mirror   Link  
@ezpublishlegacy
ezpublishlegacy pushed to master in ezpublishlegacy/ezpublish-kernel Oct 5, 2018
2 commits to master
10/05/2018 12:13 pm   eZPublishLegacy @ GitHub   Mirror   Link  
@ezecosystem
ezecosystem pushed to master in ezecosystem/TagsBundle Oct 5, 2018
2 commits to master
10/05/2018 12:07 pm   eZecosystem @ GitHub   Mirror   Link  
@ezecosystem
ezecosystem pushed to master in ezecosystem/SyliusDemo Oct 5, 2018
2 commits to master
10/05/2018 12:07 pm   eZecosystem @ GitHub   Mirror   Link  
@ezecosystem
ezecosystem pushed to master in ezecosystem/Sylius Oct 5, 2018
2 commits to master
10/05/2018 12:07 pm   eZecosystem @ GitHub   Mirror   Link  
@ezecosystem
ezecosystem pushed to master in ezecosystem/ezstudio Oct 5, 2018
2 commits to master
  • @lserwatka fa74e85
    Merge remote-tracking branch 'upstream/master'
  • @lserwatka 8d4a860
    Merge branch '2.2'
10/05/2018 12:01 pm   eZecosystem @ GitHub   Mirror   Link  
@ezecosystem
ezecosystem pushed to master in ezecosystem/ezpublish-kernel Oct 5, 2018
2 commits to master
10/05/2018 12:00 pm   eZecosystem @ GitHub   Mirror   Link  
@ezecosystem
ezecosystem pushed to master in ezecosystem/ezplatform-xmltext-fieldtype Oct 5, 2018
2 commits to master
  • @vidarl 0c3743f
    EZP-29027: Added support for conversion of ezxmltest tag <literal> (e…
  • @vidarl 2cedfa1
    EZP-29697: ezxmltext -> richtext conversion : Give user a report of c…
10/05/2018 11:59 am   eZecosystem @ GitHub   Mirror   Link  
@ezecosystem
ezecosystem pushed to master in ezecosystem/ezplatform-com Oct 5, 2018
2 commits to master
10/05/2018 11:59 am   eZecosystem @ GitHub   Mirror   Link  

The Symfony Translation component provides tools to internationalize your PHP applications. One of those tools is the transChoice() method to select a translation based on a number, which is ideal for taking care of pluralization.

However, that method uses a proprietary format to define the translations and it doesn't allow to select messages based on other conditions (for example the gender of a person).

Meanwhile, the MessageFormat created by the ICU project is a standard used in lots of applications and supports many more features. That's why Symfony 4.2 introduces an IntlMessageFormatter as a better replacement of transChoice().

The full MessageFormat format guide is intimidating at first because of all the features it supports. The following example selects the translation based on the gender and a number:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use Symfony\Component\Translation\Formatter\IntlMessageFormatter;

$translation = <<<'_TRANSLATION_'
{gender_of_host, select,
  female {{num_guests, plural, offset:1
      =0 {{host} does not give a party.}
      =1 {{host} invites {guest} to her party.}
      =2 {{host} invites {guest} and one other person to her party.}
     other {{host} invites {guest} as one of the # people invited to her party.}}}
  male   {{num_guests, plural, offset:1
      =0 {{host} does not give a party.}
      =1 {{host} invites {guest} to his party.}
      =2 {{host} invites {guest} and one other person to his party.}
     other {{host} invites {guest} as one of the # people invited to his party.}}}
  other {{num_guests, plural, offset:1
      =0 {{host} does not give a party.}
      =1 {{host} invites {guest} to their party.}
      =2 {{host} invites {guest} and one other person to their party.}
     other {{host} invites {guest} as one of the # people invited to their party.}}}}
_TRANSLATION_;

$message = (new IntlMessageFormatter())->format($translation, 'en', [
    'gender_of_host' => 'male',
    'num_guests' => 10,
    'host' => 'Jon',
    'guest' => 'Jane',
]);
// $message = 'Jon invites Jane as one of the 9 people invited to his party.'

The next step will be to deprecate the old way to select translations, deprecate the transChoice() method and maybe provide a script to convert the old format into the new one automatically.


Be trained by Symfony experts - 2018-10-10 Clichy - 2018-10-15 Paris - 2018-10-15 Paris
10/05/2018 09:23 am   Symfony Blog   Mirror   Link  
@ezpublishlegacy
ezpublishlegacy pushed to master in ezpublishlegacy/phpunit Oct 5, 2018
2 commits to master
10/05/2018 12:26 am   eZPublishLegacy @ GitHub   Mirror   Link