Skip to content

[Backport 2.3 -> 2.2] Fix meta title property & Updated unit test#16311

Closed
gelanivishal wants to merge 2 commits intomagento:2.2-developfrom
gelanivishal:2.2-develop-PR-port-11368
Closed

[Backport 2.3 -> 2.2] Fix meta title property & Updated unit test#16311
gelanivishal wants to merge 2 commits intomagento:2.2-developfrom
gelanivishal:2.2-develop-PR-port-11368

Conversation

@gelanivishal
Copy link
Copy Markdown
Contributor

Original Pull Request

#11368

Description

If, inside a controller you try to set metadata title with:

$resultPage->getConfig()->setMetadata('title', 'some meta title');

you will get an error on frontend:

Recoverable Error: Object of class Magento\Framework\View\Page\Title could not be converted to string...

becouse processMetadataContent will return an istance of Magento\Framework\View\Page\Title instead of a string.

Fixed Issues (if relevant)

  1. Unable to render page when 'meta title' page config param is set #2956: Unable to render page when 'meta title' page config param is set

Manual testing scenarios

Scenario 1

  1. Create a controller
  2. Inside the execute function add:
$resultPage = $this->resultPageFactory->create();
$resultPage->getConfig()->getTitle->set('my title');
$resultPage->getConfig()->setMetadata('title', 'metatitle');
return $resultPage;
  1. As result you will have in your page:
<title>my title</title>
<meta name="title" content="metatitle"/>

Scenario 2

  1. Create a controller
  2. Inside the execute function add:
$resultPage = $this->resultPageFactory->create();
$resultPage->getConfig()->getTitle->set('my title');
return $resultPage;
  1. As result you will have in your page:
<title>my title</title>
<meta name="title" content="my title"/>

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@magento-engcom-team
Copy link
Copy Markdown
Contributor

Hi @vgelani. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento-engcom-team give me test instance - deploy test instance based on PR changes
  • @magento-engcom-team give me {$VERSION} instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Assistant documentation

Copy link
Copy Markdown
Contributor

@orlangur orlangur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vgelani please do not rewrite authors of original commits during porting. Feel free to do just a one commit with git commit -c 32e2e4de5921ecb7b13722955298e886ec2b2d59, just that @slackerzz should be properly credited as author and you as author of port will be mentioned as committer.

@orlangur orlangur changed the title Fix meta title property & Updated unit test [Backport 2.3 -> 2.2] Fix meta title property & Updated unit test Jun 22, 2018
@gelanivishal
Copy link
Copy Markdown
Contributor Author

@orlangur Yeah, I got it. I'll take care in next PR.

@orlangur
Copy link
Copy Markdown
Contributor

@vgelani, thanks for your endeavors, @slackerzz will take care of this PR porting. He noticed some changes were missed which resulted in failing unit test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants