Uploaded image for project: 'phpBB3'
  1. phpBB3
  2. PHPBB3-11465

Use extension finder for including module info file in the ACP

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Blocker
    • Resolution: Fixed
    • 3.1.0-dev
    • None
    • ACP, Extensions
    • None

    Description

      When moving to the new extension finder interface the get_module_info() function was changed, too:

      	/**
      	* Get available module information from module files
      	*
      	* @param string $module
      	* @param bool|string $module_class
      	* @param bool $use_all_available Use all available instead of just all
      	* 						enabled extensions
      	* @return array
      	*/
      	function get_module_infos($module = '', $module_class = false, $use_all_available = false)
      	{
      		global $phpbb_root_path, $phpEx;
       
      		$module_class = ($module_class === false) ? $this->module_class : $module_class;
       
      		$directory = $phpbb_root_path . 'includes/' . $module_class . '/info/';
      		$fileinfo = array();
       
      		if (!$module)
      		{
      			global $phpbb_extension_manager;
       
      			$finder = $phpbb_extension_manager->get_finder();
       
      			$modules = $finder
      				->extension_suffix('_module')
      				->extension_directory("/$module_class")
      				->core_path("includes/$module_class/info/")
      				->core_prefix($module_class . '_')
      				->get_classes(true, $use_all_available);
       
      			foreach ($modules as $module)
      			{
      				$info_class = preg_replace('/_module$/', '_info', $module);
       
      				// If the class does not exist it might be following the old
      				// format. phpbb_acp_info_acp_foo needs to be turned into
      				// acp_foo_info and the respective file has to be included
      				// manually because it does not support auto loading
      				if (!class_exists($info_class))
      				{
      					$info_class = str_replace("phpbb_{$module_class}_info_", '', $module) . '_info';
      					if (file_exists($directory . $info_class . '.' . $phpEx))
      					{
      						include($directory . $info_class . '.' . $phpEx);
      					}
      				}
       
      				if (class_exists($info_class))
      				{
      					$info = new $info_class();
      					$module_info = $info->module();
       
      					$main_class = (isset($module_info['filename'])) ? $module_info['filename'] : $module;
       
      					$fileinfo[$main_class] = $module_info;
      				}
      			}
       
      			ksort($fileinfo);
      		}
      		else
      		{
      			$info_class = preg_replace('/_module$/', '_info', $module);
       
      			if (!class_exists($info_class))
      			{
      				if (file_exists($directory . $module . '.' . $phpEx))
      				{
      					include($directory . $module . '.' . $phpEx);
      				}
      				$info_class = $module . '_info';
      			}
       
      			// Get module title tag
      			if (class_exists($info_class))
      			{
      				$info = new $info_class();
      				$module_info = $info->module();
       
      				$main_class = (isset($module_info['filename'])) ? $module_info['filename'] : $module;
       
      				$fileinfo[$main_class] = $module_info;
      			}
      		}
       
      		return $fileinfo;
      	}

      While adding a new module in the ACP (via "Create new module") the $module string is not defined. In that case the finder properly finds the module's info file. However, once the user tries to add the module the $module string is defined and the get_modules_info() method is only looking inside the includes/acp/info/ folder according to the old system.

      This part of the function should also be changed in order to properly find the extensions' acp module info files and in order to be able to actually add those modules via the ACP.

      Attachments

        Activity

          People

            EXreaction EXreaction [X] (Inactive)
            Marc Marc
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: