]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #4378 prevent loading same library name twice
authorcash <cash.costello@gmail.com>
Sat, 30 Mar 2013 16:50:30 +0000 (12:50 -0400)
committercash <cash.costello@gmail.com>
Sat, 30 Mar 2013 16:50:30 +0000 (12:50 -0400)
engine/lib/elgglib.php

index a49b620ac56a8abd74058fb70763e13c3130adcd..fb652a14168f48af42af1d821a9462ec0171d97a 100644 (file)
@@ -93,10 +93,17 @@ function elgg_register_library($name, $location) {
  * @return void
  * @throws InvalidParameterException
  * @since 1.8.0
+ * @todo return boolean in 1.9 to indicate whether the library has been loaded
  */
 function elgg_load_library($name) {
        global $CONFIG;
 
+       static $loaded_libraries = array();
+
+       if (in_array($name, $loaded_libraries)) {
+               return;
+       }
+
        if (!isset($CONFIG->libraries)) {
                $CONFIG->libraries = array();
        }
@@ -113,6 +120,8 @@ function elgg_load_library($name) {
                );
                throw new InvalidParameterException($error);
        }
+
+       $loaded_libraries[] = $name;
 }
 
 /**