Commit graph

115 commits

Author SHA1 Message Date
C. Scott Ananian b84b71af22 Gallery: shift TSRs in the DOM, rather than fibbing about srcOffset
Passing srcOffsets which don't actually correspond to actual regions of
the source wikitext cause problems in the token offset conversion code.
Instead, parse the wikitext as itself, then adjust the TSRs in the DOM
tree.

Since Gallery isn't ported to PHP (yet), update the
automatically-generated Gallery/index.php.  The newly-added
ContentUtils::shiftDSR() was ported, however.

Change-Id: I28f3d3398930733ae2bcf9759e49c45f93bc7190
2019-06-28 14:10:16 +00:00
C. Scott Ananian c790d125de Convert dsr properties to DomSourceRange instances in PHP port
Change-Id: I7795cedf14e6ff56a31eeaba0a32c3c5c3166f08
2019-06-27 15:35:05 -04:00
Subramanya Sastry 720f1db084 Fix exception handling: Don't catch exceptions and suppress them
* Now that we are in sync land, we don't need to catch exceptions
  and log error messages at multiple places. Let them bubble up
  to the top.

* I noticed this was actually getting in the way of debugging because
  with $env->log unimplemented, I was only getting very generic
  failures instead of the root cause that was being suppressed
  and unlogged.

* There are still a couple of places where we have generic Exception
  catching in place where it does make sense currently. For example,
  we aren't interested in what caused a templatedata fetch to fail.
  We simply fall back to regular serialization - the rationale here is
  that it is better to emit a transclusion without the preferred formatting
  (but syntactically correct) instead of losing the edit altogether.

* Minor unrelated fix in Cite/Ref.php: Use !isset() instead of empty()

Change-Id: Iebff6f37dcd8278185c4a74b72a99b528efa20ff
2019-06-26 15:50:49 -05:00
Subramanya Sastry bc72a99fb2 Minor fixes to Cite port
Change-Id: Iccd6823c572059948e5ad1a7c91d567d39494934
2019-06-26 11:59:48 -05:00
Subramanya Sastry 3f0b81b085 Followup to 31d356a5, 005176a3 and assorted fixes
* Source offset fixes: followup to 31d356a5
  - there were instances of $tsr[0] and $tsr[1] that hadn't
    been converted over to $tsr->start, $tsr->end
  - removed dead code

* Cite fixes: followup ot 005176a3
  - Fixes array / object mixups
  - Bug fix

* html2wt/WikiLinkHandler fixes
  - Protect access to missing properties in data-mw opt list

* Other assorted fixes
  - Added missing typehints and improved doc types
  - Simplified some code patterns
  - Cast extension attributes to object since that ends up
    in data-mw which is a stdclass object.

Change-Id: Idd04b0d3819be3660823047a90330fd1213388cf
2019-06-24 16:56:56 +00:00
Pavel Astakhov 005176a355 Port Cite extension
* All wt2wt, html2wt, and all but one html2html tests pass in
  hybrid mode when entire html2wt code is run in PHP

  Set "Serializer: true" in the html2wt section of phpconfig.yaml

* The single failing html2html test is a <gallery> test which is
  presumably related to the unported <gallery> extension code, but
  not sure. Not investigating it now.

* Update Parsoid Extension API to provide access to extension source
  without exposing internals.

Change-Id: I6d6e21ad2324acfc4306b32c9055d6c088708c48
2019-06-21 16:23:42 -05:00
C. Scott Ananian 4e334fa727 Fix an incorrectly capitalized typeOf in automatically-generated code
Follow up to 04efa43c4c.

Change-Id: I12fa70f002ba65b5a5835ef65a557b6c39782f51
2019-06-20 18:54:13 -04:00
Subramanya Sastry 30aaf6574c DOMFragments: Use sealFragment instead of unwrapFragment
* unwrapFragment had a somewhat unusual behavior which could be
  a source of bugs while reasoning with it.

  If undefined, it's default value is true which is contrary
  to how we think of undefined.

* Flipping the polarity of the flag to sealFragment makes the
  semantics easier to reason with and where !empty(..) applies
  more naturally to it.

Change-Id: Ia50cba345f37e815e5f5f95abb452c8eefcf9011
2019-06-13 13:38:20 -05:00
C. Scott Ananian 320d045ee8 Update automatically-generated PHP files w/ latest js2php
Mostly comment formatting improvements, some significant code changes
to the JS side.

Change-Id: I7a8f2105173df74dc09f2024d68268f5dc6fa632
2019-06-05 17:13:34 -04:00
Arlo Breault 05cb13ddf9 Make extensions with post-processors return constructors
This allows us to finish the cleanup started in 0b3bb10 and inline
setupProcessors.

Change-Id: Ia7840091607e9a75153031b5db7600d5a0018da6
2019-04-03 18:44:21 +00:00
Arlo Breault 20c627e3f4 Convert cite extension to es6 class structure
Also, runs js2php on these files.

Change-Id: Id8ee13ad536d75f63e0045a21fdfdb667a0df65d
2019-04-03 12:20:41 -04:00
C. Scott Ananian eb70a83eb0 Audit uses of Node#getAttribute() + add missing file to PHP codebase
In PHP, DOMNode#getAttribute() return '' if the attribute is not present,
not null.  Audit our uses and try to either explicitly use `|| ''` (which
will ensure that PHP behaves the same was as JS) or use `hasAttribute`
to explicitly test for the presence of the attribute.

Changes have also been ported to PHP from JS.
Also added src/Wt2Html/PP/Processors/AddMediaInfo.php which was missing.

Change-Id: Ie1ae1df88e4fca70daf97b6f720f28014ebc99ed
2019-03-15 15:48:20 +00:00
C. Scott Ananian 25385a06e8 Apply recent JS changes to automatically-generated PHP port
This applies the JS changes from the following recently-merged patches:

6679c3bf Protect data-object-id attribute
d4e76d5b Fix new linter category to enable code work with templates
e567db8d Tweak storeDataAttribs to suppress DOM nodes in data-parsoid.tmp
16603953 Fix setting dsr on body for genTest
3a84a9dd Fix stashing data attributes for mw:StartTag
22c4a19a Remove redundant dataParsoid call
ed7b0ba0 Fix crasher in newly added linter category
505a357b Linter.js: Add new function to detect the use of links in links
8885b20e Move redlink updating into lib/parse.js
ccfce23d templatedepth is either an int or false
6d1571bd Move language conversion work into lib/parse.js
5a89c7de Avoid serialize/parse of data attributes when treebuilding
021d9958 Rename `document.env` to `document.bag`
c03ba494 Use XMLSerializer on both PHP & JS side in the DOM pass test script
e0c3cca9 Use env.createDocument in lib/api/apiUtils.js
550d3d71 Use a bag-on-the-side implementation for node data
f8de8b25 Add bin/inspectTokenizer.js
db704eea Add ability to splice a PHP transformer into the pipeline
a8be3ad6 Fix crasher in cite extension from accessing data after it's stored
2874f200 Simplify and clean up stops usage
6368265d Add some strategic isElt guards
5ae9553f DRY out transform test runners + tweak genTest to enable that
b0f2adc6 Assert that the .dataobject isn't touched after storing attrs on a node
1ce6a98d Skip separators when looking for the next th/td

Change-Id: I6a66ecb061e7ee7ed53feba1895dd315d9324715
2019-03-05 17:33:32 -05:00
C. Scott Ananian f2948cd170 Skeleton PHP files generated by automatic conversion from JS
Change-Id: I93dbbdb474d37f88e0bab1d810b3dd51304055fd
2019-02-13 12:34:44 -05:00
Subramanya Sastry bf21cf0ce9 Init src/ with .js files copied over with .php extensions
* This initialization lets us do a git log --follow and follow
  git history for that file across the js -> php port boundary.
  This works because git uses content hashes for objects and
  the copied code in the new .php file will have the same content
  hash as the .js file.

* The following directories were skipped
  - ./lib/config/baseconfig
  - ./tests

* The following JS files were skipped
  - ./lib/utils/promise.js
  - ./lib/config/wmf.sitematrix.json

  - ./tools/sync-baseconfig.js
  - ./tools/sync-parserTests.js
  - ./tools/fetch_ve_nowiki_edits.js
  - ./tools/fetch-parserTests.txt.js
  - ./tools/fetch-wmf-sitematrix.js
  - ./tools/compare.linter.results.js
  - ./tools/fetch-revision-data.js
  - ./tools/fetch-wt.js
  - ./tools/regression-testing.js
  - ./tools/build-langconv-fst.js

  - ./bin/server.js

Change-Id: I0b22057c23b72795aebbd66e3abcb627c6858ef3
2019-01-09 11:59:29 -06:00