From 95e4457fa08a20bc3cc8873274f259b5d4df6c21 Mon Sep 17 00:00:00 2001 From: Joschi Kuphal Date: Tue, 25 Dec 2018 17:16:54 +0100 Subject: [PATCH] Fixed mf2 language parsing in accordance w/ https://github.com/microformats/php-mf2/issues/96 --- CHANGELOG.md | 6 +++++- .../Infrastructure/Factory/MicroformatsFactory.php | 8 ++++---- src/Micrometa/Tests/Infrastructure/ParserTest.php | 1 - 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 35c1cb7..c9506c0 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,13 +4,17 @@ All Notable changes to *jkphl/micrometa* will be documented in this file. Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) principles. -## [3.0.0] - Dendency update release 2018-12-15 +## [3.0.0] - Dendency update release 2018-12-25 ### Changed * Updated dependency versions ([#30](https://github.com/jkphl/micrometa/pull/30), [#31](https://github.com/jkphl/micrometa/pull/31)) * Bumped PHP version requirement to 7.1 +### Fixed + +* Microformats language parsing in accordance with [microformats/php-mf2#96](https://github.com/microformats/php-mf2/issues/96) + ### [2.1.1] - Bugfix release 2018-12-15 ### Fixed diff --git a/src/Micrometa/Infrastructure/Factory/MicroformatsFactory.php b/src/Micrometa/Infrastructure/Factory/MicroformatsFactory.php index a59d7cc..f58ddb2 100755 --- a/src/Micrometa/Infrastructure/Factory/MicroformatsFactory.php +++ b/src/Micrometa/Infrastructure/Factory/MicroformatsFactory.php @@ -139,11 +139,11 @@ protected static function createProperties(array $properties, &$lang) protected static function createLanguage(array $values, &$lang) { // If this is an alternate values list - if (isset($values['html-lang'])) { - if (is_string($values['html-lang'])) { - $lang = trim($values['html-lang']) ?: null; + if (isset($values['lang'])) { + if (is_string($values['lang'])) { + $lang = trim($values['lang']) ?: null; } - unset($values['html-lang']); + unset($values['lang']); } return $values; diff --git a/src/Micrometa/Tests/Infrastructure/ParserTest.php b/src/Micrometa/Tests/Infrastructure/ParserTest.php index 50c95f7..adfd957 100644 --- a/src/Micrometa/Tests/Infrastructure/ParserTest.php +++ b/src/Micrometa/Tests/Infrastructure/ParserTest.php @@ -118,7 +118,6 @@ public function testMicroformatsParser() $this->assertEquals(1, count($items)); $this->assertInstanceOf(Item::class, $items[0]); $this->assertEquals(Microformats::FORMAT, $items[0]->getFormat()); - $this->assertNull($items[0]->getLanguage()); } /**