Deesen / YAMS

Original Fork of YAMS (Yet Another Multilingual Solution for Evolution CMS)
http://modxcms.com/forums/index.php/board,381.0.html
8 stars 7 forks source link

YAMs php warning after evolution 2.0.2 migration #27

Closed ericfilippi closed 4 years ago

ericfilippi commented 4 years ago

Hello,

After migrating from evolution 1.4.10 to 2.0.2, I get some errors in the manager back office đź‘Ť

Warning: Use of undefined constant IN_PARSER_MODE - assumed 'IN_PARSER_MODE' (this will throw an Error in a future version of PHP) in root_dir/core/src/Core.php on line 745 Warning: Use of undefined constant MODX_API_MODE - assumed 'MODX_API_MODE' (this will throw an Error in a future version of PHP) in root_dir/assets/modules/yams/yams.plugin.inc.php on line 35

When I deactivate YAMs plugin, both errors disappear. I guess that there is a problem in yams.plugin.inc.php on line 35 but I don't want to break everything adding quotes ...

Where is defined MODX_API_MODE constant ? Can I fix the problem replacing MODX_API_MODE by 'MODX_API_MODE' ? => but this seems to be not so clean.

Thank you for your help. Eric.

Deesen commented 4 years ago

Hi, to be honest I am not sure how to solve this issue best yet to guarantee compatibility with Evo 2.0.2. But you can try replacing Line 35

if(MODX_API_MODE) return;

by

if(defined('MODX_API_MODE') && MODX_API_MODE) return;

ericfilippi commented 4 years ago

Thanks it works fine ! no more php errors

But there's another trick

i'm trying to work on YAM's compatibilty with Evo 2.0.2 and I found that something goes wrong in yams.plugin.inc.php in the event OnBeforeDocFormSave while accessing : global $tmplvars => this seems to have been moved. Saving a ressource just crashes.

Is this global $tmplvars an Evo one or a YAM's specific one ?

I don't want to bother you nor ask you to find the solution. I just wonder if we can get rid of all the statements "// The pagetitle has been marked for deletion because it is empty. Undo that..." or if it's absolutely necessary to keep them to make YAM's work.

If so => I comment all the pieces of code related to $tmplvars use and the ressource is saved without crashing If not : I need to further investigate ... or give up YAM's to another multilingual extra (lot's of work)

Eric

Deesen commented 4 years ago

I think global $tmplvars is from old Evo code-base. But I don´t think it makes sense to just comment out all code related to $tmplvars, as YAMS is using TVs essentially for its multilanguage-mechanismn (content_en, content_fr etc... all of them are TVs).

ericfilippi commented 4 years ago

Actually, after a few hors of trying to understand the logic and new modx constraints, I rewrote a part of the plugin code using new evolution cms API functions such as $modx->getConfig() and $modx->getDocumentObject('id',$docId). I followed the same logic as you did, just replacing deprecated $tmplvars variable by modx API, and using the event "OnDocFormSave" instead of "OnBeforeDocFormSave" because DocumentObject has not the good values before the effective save. So instead of preventing modx to delete empty tvs, I just recreate then afterwards.

Then I reviewed all the YAMS php files for these items :

I'm now about to do a couple of tests for my needs, but I'm don't have the time to build a full test protocol.

If you have a full test protocol in your archives, I would appreciate that.

I'll then propose a pull request with this new v2.0.2 compatible version of YAMS. (modx developpers recommended me to move to BLang extra, but I assumed (and this was a good decision) that the work on YAMS would be easier for me)

Cheers, Eric

ericfilippi commented 4 years ago

I made a pull request to proposed an update to v1.3.0 that close this issue. Just need to merge it to the master branch.

I also updated the doc in the new Evolution CMS doc on GitHub : https://github.com/evolution-cms/docs/tree/master/en/04_Extras/YAMS

When the merge is done, I'll need to post This release on the new Evolution CMS extra repository.

Deesen commented 4 years ago

Thanks for all your efforts man and sorry for the delay!

ericfilippi commented 4 years ago

Hi,

Thank you very much !

If there are issues, I will be the first to see them I guess … So I can help in a “best effort basis”.

Eric FILIPPI

eric.filippi@yahoo.fr

De : Deesen [mailto:notifications@github.com] Envoyé : mardi 9 juin 2020 17:22 À : Deesen/YAMS Cc : ericfilippi; Author Objet : Re: [Deesen/YAMS] YAMs php warning after evolution 2.0.2 migration (#27)

Thanks for all your efforts man and sorry for the delay!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Deesen/YAMS/issues/27#issuecomment-641367024 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AK4XMVNWIUTLYBHU33PXWHDRVZHP7ANCNFSM4MDYZNMQ . https://github.com/notifications/beacon/AK4XMVNL4UV5ZNCYDRCJCALRVZHP7A5CNFSM4MDYZNM2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEY5HX4A.gif