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

Upgraded TinyMCE to 6.7.0 #3220

Merged
merged 57 commits into from
Oct 2, 2023
Merged

Upgraded TinyMCE to 6.7.0 #3220

merged 57 commits into from
Oct 2, 2023

Conversation

fballiano
Copy link
Contributor

@fballiano fballiano commented Apr 25, 2023

the WYSIWYG editor shipped with OM is TinyMCE 3.something, it is extremely old and outdated and has at least one known vulnerability.

example:
Screenshot 2023-08-07 alle 09 10 44

what works (everything):

  • loading/unloading the editor
  • localization
  • openmage-variables widget
  • openmage-widgets widget
  • file/image upload

note:

  • there's a small modification to prototypejs in this PR, because the default one is not compatible with the new tinymce

@github-actions github-actions bot added Component: Adminhtml Relates to Mage_Adminhtml Component: Catalog Relates to Mage_Catalog Component: Newsletter Relates to Mage_Newsletter Component: Page Relates to Mage_Page Component: Widget Relates to Mage_Widget JavaScript Relates to js/* Template : admin Relates to admin template labels Apr 25, 2023
@github-actions github-actions bot added the Component: Core Relates to Mage_Core label Apr 25, 2023
@github-actions github-actions bot added the Component: Oauth Relates to Mage_Oauth label Apr 25, 2023
@addison74
Copy link
Contributor

I know that some parts of OM are old and not updated, but they work. However, if it can be replaced with the latest version in next branch, I will approve it after intensive testing.

Please note over 1k issues reported in TinyMCE repository. Here we didn't really face any reports related to this editor.

@fballiano
Copy link
Contributor Author

@colinmollenhour knows why this PR is here, let's just say that outdates software may bring some side effects.

@addison74
Copy link
Contributor

Let's make a visual comparison between what exists now in OpenMage and the proposed version. Even if the current one looks old, by far it has all the intuitive features for an editor. I tried to create a list just pressing a button in version 6 and I didn't succeed. It is probably hidden somewhere but does not appear in the menus.

2

1

@fballiano
Copy link
Contributor Author

It’s not worth testing it now, it’s extremely far from being usable

@addison74
Copy link
Contributor

The browser console must be followed. I get errors as soon as I open the editor. If I enter html tags when I press the hide/show button, the editor no longer retains the changes, errors appear in the console.

@fballiano fballiano changed the title Upgraded TinyMCE to 6.4.1 Upgraded TinyMCE to 6.4.2 May 9, 2023
@github-actions github-actions bot added the Template : base Relates to base template label May 9, 2023
@empiricompany
Copy link
Contributor

for me, it's perfect. I'm already using it with several clients, and they're really satisfied about it

@colinmollenhour
Copy link
Member

colinmollenhour commented Sep 6, 2023

A test suite would be great (and Cypress is an excellent choice) but to me that's a new feature so I think it should not become a blocker for this task. My only stipulations would be that if there is a test suite it must run automated via Github Actions and be easy to setup and run locally.

@pquerner I propose you create a new branch based on the one in this PR and add the Cypress test suite there and if it is done before this branch is ready to merge, great, they can both be merged together. However, if it is not ready in time, no problem, it can be merged later.

It appears TinyMCE doesn't really have their own test suite, but still I think just making sure the basic functionality (turn WYSIWYG off/on) and the OM add-ons (images, variables, widgets) work as expected would be sufficient. If there are changes between TinyMCE 3 and 6 for normal content they will probably not become apparent until it gets broader use and not every difference will indicate there is a regression as we may decide the new behavior is preferred anyway.

So is PHPStan the only blocker now for merging (edit: aside from approval reviews of course)?

@fballiano
Copy link
Contributor Author

@colinmollenhour If I'm not mistaken it's a PHPStan bug with PHP 8.1, nothing to so with this PR, the whole next branch shows this error (regardless of this PR which is not merged yet)

@colinmollenhour
Copy link
Member

Attempting to fix PHPStan with #3498

@fballiano
Copy link
Contributor Author

all green checks again ;-)

@fballiano
Copy link
Contributor Author

It is a bit frustrating not to get a single review for such a big effort mostly @empiricompany put into this.

we prefer keeping a >10 years old component with a published vulnerability instead of this.

@empiricompany
Copy link
Contributor

It is a bit frustrating not to get a single review for such a big effort mostly @empiricompany put into this.

we prefer keeping a >10 years old component with a published vulnerability instead of this.

yes we should merge it ASAP this PR is perfect, i have dedicated a lot of time to it and also fixed all minor things ..
IMHO in general, we should speed up the development of OpenMage and move forward quickly; otherwise, we will miss the opportunity to become a independent and affidable e-commerce platform

Copy link
Member

@colinmollenhour colinmollenhour left a comment

Choose a reason for hiding this comment

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

Awesome work, guys! I've tested in Chrome just clicking around, adding variables, widgets and images and saving an reloading and switching WYSIWYG off and on.

I can't find any issues with it, works beautifully!

@pquerner
Copy link
Contributor

pquerner commented Sep 19, 2023

I've started the cypress tests here btw: https://github.com/pquerner/openmage_cypress_tests
In case anyone wants to take a look.

I think I write a few tests for widget and magento-only functionality and that should be it.

Why its own repo?
I think such tests shouldnt be shipped with the normal openmage (test) code.
Also its very hard to make this automatic, since a instance must be up and running and configured to be testable - not sure how you would do that automatically - other than have a instance ready to go to (at all times).

@fballiano
Copy link
Contributor Author

@kiatng @elidrissidev @addison74 @Flyingmana @tmotyl sorry to bother you but we would need to get some review on this PR.

notes:

  • there's an public vulnerability on the version of tinymce that's currently in OM
  • this PR is for main and I'll backport it as soon as it gets merged

@Flyingmana
Copy link
Contributor

I will need maybe 2 days to fully review the changes.

An advise. If something is of importance for security, keep the amount of changed lines and files low
No codestyle changes.
If the framework/library changes its used variable name, link the previous one to it so you dont need to rename all.

@addison74
Copy link
Contributor

I've been testing it in production for about 2 weeks and I haven't identified any problems. I haven't approved it yet because I have about 5% left to be fully convinced. I also received quite useful feedback. There is room for other changes, but they can be made in time and in separate PRs. In general, these changes are TinyMCE features for which the API must be read in full.

@fballiano
Copy link
Contributor Author

about workflow failing after #3536, I think #3542 would fix. anyway they don't fail because of this PR, it's the next branch failing, not the PR.

@Flyingmana
Copy link
Contributor

These files still use the tinyMCE writing

  • app/design/adminhtml/default/default/template/widget/form/element.phtml
  • js/mage/adminhtml/browser.js
  • js/mage/adminhtml/wysiwyg/widget.js

@@ -112,7 +112,7 @@ var Variables = {
}
};

MagentovariablePlugin = {
OpenmagevariablePlugin = {
Copy link
Contributor

Choose a reason for hiding this comment

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

was it necessary to mix a renaming with a security related update?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

actually the naming changes were done to make it easier to find something like what you highlight in #3220 (comment) actually I'll check them out right now, thank you for noticing!!!

@@ -34,10 +34,11 @@ public function indexAction()
{
// save extra params for widgets insertion form
$skipped = $this->getRequest()->getParam('skip_widgets');
$skipped = Mage::getSingleton('widget/widget_config')->decodeWidgetsFromQuery($skipped);
if (is_string($skipped)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

for type safety you should put $skipped as an empty array for the else case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in order not to drag this PR any longer I'd address it in a separate PR ASAP :-)

} else {
return null;
}
getMediaBrowserCallback: function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did we change method names of our own class here? isnt this a BC Break?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

well initially my idea was to have it in the next branch because, since all tinymce's variables/objects have different names between v3 and v6... everything is BC so having better names for our method didn't make any change.

later it was sad to have it into main which changes things a bit but at the end of the day, all of tinymce's scripts are still incompatible so... also if we don't change our naming... we don't get much compatibility anyway.

what do you think?

},


getSettings: function (mode) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We can do this later in a separate PR

@Flyingmana
Copy link
Contributor

None of the things I commented I would count as blocking because of the security relevance, but maybe we should look again at them and if needed fix them later then

@fballiano
Copy link
Contributor Author

is it ok if I merge and port to main now? then work on @Flyingmana's notes in a PR on the main branch?

@addison74
Copy link
Contributor

I looked over this PR this weekend too. There are still changes to be made, but they are not a priority because all are related to with UI/UX. The editor is functional and ready for production.

Could we extract the version we are replacing in a repository? If someone is not happy with this new version and wants the previous one, he can replace it on his own responsibility.

I agree with porting to the main branch and we continue the work from there. All future PRs will go to next too.

@fballiano
Copy link
Contributor Author

@addison74 create something like an extension to return to tinymce v3 is complex because it's like 500 files, with phtml in many different places, I'm sorry but I really wouldn't do that, it's too much work and I can't dedicate that time. anybody could do it if somebody feels the need for that, although highly un-suggested because of the security implications.

@fballiano
Copy link
Contributor Author

oki guys it's time, I'll merge and port to main so we can continue there, I feel that after ZF1F this is another major stepstone!

@fballiano fballiano merged commit 9c7e07e into OpenMage:next Oct 2, 2023
@fballiano fballiano deleted the tinymce6 branch October 2, 2023 12:40
fballiano added a commit that referenced this pull request Oct 2, 2023
Co-authored-by: Tony <[email protected]>
Co-authored-by: Tony <[email protected]>
@colinmollenhour
Copy link
Member

Nice work, @fballiano! Also thanks for everyone else's testing and feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Adminhtml Relates to Mage_Adminhtml Component: Catalog Relates to Mage_Catalog Component: Cms Relates to Mage_Cms Component: Core Relates to Mage_Core Component: lib/Varien Relates to lib/Varien Component: lib/* Relates to lib/* Component: Newsletter Relates to Mage_Newsletter Component: Oauth Relates to Mage_Oauth Component: Page Relates to Mage_Page Component: Widget Relates to Mage_Widget help wanted JavaScript Relates to js/* Template : admin Relates to admin template Template : base Relates to base template
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants