Yurik has uploaded a new change for review.

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

Change subject: (WAIT) Compress graph_specs page property
......................................................................

(WAIT) Compress graph_specs page property

Do not merge until after graphoid starts using new api action=graph

Large or multiple graphs on the same page sometimes do
not fit in the 64KB database blob limit. Even though this does not
fully solve it, it reduces problem's severity until
we have a proper storage.

Change-Id: I375d9b9512cc946090be8097bd7d829e6f99cada
---
M ApiGraph.php
M Graph.body.php
2 files changed, 7 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Graph 
refs/changes/14/255914/1

diff --git a/ApiGraph.php b/ApiGraph.php
index 1e8ef3a..4cf4cd3 100644
--- a/ApiGraph.php
+++ b/ApiGraph.php
@@ -36,6 +36,11 @@
 
                $graph = false;
                if ( $ppValue ) {
+                       // Copied from TemplateDataBlob.php:newFromDatabase()
+                       // Handle GZIP compression. \037\213 is the header for 
GZIP files.
+                       if ( substr( $ppValue, 0, 2 ) === "\037\213" ) {
+                               $ppValue = gzdecode( $ppValue );
+                       }
                        $st = FormatJson::parse( $ppValue );
                        if ( $st->isOK() ) {
                                $allGraphs = $st->getValue();
diff --git a/Graph.body.php b/Graph.body.php
index f5cd3e0..9008434 100644
--- a/Graph.body.php
+++ b/Graph.body.php
@@ -81,8 +81,8 @@
                                $output->addJsConfigVars( 
'wgGraphUrlBlacklist', $wgGraphUrlBlacklist );
                                $output->addJsConfigVars( 'wgGraphIsTrusted', 
$wgGraphIsTrusted );
                        }
-                       $output->setProperty( 'graph_specs',
-                               FormatJson::encode( $specs, false, 
FormatJson::ALL_OK ) );
+                       $ppValue = gzencode( FormatJson::encode( $specs, false, 
FormatJson::ALL_OK ), 9 );
+                       $output->setProperty( 'graph_specs', $ppValue );
                        $output->addTrackingCategory( 
'graph-tracking-category', $title );
                }
        }

-- 
To view, visit https://gerrit.wikimedia.org/r/255914
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I375d9b9512cc946090be8097bd7d829e6f99cada
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Graph
Gerrit-Branch: master
Gerrit-Owner: Yurik <yu...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to