Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix EZP-29116 : Conversions from ezxmltext to ezrichtext fails if ezxmtext have duplicate xhtml ids #36

Merged
merged 9 commits into from Apr 25, 2018

Conversation

vidarl
Copy link
Member

@vidarl vidarl commented Apr 19, 2018

This fix is dependent on ezsystems/ezpublish-kernel#2312 which actually deals with the xml conversion..

The change in this PR

  • outputs warnings of duplicated ids are detected and new ones had to be generated due to that.
  • Refactors so that it is possible to make tests for ezxmltext -> richtext conversion
  • Adds tests for duplicate ids

@vidarl vidarl changed the base branch from master to dryrun-and-contentobject April 23, 2018 13:16
@vidarl vidarl changed the base branch from dryrun-and-contentobject to master April 24, 2018 07:59
@vidarl vidarl requested a review from andrerom April 24, 2018 08:03
@vidarl vidarl changed the title [WIP] Fix EZP-29116 : Conversions from ezxmltext to ezrichtext fails if ezxmtext have duplicate xhtml ids Fix EZP-29116 : Conversions from ezxmltext to ezrichtext fails if ezxmtext have duplicate xhtml ids Apr 24, 2018
@vidarl
Copy link
Member Author

vidarl commented Apr 24, 2018

The tests will fail until ezsystems/ezpublish-kernel#2312 is merged.

@vidarl
Copy link
Member Author

vidarl commented Apr 24, 2018

@adamwojs : Could you have a look on this one too? I was not able to add you as reviewer

@andrerom andrerom requested a review from adamwojs April 24, 2018 10:33
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*
* @version //autogentag//
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: @version is not needed anymore.

)
);
}
function removeComments(DOMDocument $document)
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: Missing new line between methods. Can we also specify the visibility of the method?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah.. both nitpicks are a result of cut&paste... I'll fix

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

@@ -174,8 +141,9 @@ function convertFieldDefinitions($dryRun, OutputInterface $output)
$output->writeln("Converted $count ezxmltext field definitions to ezrichtext");
}

function convertFields($dryRun, $contentObjectId, OutputInterface $output)
function convertFields($dryRun, $contentObjectId, $checkDuplicateIds, OutputInterface $output)
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: missing visibility specification for method.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

array(
new ToRichTextPreNormalize(new Expanding(), new EmbedLinking()),
new Xslt(
'./vendor/ezsystems/ezpublish-kernel/eZ/Publish/Core/FieldType/RichText/Resources/stylesheets/ezxml/docbook/docbook.xsl',
Copy link
Member

@adamwojs adamwojs Apr 25, 2018

Choose a reason for hiding this comment

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

Specifying path relative to __DIR__ is a bit safer for me, especially when it was moved from the command

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think that will work.
If only running tests, you may not have a meta repo. so you will have these paths:

lib/FieldType/XmlText/Converter/RichText.php 
vendor/ezsystems/ezpublish-kernel/eZ/Publish/Core/FieldType/RichText/Resources/stylesheets/ezxml/docbook/docbook.xsl

Which means __DIR__ . '/../../../../vendor/ezsystems/ezpublish-kernel/eZ/Publish/Core/FieldType/RichText/Resources/stylesheets/ezxml/docbook/docbook.xsl',

But when you have a meta repo and running the actuall bin/console ezxmltext:convert-to-richtext command, ezpublish-kernel will be in different location relative to ezplatform-xmltext-fieldtype :

vendor/ezsystems/ezplatform-xmltext-fieldtype/lib/FieldType/XmlText/Converter/RichText.php
vendor/ezsystems/ezpublish-kernel/eZ/Publish/Core/FieldType/RichText/Resources/stylesheets/ezxml/docbook/docbook.xsl

Which will require __DIR__ . '/../../../../../../../vendor/ezsystems/ezpublish-kernel/eZ/Publish/Core/FieldType/RichText/Resources/stylesheets/ezxml/docbook/docbook.xsl',

Copy link
Member Author

@vidarl vidarl Apr 25, 2018

Choose a reason for hiding this comment

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

So, I could add some logic and check whatever vendor/ezsystems/ezpublish-kernel or ../ezpublish-kernel exists, and set the path accordingly, relative to __DIR__

Copy link
Member

Choose a reason for hiding this comment

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

So, I could add some logic and check whatever vendor/ezsystems/ezpublish-kernel or ../ezpublish-kernel exists, and set the path accordingly, relative to DIR

@vidarl No, in this circumstances let's leave it as is 😉

@andrerom andrerom merged commit 9ffe1e7 into master Apr 25, 2018
@vidarl vidarl deleted the id_already_def branch April 26, 2018 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants