aboutsummaryrefslogtreecommitdiffstats
path: root/includes/diff/ComplexityException.php
diff options
context:
space:
mode:
authorMax Semenik <maxsem.wiki@gmail.com>2016-04-26 18:10:26 -0700
committerMax Semenik <maxsem.wiki@gmail.com>2016-06-01 16:30:58 -0700
commitdd57ff3cce86f3055c249a414c49b74f2bcb3497 (patch)
tree31b4ef5a9227d629b5173b70a04b774c7ac0e8c3 /includes/diff/ComplexityException.php
parent218e89d5b467840b800316df2cefcc07509d0f1b (diff)
downloadmediawikicore-dd57ff3cce86f3055c249a414c49b74f2bcb3497.tar.gz
mediawikicore-dd57ff3cce86f3055c249a414c49b74f2bcb3497.zip
Rethink diff limits
Now, instead of "if your changed paragraphs are larger than 10Kb, you're screwed": * Instead of relying on overall length, estimate complexity after splitting to words and taking any equal head and tail out of equation. * Estimate based on words changed, which better reflects the actual complexity of generating a diff. * New limit is determined scientifically, i.e. "above that number XDebug starts complaining about recursion limits reached in Vagrant". Caveat: if new limits are hit, the consequences are more widespread as all adjacent changed paragraphs are displayed without word level diffs, as opposed to only the paragraph that's too long being affected. However, the new limit is much higher and in wikitext you're supposed to put empty lines between paragraphs anyway, negating this problem. Bug: T128697 Change-Id: I4e91c7c40f5afdd116b847a859b8517522302489
Diffstat (limited to 'includes/diff/ComplexityException.php')
-rw-r--r--includes/diff/ComplexityException.php30
1 files changed, 30 insertions, 0 deletions
diff --git a/includes/diff/ComplexityException.php b/includes/diff/ComplexityException.php
new file mode 100644
index 000000000000..10ca964ac236
--- /dev/null
+++ b/includes/diff/ComplexityException.php
@@ -0,0 +1,30 @@
+<?php
+/**
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup DifferenceEngine
+ */
+
+namespace MediaWiki\Diff;
+
+use Exception;
+
+class ComplexityException extends Exception {
+ public function __construct() {
+ parent::__construct( 'Diff is too complex to generate' );
+ }
+}