Page MenuHomePhabricator

Avoid duplicate PHP logic between ZObjectEditAction, ZObjectContentHandler, and SpecialCreateZObject
Open, MediumPublic

Description

I noticed there's a lot of duplicate lines of code across

ZObjectEditAction.php
ZObjectContentHandler.php
SpecialCreateZObject.php

...should we find a way to deduplicate?

  • The code to generate the placeholder for the Vue app to load and to configure it
  • The code to generate the language ISO code shown next to labels of ZTypes and ZObjects
  • Others?

Event Timeline

Currently working on it (I'll try to push my work in progress ASAP)

I could quite easily factorize code between ZObjectEditAction.php and SpecialCreateZObject.php in a mixin I declared

I encounter more difficulties about factorizing content in ZObjectContentHandler.php. I think I don't understand yet the role of the fillParserOutput function and the role of some variables (and what they represent).

I'll try to figure out how to trigger the fillParserOutput by myself (so I can step-debug it), but if you have time to help me on it, that would be much appreciated! :)

Change 826984 had a related patch set uploaded (by Teleosteen; author: Teleosteen):

[mediawiki/extensions/WikiLambda@master] Deduplicate code between SpecialCreateZObject and ZObjectEditAction

https://gerrit.wikimedia.org/r/826984

(I pushed my work in progress as promised)

Change 827563 had a related patch set uploaded (by Teleosteen; author: Teleosteen):

[mediawiki/extensions/WikiLambda@master] Factorize iso code getArgumentDeclarations

https://gerrit.wikimedia.org/r/827563

Jdforrester-WMF renamed this task from PHP duplication to Avoid duplicate PHP logic between ZObjectEditAction, ZObjectContentHandler, and SpecialCreateZObject.Aug 29 2022, 9:25 PM
Jdforrester-WMF updated the task description. (Show Details)

Change 827990 had a related patch set uploaded (by Teleosteen; author: Teleosteen):

[mediawiki/extensions/WikiLambda@master] A bit more of cleanup and factorizations

https://gerrit.wikimedia.org/r/827990

I guess we could do more, but it would probably take time for me (maybe more functional and technical background on WikiLambda can help doing more).

Review welcome! :)

Also I can squash the commits, I don't think it is worth to keep 3 commits for this ticket.

Change 826984 merged by jenkins-bot:

[mediawiki/extensions/WikiLambda@master] Deduplicate code between SpecialCreateZObject and ZObjectEditAction

https://gerrit.wikimedia.org/r/826984

Change 827990 abandoned by Teleosteen:

[mediawiki/extensions/WikiLambda@master] A bit more of cleanup and factorizations

Reason:

Commit squashed into b95710285e

https://gerrit.wikimedia.org/r/827990

Change 827563 merged by jenkins-bot:

[mediawiki/extensions/WikiLambda@master] Deduplicate code between ZObjectContentHandler and ZObjectEditAction

https://gerrit.wikimedia.org/r/827563