Welterkj has uploaded a new change for review.

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

Change subject: Prevent recursive call to Parser::parse (see bug 73073).
......................................................................

Prevent recursive call to Parser::parse (see bug 73073).

Bug: 73073
Change-Id: I376df7cb7e7782bd846f572e7a0c42e48f6e71cd
---
M GraphViz.php
M GraphViz_body.php
M RELEASE-NOTES.md
3 files changed, 62 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GraphViz 
refs/changes/87/174487/1

diff --git a/GraphViz.php b/GraphViz.php
index 4192f75..25ea832 100644
--- a/GraphViz.php
+++ b/GraphViz.php
@@ -33,7 +33,7 @@
 
 if ( !defined( 'MEDIAWIKI' ) ) die();
 
-define( 'GraphViz_VERSION', '1.5.0' );
+define( 'GraphViz_VERSION', '1.5.1' );
 
 /**
  * The GraphViz settings class.
diff --git a/GraphViz_body.php b/GraphViz_body.php
index c051374..2972957 100644
--- a/GraphViz_body.php
+++ b/GraphViz_body.php
@@ -201,6 +201,55 @@
        private static $titlesBeingSaved = array();
 
        /**
+        * A variable for temporarily holding a copy of GLOBALS['wgHooks'].
+        * @var $disabledHooks
+        */
+       private static $disabledHooks = null;
+
+       /**
+        * Disable all hook functions (GLOBALS['wgHooks']).
+        * @author Keith Welter
+        * @return true upon success, false upon failure.
+        */
+       protected static function disableHooks() {
+               if ( isset( $GLOBALS['wgHooks'] ) ) {
+                       if ( isset( self::$disabledHooks ) ) {
+                               wfDebug( __METHOD__ . ": hooks already 
disabled\n" );
+                       } else {
+                               self::$disabledHooks = $GLOBALS['wgHooks'];
+                               $GLOBALS['wgHooks'] = null;
+                               wfDebug( __METHOD__ . ": hooks disabled\n" );
+                               return true;
+                       }
+               } else {
+                       wfDebug( __METHOD__ . ": hooks not set\n" );
+               }
+               return false;
+       }
+
+       /**
+        * Re-enable all hook functions (GLOBALS['wgHooks']).
+        * Must be called after GraphViz::disableHooks.
+        * @author Keith Welter
+        * @return true upon success, false upon failure.
+        */
+       protected static function enableHooks() {
+               if ( isset( self::$disabledHooks ) ) {
+                       if ( isset( $GLOBALS['wgHooks'] ) ) {
+                               wfDebug( __METHOD__ . ": hooks are already set 
- aborting\n" );
+                       } else {
+                               $GLOBALS['wgHooks'] = self::$disabledHooks;
+                               self::$disabledHooks = null;
+                               wfDebug( __METHOD__ . ": hooks enabled\n" );
+                               return true;
+                       }
+               } else {
+                       wfDebug( __METHOD__ . ": hooks not disabled\n" );
+               }
+               return false;
+       }
+
+       /**
         * @return string regular expression for matching an image attribute in 
the DOT language.
         *
         * @see http://www.graphviz.org/content/attrs#dimage
@@ -1131,6 +1180,11 @@
                        $watch = false;
                        $removeTempFile = true;
 
+                       // prevent recusive call to Parser::parse (see bug 
73073).
+                       if ( !self::disableHooks() ) {
+                               return wfMessage( 'graphviz-reload' 
)->escaped();
+                       }
+
                        // Upload the graph image.
                        // We can only do this here when a file page already 
exists for the given image.
                        // Otherwise, file page creation triggers parsing of 
the page text and comment
@@ -1151,6 +1205,10 @@
                                $uploaded = true;
                                touch( $imageFilePath );
                        }
+
+                       if ( !self::enableHooks() ) {
+                               throw new MWException( "failed to re-enable 
hooks" );
+                       }
                }
 
                // If rendering a dummy graph image just return without 
producing HTML.
diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index 91cb0b3..339ee34 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -1,6 +1,9 @@
 These are the release notes for the [MediaWiki][mediawiki] [GraphViz 
extension][gv_ext].
 
 ## GraphViz 1.5.x ## (not released yet)
+* Fix for [bug 73073](https://bugzilla.wikimedia.org/show_bug.cgi?id=72325).
+
+## GraphViz 1.5.0 ## (2014-10-28)
 * Add tag arguments preparse="dynamic" and preparse="static".
 * Add categories for pages created by this extension.
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I376df7cb7e7782bd846f572e7a0c42e48f6e71cd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/GraphViz
Gerrit-Branch: master
Gerrit-Owner: Welterkj <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to