convertExtensionToRegistration.php: die on global functions
authorvictorbarbu <victorbarbu08@gmail.com>
Sat, 9 Jan 2016 19:27:54 +0000 (21:27 +0200)
committerLegoktm <legoktm.wikipedia@gmail.com>
Sat, 9 Jan 2016 21:50:11 +0000 (21:50 +0000)
Bug: T122952
Change-Id: I0fca5457aba3a7237ad7aeb96f3f6636d73863d3

maintenance/convertExtensionToRegistration.php

index 2de2e22..3113533 100644 (file)
@@ -151,6 +151,12 @@ class ConvertExtensionToRegistration extends Maintenance {
                                        "Please move your extension function somewhere else.", 1
                                );
                        }
+                       // check if $func exists in the global scope
+                       if ( function_exists( $func ) ) {
+                               $this->error( "Error: Global functions cannot be converted to JSON. " .
+                                       "Please move your extension function ($func) into a class.", 1
+                               );
+                       }
                }
 
                $this->json[$realName] = $value;
@@ -217,6 +223,12 @@ class ConvertExtensionToRegistration extends Maintenance {
                                                "Please move the handler for $hookName somewhere else.", 1
                                        );
                                }
+                               // Check if $func exists in the global scope
+                               if ( function_exists( $func ) ) {
+                                       $this->error( "Error: Global functions cannot be converted to JSON. " .
+                                               "Please move the handler for $hookName inside a class.", 1
+                                       );
+                               }
                        }
                }
                $this->json[$realName] = $value;