Commit graph

51 commits

Author SHA1 Message Date
Brad Jorsch 1c3dd4fb0d Replace use of &$this
Use of &$this doesn't work in PHP 7.1. For callbacks to methods like
array_map() it's completely unnecessary, while for hooks we still need
to pass a reference and so we need to copy $this into a local variable.

Bug: T153505
Change-Id: Ib31f3bbffdd6b25ad9a21498294644e4dde33bd1
2017-01-31 22:54:07 -05:00
Darian Anthony Patrick a16c563459 Skip shell invocation on large input
Add a sanity check to the math extension that skips shelling out to
texvc if the input is insanely large.

Bug: T129506
Change-Id: I2c7b6561464bddb4c3eab9230fa8168b24adaa37
2017-01-20 15:09:56 -08:00
Physikerwelt 797c8ddfc9 Revert "Add class mwe-math-element to math elements"
This reverts commit e674d7e73b.
That commit does not help to solve T134281.
It adds a CSS class name which is configurable
by a global variable to various math elements, which is confusing.

Change-Id: Iea5f231e0cea1221dc717b3409b36c0baf11bb24
2017-01-03 23:57:46 +00:00
tameeshb e674d7e73b Add class mwe-math-element to math elements
This is the fix for the bug that makes the whole page scroll when long 
equations are present in the wiki article.

Bug: T134281
Change-Id: I29f8df027384098cd0923bcfa23a914c8d887bba
2016-12-21 23:03:18 +00:00
Aaron Schulz 3a6617faf0 Set the stream and buffer reset methods for the default backend
Change-Id: Ia28c92a66a217cea24ff70f5be1a51a53fa5d6f8
2016-09-28 15:10:20 -07:00
physikerwelt 0d55341ff9 Fix: Convert all array() syntax to []
The signature of the Hook function is not respected.
Thus parameters need to be passed by reference explicitly.
For syntax validation to pass, this requires
mediawiki-codesniffer to 0.6.0

Change-Id: I90b6501000200c1b462407b769113358eb5c762f
2016-04-19 21:41:42 +00:00
physikerwelt 6f7bcaf2c6 Update to mediawiki-codesniffer 0.6.0
Change-Id: I2a1a74c771bc00f6c1569568dfcf474f06714426
2016-04-19 17:07:21 -04:00
physikerwelt 6699724d65 Convert all array() syntax to []
Per wikitech-l consensus: https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Change-Id: I1d2604e3f246ede58ff8245ba2b940f258d2d80c
2016-04-13 10:18:23 -04:00
Marko Obrovac a3072e273b Logging: adjust the log entry levels
Most info-level log entries are actually debug messages, which should
not end up in the production log by default, so adjust them.

Only the Mathoid-powered TeX check fail has been promoted to info so
that we can quickly identify such requests from pages.

Bug: T121445
Change-Id: I3736c59f6425d675befea9438182ee1cdebe5fc5
2015-12-15 00:14:15 +01:00
Marko Obrovac c3ebc54994 Minor: rename checkTex() to checkTeX()
Change-Id: I9b1860562b2f4f2112b68c0c3d6f0390f0405fbe
2015-12-14 23:58:08 +01:00
physikerwelt 1ec767791b Make math usable without RESTbase
* Do not contact RESTbase in texvc rendering mode and
  use the well established tex checking that is already build
  into texvc.
* Do not use RESTbase in LaTeXML mode.

Background:
In I1982612e8c6a356e3dbdf447724ac82e5968cc77 RESTbased replaced
texvccheck that was a derivate of texvc designed for people
that wanted to use secure MathML rendering using mathoid.
The integration of mathoid to restbase made this feature obsolete.
However, texvccheck was not only used to check the latex input
that was sent to mathoid, but also the string which was sent to texvc.
Since texvc has already build in tex checking this is not
required and does not improve security.
Finally, users updating from old versions of the math extension
(prior to 2014) that do not have textexvccheck installed,
do not need to compile the texvccheck binary after this change.

PS5: Also treats the case where VisualEditor is not installed.

Bug: T121173
Change-Id: I1bd076b09206869b5ed75280d22e1b36bfb8d8ad
2015-12-11 22:04:12 +01:00
Aaron Schulz 7bbf7c6b68 Fix "Call to a member function getIsPreview() on a non-object (NULL)"
Also, the isset() checked was backwards

Bug: T116257
Change-Id: I419208bd9ad1a7a758bf9dbe0450020a9f14d39e
2015-10-23 18:09:35 +00:00
paladox df8ad1c799 Add php code sniffer to composer
Add support for php code sniffer

Change-Id: I7dcdd88be4f1f8219f71ab770979284761e09bae
2015-09-23 10:46:14 +01:00
jenkins-bot 032fb79f67 Merge "Remove use of deprecated wfRunHooks" 2015-08-06 18:03:31 +00:00
addshore a1c1e759a6 Remove use of deprecated wfRunHooks
Change-Id: I9800664555a9a6a54c3a62ed29928346fb87b194
2015-08-06 18:58:42 +01:00
physikerwelt bc52c77d24 Use extension.json, empty PHP entry point
* Use string constants instead of integers
* Derive new names from old via conversion of constant
  naming convention to CamelCase.
* Replace old constant string e.g. 'MW_MATH_ABC_DEF'
  with new string 'abcDef'
* Replace old constant value with new string.
* Tests to demonstrates what is actually done.
* Rename constants

Bug: T106630
Bug: T106631
Bug: T87941
Change-Id: I6d1094ece79e912d9ddbef6681a25196c7a6e801
2015-07-30 22:01:20 +00:00
Bartosz Dziewoński bc81cdd4b7 Pass arguments to ParserAfterParse by reference
The workaround to save PNG images calls the hook wrong,
the parameters must be passed as references.

Bug: T105598
Change-Id: Ic77aa79aa6e2bf2a9ec00be4cc775d0123bed91a
2015-07-22 15:36:48 +00:00
physikerwelt 1baec69f25 Add required arguments to ParserAfterParse hook call
* add missing global $wgHooks

Bug: T99212
Change-Id: Ia8993e55a4abd6580504e422eb84ebd4ed09544c
2015-06-04 14:21:13 +02:00
physikerwelt 1cd0dad54f Update Hook call
* Replace deprecated wfHooksRun with Hooks::run
* move texvc specific bugfix to texvc class

Change-Id: Iba2aff9205ebbb39e256396072282e2ed96cc4b0
2015-04-24 20:47:54 +00:00
Kunal Mehta 241800f80d Use namespaced \MediaWiki\Logger\LoggerFactory
Change-Id: I78fca87d87379a694662c1a4ecc42e9401fd4c2c
2015-04-16 07:33:29 +00:00
Bryan Davis 23ff28d71d PSR-3 logging cleanup
* Limit levels to MediaWiki recommended debug, info, warning, error
* Don't add trailing newlines
* Capitalize messages

Change-Id: I211357b1cc014d6bed1717f22e2bf8ebfc4f386f
2015-03-18 12:13:05 -06:00
physikerwelt 5e46586ada Update to PSR-3 logging
Change-Id: I8b61cec606e75a3cf2143b1fa54e5dff2cfa3c7f
2015-03-18 17:26:01 +00:00
physikerwelt 6742dedda4 Code style cleanup
Cleanup whitespace and quoting, mostly related to logging function
usage.

Change-Id: I82ff6a31cd191119ec0c71c32eeb9570afd629db
2015-03-18 15:41:04 +00:00
Chad Horohoe 0404113641 Remove obvious function-level profiling
Change-Id: I41d48da124e38c46ce71aa9d3b756096a424df1c
2015-02-12 12:14:24 -08:00
physikerwelt (Moritz Schubotz) 31c38bdf76 MathMathML, MathTexvc: Improve PhpDoc
Change-Id: I84af65e15bdae81f69f0444afdd9ffa5fe9fc326
2015-01-22 19:13:11 +00:00
Frédéric Wang 3d0b787cbe Move vertical-align back to ext.math.css
This improves If8ee1cf6453257a0a2f6aa186d4007954a8e5d8e

Change-Id: I794b39a5d322a92d9f722ded790e213803448127
2014-10-12 18:22:06 +00:00
Frédéric Wang 296c79e070 Rename fallback-svg and fallback-png to fallback-image
- Merge fallback-svg and fallback-png into one fallback-image class.
- Move the vertical centering of PNG to MathTexvc and ext.math.js.
- Remove "img" from ext.math.css to reduce CSS specificity and make
  style easier to override by user stylesheets.
- Add a comment about the !important rules for centering in
  display mode.
- Only load ext.math.scripts in MathML mode.

Bug: 71955
Change-Id: If8ee1cf6453257a0a2f6aa186d4007954a8e5d8e
2014-10-12 13:42:01 +02:00
physikerwelt (Moritz Schubotz) 4459c5c452 Avoid unnecessary database reads
Use the cached function isInDatabase rather than readFromDatabase to
 avoid unnecessary read operations on the database.

 Currently, readFromDatabase is usually called only once during instance
 livetime. But after I455b41c8b8d918f4c34f6c115194d227a8394e0a has bben
 merged chances are that it's called twice.

Change-Id: I6434195ad1d323a578a8fdca1b4555e11ab30a15
2014-09-06 02:34:30 +00:00
physikerwelt 65642489ae Separate render and getHtml
Currently the method render always returns
a html string that can be a string that
represents the correct result or a rendered
error message.
This change splits rendering and
fetching of the HTML output.
This simplifies the logic of the rendering
and caching mechanism.
Now the render method returns a boolean that
indicates if the rendering was sucessful or
not.

Step 2/2

Warning: Errors in this change might affect
caching logic and squid caches.

Change-Id: I00502b84212ed70cdf63bd69916a35afbd6fdbc1
2014-06-09 23:21:44 +02:00
physikerwelt c390f6479a Add getHtmlOutput method
Currently the method render always returns
a html string that can be a string that
represents the correct result or a rendered
error message.
This change adds a mechanism that allows
to fetch the HTML output.
In a followup commit the rendering function
is changed to return a boolean value rather
than the rendering result.
This will simplify the error handling and caching.

Change-Id: I80760493e391911c41eb69d75a93c6a34db8852e
2014-06-06 21:52:35 +02:00
physikerwelt (Moritz Schubotz) c7197bee19 Add separate database table for LaTeXML (step 5)
Currently the PNG and the LaTeXML rendering mode
use a common table in the database. If both rendering
modes are allowed in a wiki simultaneously this causes
problems, because the fields are continuously overwritten.

This is patch changes the logic of the rendering
engine to use the specific database.
The caching logic is now simpler to understand.
A entry is written to the database if the changed field
of the MathRenderer class is true. Is is triggered by the
setters of the database relevant fields.


Bug: 65522
Change-Id: Ief9de889b9292b21c9d1529a8b1797f38196edad
2014-05-31 10:34:21 +00:00
physikerwelt bf33d51320 Add separate database table for LaTeXML (step 3)
Currently the PNG and the LaTeXML rendering mode
use a common table in the database. If both rendering
modes are allowed in a wiki simultaneously this causes
problems, because the fields are continuously overwritten.

This change adds the method getMathTableName that will
allow renderers to access their specific table in the
database.

Change-Id: I8b11ffd0a39fadd7d3c8de1e94e74ff5f490430d
2014-05-27 05:33:20 +00:00
Moritz Schubotz (Physikerwelt) c5b0b15d8f Fix MathJax centers equations
* Removes the MathJax heuristics that decides
  if equations are centered or left-aligned.
* Introduces the attribute display to specify
  if the math element is rendered in inline,
  display, or inline-displaystyle.
* add css rules for display / inline math images

Bug: 61051
Change-Id: Iba69903f781f0cb1606b8ddcffb90fb86c9b229b
2014-04-06 21:58:30 +00:00
physikerwelt 94b035b26a Coverage tests for the Math extension
* Include generated tests for a better test coverage
of the Math extension.
* Compiles texvc in testsuite (if required)
* Test generator now included
* Replaces the old parser tests
* Fixes whitspace issues

Bug: 61090
Change-Id: Iff7eeb5ee72137492c3f6659e4d4d106e5715586
2014-03-11 15:35:07 +00:00
Aaron Schulz 078347b35e Update the DB output hash if outdated according to texvc
* Otherwise all future <math> hits will check the wrong file
  (which may not exist), recreate the png, and store over the
  proper file (even if it was already there). Update the DB to
  point to the right hash instead.

bug: 60997
Change-Id: Ib833ad32ff1e4506e9b8ab2cc1b72516cb072cd5
2014-02-14 23:42:17 +00:00
Moritz Schubotz ff83048597 fix: texvccheck is not idempotent
The output of texvccheck is not only "checked" but also
rewritten to another form.
(For example $\R$ is transformed to $\mathbb{R}$.)
But the output might not be a valid input for the thexvccheck
part of texvc, like it happened in for the example given in the bug
description.
See also I599c4390da9b8f36d800f379a33ad5ce90f5096c
Bug: 61012
Change-Id: Iae5e350cb78c0e637e574390c586fbdb8dc38496
2014-02-07 10:27:21 +00:00
physikerwelt 6a0af8f3b4 Validate TeX input for all renderers, not just texvc
The user input specified in the math tag a. la
<math>E=m <script>alert('attacked')</script>^2 </math>
is verified in PNG rendering mode, but not in plaintext, MathJax
or LaTeXML rendering mode. This is a potential security issue.

Furthermore, the texvc specific commands such as $\reals$
that is expanded to $\mathbb{R}$ might be rendered differently
depended on the rendering mode.

Therefore, the security checking and rewriting portion of texvc
have been extracted from the texvc source
(see I1650e6ec2ccefff6335fbc36bbe8ca8f59db0faa) and are
now available as a separate executable (texvccheck).

This commit will now enable this enhancement in security and
provide even more compatibility among the different rendering
modes.

Bug: 49169
Change-Id: Ida24b6bf339508753bed40d2e218c4a5b7fe7d0c
2014-01-22 10:07:27 +00:00
vishnu 0ab1280d6b Fix depreciation warnings in FileBackend construction
Added wikiId and lockManager was changed to an object
Bug: 58615

Change-Id: Id3bdc7e6bc3951db4753553da03193783f0bd7c8
2013-12-27 23:27:32 +05:30
Aaron Schulz f0f19007c5 Buffer png writes and flush them all at once
* This should half the time to render pages with many formulas

bug: 56769
Change-Id: I5edf979c31fe12098eba1d1df52c9cd3251bd115
2013-12-27 10:42:27 +00:00
Max Semenik 4d68c31de1 Add profiling
Change-Id: I9066f6b2606044412a9b91ca395e841550d7e787
2013-11-18 14:46:00 +04:00
Ori Livneh 679ce7fe2f Log texvc errors in 'texvc' log channel
This patch adds wfDebugLog() calls for conditions related to texvc invocations.
The logs are grouped under a 'texvc' group, added for this purpose. The reason
for logging into a separate channel is that the Math channel is too verbose for
production use on the Wikimedia cluster.

Change-Id: I05a17a0230f49f5d698b91617d06b3e3f838b67d
2013-10-14 15:59:21 -07:00
physikerwelt 90d678782f Fix: PHP Style corrections
* Explicit function visibility
* Uniform constant definition

Change-Id: I5f064d2eac0dedd4c8cc94f442c65f0e338ebbf4
2013-06-07 15:37:56 +00:00
Matthew Flaschen 32e2f4d4f5 Use i18n params for errors than appending raw string, with test
* Remove parameters/append that are never outputted by texvc.ml
* Add missing math_output_error to i18n file
* Improve a few qqq descriptions

Change-Id: Iea5139682fbe8389e578549f5f62e5505f4c0b48
2013-05-18 01:48:16 -04:00
physikerwelt 5245d0f555 Introduce getter and setter for the MathRenderer
Adds a new method isChanged() for determining if a value was changed.
This is done in preparation for a more elaborated caching method that is
handled inside the abstract base class.

Change-Id: Ica15f77d96453d30edd3a117c7185c694ad3691e
2013-05-03 21:12:36 +00:00
physikerwelt 08b93eebd6 renaming of read and write methods for database access
readFromBB->readFromDatabase
writeDBEntry->writeToDatabase

Change-Id: I426be5dc479ad789d0e85b149a989a581945c9be
2013-04-24 06:03:37 +00:00
Matthew Flaschen aa8a0eaf19 Write cache unless there *is* a cache hit:
Moves writeCache call back to hooks (changed in 9ba4ef269d)
 and makes it unconditional, so only one part of the code decides
whether to write to the cache.

Bug: 45973
Change-Id: I6b387795304ff15c960fcf0f5354a9ac939e1212
2013-03-12 00:38:45 -04:00
Matthew Flaschen 3916ac167c Revert "(Bug 45973) Fix check for avoiding re-cache"
Revert unreviewed self-merge with pending issues.

This reverts commit f5422cf85a.

Change-Id: I17471e2adccf54b79a9d8185c4a6f4b6937ce622
2013-03-12 00:24:43 -04:00
Ori Livneh f5422cf85a (Bug 45973) Fix check for avoiding re-cache
If the request could not be served from the cache, we *do* want to cache it.

Change-Id: Id58dac55ce79f568e4b4a42a155235af5a46bf7f
2013-03-12 04:16:21 +00:00
Ori Livneh 9ba4ef269d Only update the cache on cache miss
Change I9b1d68c4faa8d177d8d0088fa1a5879caed4f1fe added an indiscriminant call
to writeCache(). I assume that it was supposed to be regulated by the check for
$this->isRecall() (which is a getter for '$this->recall'), but there was no
concomitant change to ensure that recall is set true on cache hits.

My fix does not set recall to true. The style of "pass-by-attribute" is tricky
and should be factored out by a subsequent change. This change moves the call
to writeCache() so that it is only called on cache miss.

Change-Id: I9b690e55001859c97fd40330272791d49ec6de75
2013-02-21 17:39:17 -08:00
Matthew Flaschen 8a04254e6d Change default LockManager back to nullLockManager.
* This was changed in 926db7c3bd as a workaround for a testing issue.
* See 8cbd679aac781bdd73038064261736a937645fc1 , which fixes the test harness in core .

Change-Id: Ib57cafee35a699ce875ee4bc8951781e1a37553a
2013-02-08 13:59:26 -05:00