/**
  * @covers ExtensionProcessor::extractResourceLoaderModules
  * @dataProvider provideExtractResourceLoaderModules
  */
 public function testExtractResourceLoaderModules($input, $expected)
 {
     $processor = new ExtensionProcessor();
     $processor->extractInfo($this->dir, $input + self::$default);
     $out = $processor->getExtractedInfo();
     foreach ($expected as $key => $value) {
         $this->assertEquals($value, $out['globals'][$key]);
     }
 }
예제 #2
0
 /**
  * Process a queue of extensions and return their extracted data
  *
  * @param array $queue keys are filenames, values are ignored
  * @return array extracted info
  * @throws Exception
  */
 public function readFromQueue(array $queue)
 {
     $autoloadClasses = array();
     $processor = new ExtensionProcessor();
     foreach ($queue as $path => $mtime) {
         $json = file_get_contents($path);
         if ($json === false) {
             throw new Exception("Unable to read {$path}, does it exist?");
         }
         $info = json_decode($json, true);
         if (!is_array($info)) {
             throw new Exception("{$path} is not a valid JSON file.");
         }
         if (!isset($info['manifest_version'])) {
             // For backwards-compatability, assume a version of 1
             $info['manifest_version'] = 1;
         }
         $version = $info['manifest_version'];
         if ($version < self::OLDEST_MANIFEST_VERSION || $version > self::MANIFEST_VERSION) {
             throw new Exception("{$path}: unsupported manifest_version: {$version}");
         }
         $autoload = $this->processAutoLoader(dirname($path), $info);
         // Set up the autoloader now so custom processors will work
         $GLOBALS['wgAutoloadClasses'] += $autoload;
         $autoloadClasses += $autoload;
         $processor->extractInfo($path, $info, $version);
     }
     $data = $processor->getExtractedInfo();
     // Need to set this so we can += to it later
     $data['globals']['wgAutoloadClasses'] = array();
     foreach ($data['credits'] as $credit) {
         $data['globals']['wgExtensionCredits'][$credit['type']][] = $credit;
     }
     $data['autoload'] = $autoloadClasses;
     return $data;
 }
예제 #3
0
 /**
  * Process a queue of extensions and return their extracted data
  *
  * @param array $queue keys are filenames, values are ignored
  * @return array extracted info
  * @throws Exception
  */
 public function readFromQueue(array $queue)
 {
     global $wgVersion;
     $autoloadClasses = array();
     $processor = new ExtensionProcessor();
     $incompatible = array();
     $coreVersionParser = new CoreVersionChecker($wgVersion);
     foreach ($queue as $path => $mtime) {
         $json = file_get_contents($path);
         if ($json === false) {
             throw new Exception("Unable to read {$path}, does it exist?");
         }
         $info = json_decode($json, true);
         if (!is_array($info)) {
             throw new Exception("{$path} is not a valid JSON file.");
         }
         if (!isset($info['manifest_version'])) {
             // For backwards-compatability, assume a version of 1
             $info['manifest_version'] = 1;
         }
         $version = $info['manifest_version'];
         if ($version < self::OLDEST_MANIFEST_VERSION || $version > self::MANIFEST_VERSION) {
             throw new Exception("{$path}: unsupported manifest_version: {$version}");
         }
         $autoload = $this->processAutoLoader(dirname($path), $info);
         // Set up the autoloader now so custom processors will work
         $GLOBALS['wgAutoloadClasses'] += $autoload;
         $autoloadClasses += $autoload;
         // Check any constraints against MediaWiki core
         $requires = $processor->getRequirements($info);
         if (isset($requires[self::MEDIAWIKI_CORE]) && !$coreVersionParser->check($requires[self::MEDIAWIKI_CORE])) {
             // Doesn't match, mark it as incompatible.
             $incompatible[] = "{$info['name']} is not compatible with the current " . "MediaWiki core (version {$wgVersion}), it requires: " . $requires[self::MEDIAWIKI_CORE] . '.';
             continue;
         }
         // Compatible, read and extract info
         $processor->extractInfo($path, $info, $version);
     }
     if ($incompatible) {
         if (count($incompatible) === 1) {
             throw new Exception($incompatible[0]);
         } else {
             throw new Exception(implode("\n", $incompatible));
         }
     }
     $data = $processor->getExtractedInfo();
     // Need to set this so we can += to it later
     $data['globals']['wgAutoloadClasses'] = array();
     foreach ($data['credits'] as $credit) {
         $data['globals']['wgExtensionCredits'][$credit['type']][] = $credit;
     }
     $data['globals']['wgExtensionCredits'][self::MERGE_STRATEGY] = 'array_merge_recursive';
     $data['autoload'] = $autoloadClasses;
     return $data;
 }
예제 #4
0
 /**
  * Process a queue of extensions and return their extracted data
  *
  * @param array $queue keys are filenames, values are ignored
  * @return array extracted info
  * @throws Exception
  */
 public function readFromQueue(array $queue)
 {
     $data = array('globals' => array('wgAutoloadClasses' => array()));
     $autoloadClasses = array();
     $processor = new ExtensionProcessor();
     foreach ($queue as $path => $mtime) {
         $json = file_get_contents($path);
         $info = json_decode($json, true);
         if (!is_array($info)) {
             throw new Exception("{$path} is not a valid JSON file.");
         }
         $autoload = $this->processAutoLoader(dirname($path), $info);
         // Set up the autoloader now so custom processors will work
         $GLOBALS['wgAutoloadClasses'] += $autoload;
         $autoloadClasses += $autoload;
         $processor->extractInfo($path, $info);
     }
     $data = $processor->getExtractedInfo();
     // Need to set this so we can += to it later
     $data['globals']['wgAutoloadClasses'] = array();
     foreach ($data['credits'] as $credit) {
         $data['globals']['wgExtensionCredits'][$credit['type']][] = $credit;
     }
     $data['globals']['wgExtensionCredits'][self::MERGE_STRATEGY] = 'array_merge_recursive';
     $data['autoload'] = $autoloadClasses;
     return $data;
 }