Development

#3711 ([PATCH] Generator fails to find generator.yml a in module)

You must first sign up to be able to contribute.

Ticket #3711 (reopened defect)

Opened 7 months ago

Last modified 2 months ago

[PATCH] Generator fails to find generator.yml a in module

Reported by: suntrix Assigned to: fabien
Priority: major Milestone: 1.0.18
Component: generator Version: 1.0.16
Keywords: Cc:
Qualification: Ready for core team

Description

There is an error in sfGeneratorConfigHandler.class.php. In some cases when we have cleared the cache we get symfony exception that regards to generator.yml file parse. Generator takes the original symfony generator.yml file (/data/symfony/generator/...) instead of the file in our module.

Here is this error stack trace:

( ! ) Notice: Undefined offset: 1 in /home/sowodzin/workspace/dhcp_intruder/lib/symfony/config/sfGeneratorConfigHandler.class.php on line 70 Call Stack # Time Memory Function Location 1 0.0006 60520 {main}( ) ../frontend_dev.php:0 2 0.2586 3171780 sfFrontWebController->dispatch( ) ../frontend_dev.php:10 3 0.2604 3192836 sfController->forward( ) ../sfFrontWebController.class.php:48 4 0.2606 3193208 sfConfigCache->import( ) ../sfController.class.php:194 5 0.2606 3193208 sfConfigCache->checkConfig( ) ../sfConfigCache.class.php:248 6 0.2614 3194216 sfConfigCache->callHandler( ) ../sfConfigCache.class.php:190 7 0.2925 3712552 sfGeneratorConfigHandler->execute( ) ../sfConfigCache.class.php:103

( ! ) Warning: Cannot modify header information - headers already sent by (output started at /home/sowodzin/workspace/dhcp_intruder/lib/symfony/config/sfGeneratorConfigHandler.class.php:70) in /home/sowodzin/workspace/dhcp_intruder/lib/symfony/exception/sfException.class.php on line 101 Call Stack # Time Memory Function Location 1 0.0006 60520 {main}( ) ../frontend_dev.php:0 2 0.2586 3171780 sfFrontWebController->dispatch( ) ../frontend_dev.php:10 3 0.3581 4209932 sfException->printStackTrace( ) ../sfFrontWebController.class.php:57 4 0.3582 4209932 header ( ) ../sfException.class.php:101 [sfParseException] You must specify a "moduleName" stack trace

  • at () in SF_ROOT_DIR/lib/symfony/generator/sfCrudGenerator.class.php line 52 ...
    1. $error = 'You must specify a "%s"';
    2. $error = sprintf($error, $entry); 51.
    3. throw new sfParseException($error);
    4. }
    5. }

55.

  • at sfCrudGenerator->generate(array('model_class' => 'Host', 'theme' => 'default', array('title' => 'Hosts list', array('=host_name', '_host_mac', 'vlan', 'host_ip', 'host_description', 'host_type', 'created_at'), array(array('name' => 'Name'), array('name' => 'Virtual LAN'), array('name' => 'Host type'), array('name' => 'MAC'), array('name' => 'IP'), array('name' => 'Description')), array(array(null), array(null)), array('host_name', 'host_mac', '_vlan', 'host_ip', 'host_description'), 'max_per_page' => '50', array(array(null), array('name' => 'export data', 'action' => 'exportData'))), array('title' => 'Edit host', array('host_name', 'vlan_vlan_id', 'host_type_host_type_id', 'host_mac', 'host_ip4', 'host_description'), array(array('name' => 'Name', 'type' => 'input_tag', 'params' => 'size=50'), array('name' => 'Virtual LAN', 'params' => 'include_custom=Wybierz'), array('name' => 'Host type'), array('name' => 'MAC', 'help' => 'np. c8a1c6d6ff11', 'type' => 'input_tag', 'params' => 'size=12'), array('name' => 'IP4', 'help' => 'przy dodawaniu nowego w polu jest wpisany pierwszy wolny IP', 'type' => 'input_tag', 'params' => 'size=3'), array('name' => 'Description', 'type' => 'input_tag', 'params' => 'size=100')), array(array(null), array(null), array(null), array(null), array(null))), null)) in SF_ROOT_DIR/lib/symfony/generator/sfGeneratorManager.class.php line 55 ...
    1. {
    2. $generator = new $generator_class();
    3. $generator->initialize($this);
    4. $data = $generator->generate($param); 56.
    5. return $data;
    6. }
  • at sfGeneratorManager->generate('sfPropelAdminGenerator', array('model_class' => 'Host', 'theme' => 'default', array('title' => 'Hosts list', array('=host_name', '_host_mac', 'vlan', 'host_ip', 'host_description', 'host_type', 'created_at'), array(array('name' => 'Name'), array('name' => 'Virtual LAN'), array('name' => 'Host type'), array('name' => 'MAC'), array('name' => 'IP'), array('name' => 'Description')), array(array(null), array(null)), array('host_name', 'host_mac', '_vlan', 'host_ip', 'host_description'), 'max_per_page' => '50', array(array(null), array('name' => 'export data', 'action' => 'exportData'))), array('title' => 'Edit host', array('host_name', 'vlan_vlan_id', 'host_type_host_type_id', 'host_mac', 'host_ip4', 'host_description'), array(array('name' => 'Name', 'type' => 'input_tag', 'params' => 'size=50'), array('name' => 'Virtual LAN', 'params' => 'include_custom=Wybierz'), array('name' => 'Host type'), array('name' => 'MAC', 'help' => 'np. c8a1c6d6ff11', 'type' => 'input_tag', 'params' => 'size=12'), array('name' => 'IP4', 'help' => 'przy dodawaniu nowego w polu jest wpisany pierwszy wolny IP', 'type' => 'input_tag', 'params' => 'size=3'), array('name' => 'Description', 'type' => 'input_tag', 'params' => 'size=100')), array(array(null), array(null), array(null), array(null), array(null))), null)) in SF_ROOT_DIR/lib/symfony/config/sfGeneratorConfigHandler.class.php line 72 ...
    1. preg_match('#.*/'.sfConfig::get('sf_app_module_dir_name').'/([/]+)/#', $configFiles[0], $match);
    2. $generatorParammoduleName? = $match[1]; 71.
    3. $data = $generatorManager->generate($configclass?, $generatorParam); 73.
    4. // compile data
    5. $retval = "<?php\n".
  • at sfGeneratorConfigHandler->execute(array('/home/sowodzin/workspace/dhcp_intruder/config/../data/symfony/config/generator.yml', '/home/sowodzin/workspace/dhcp_intruder/apps/frontend/modules/host/config/generator.yml')) in SF_ROOT_DIR/lib/symfony/config/sfConfigCache.class.php line 103 ...
    1. if ($handlerToCall)
    2. {
    3. // call the handler and retrieve the cache data
    4. $data = $handlerToCall->execute($configs); 104.
    5. $this->writeCacheFile($handler, $cache, $data);
    6. }
  • at sfConfigCache->callHandler('modules/host/config/generator.yml', array('/home/sowodzin/workspace/dhcp_intruder/config/../data/symfony/config/generator.yml', '/home/sowodzin/workspace/dhcp_intruder/apps/frontend/modules/host/config/generator.yml'), '/home/sowodzin/workspace/dhcp_intruder/cache/frontend/dev/config/modules_host_config_generator.yml.php') in SF_ROOT_DIR/lib/symfony/config/sfConfigCache.class.php line 190 ...
if (!is_readable($cache) $mtime > filemtime($cache))
  1. {
  2. // configuration has changed so we need to reparse it
  3. $this->callHandler($configPath, $files, $cache); 191.
  4. // clear process cache
  5. if ('config/config_handlers.yml' != $configPath && sfConfig::get('sf_use_process_cache') && !$process_cache_cleared)
  • at sfConfigCache->checkConfig('modules/host/config/generator.yml', '1') in SF_ROOT_DIR/lib/symfony/config/sfConfigCache.class.php line 248 ...
    1. */
    2. public function import($config, $once = true, $optional = false)
    3. {
    4. $cache = $this->checkConfig($config, $optional); 249.
    5. if ($optional && !$cache)
    6. {
  • at sfConfigCache->import('modules/host/config/generator.yml', '1', '1') in SF_ROOT_DIR/lib/symfony/controller/sfController.class.php line 194 ...
    1. } 192.
    2. // check for a module generator config file
    3. sfConfigCache::getInstance()->import(sfConfig::get('sf_app_module_dir_name').'/'.$moduleName.'/'.sfConfig::get('sf_app_module_config_dir_name').'/generator.yml', true, true); 195.
    4. if (!$this->actionExists($moduleName, $actionName))
    5. {
  • at sfController->forward('host', 'list') in SF_ROOT_DIR/lib/symfony/controller/sfFrontWebController.class.php line 48 ...
    1. $actionName = $request->getParameter('action'); 46.
    2. // make the first request
    3. $this->forward($moduleName, $actionName);
    4. }
    5. catch (sfException $e)
    6. {
  • at sfFrontWebController->dispatch() in SF_ROOT_DIR/web/frontend_dev.php line 10 ...

7.

  1. require_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php'); 9.
  1. sfContext::getInstance()->getController()->dispatch();

11.

symfony settings ...

--- sf_admin_web_dir: /sf/sf_admin sf_app: frontend sf_app_config_dir: /home/sowodzin/workspace/dhcp_intruder/apps/frontend/config sf_app_config_dir_name: config sf_app_dir: /home/sowodzin/workspace/dhcp_intruder/apps/frontend sf_app_i18n_dir: /home/sowodzin/workspace/dhcp_intruder/apps/frontend/i18n sf_app_i18n_dir_name: i18n sf_app_lib_dir: /home/sowodzin/workspace/dhcp_intruder/apps/frontend/lib sf_app_lib_dir_name: lib sf_app_module_action_dir_name: actions sf_app_module_config_dir_name: config sf_app_module_dir: /home/sowodzin/workspace/dhcp_intruder/apps/frontend/modules sf_app_module_dir_name: modules sf_app_module_i18n_dir_name: i18n sf_app_module_lib_dir_name: lib sf_app_module_template_dir_name: templates sf_app_module_validate_dir_name: validate sf_app_module_view_dir_name: views sf_app_template_dir: /home/sowodzin/workspace/dhcp_intruder/apps/frontend/templates sf_app_template_dir_name: templates sf_apps_dir_name: apps sf_autoloading_functions: sf_available: 1 sf_base_cache_dir: /home/sowodzin/workspace/dhcp_intruder/cache/frontend sf_bin_dir: /home/sowodzin/workspace/dhcp_intruder/batch sf_bin_dir_name: batch sf_cache: sf_cache_dir: /home/sowodzin/workspace/dhcp_intruder/cache/frontend/dev sf_cache_dir_name: cache sf_calendar_web_dir: /sf/calendar sf_charset: utf-8 sf_check_lock: sf_check_symfony_version: sf_compressed: sf_config_cache_dir: /home/sowodzin/workspace/dhcp_intruder/cache/frontend/dev/config sf_config_dir: /home/sowodzin/workspace/dhcp_intruder/config sf_config_dir_name: config sf_data_dir: /home/sowodzin/workspace/dhcp_intruder/data sf_data_dir_name: data sf_debug: 1 sf_default_action: index sf_default_module: default sf_doc_dir: /home/sowodzin/workspace/dhcp_intruder/data/doc sf_doc_dir_name: doc sf_enabled_modules:

  • default
  • sfGuardGroup
  • sfGuardUser
  • sfGuardPermission
  • sfGuardAuth

sf_environment: dev sf_error_404_action: error404 sf_error_404_module: default sf_error_reporting: 4095 sf_escaping_method: ESC_ENTITIES sf_escaping_strategy: bc sf_etag: sf_i18n: 1 sf_i18n_cache: 1 sf_i18n_cache_dir: /home/sowodzin/workspace/dhcp_intruder/cache/frontend/dev/i18n sf_i18n_debug: sf_i18n_default_culture: en_GB sf_i18n_source: XLIFF sf_i18n_untranslated_prefix: [T] sf_i18n_untranslated_suffix: /T sf_lib_dir: /home/sowodzin/workspace/dhcp_intruder/lib sf_lib_dir_name: lib sf_log_dir: /home/sowodzin/workspace/dhcp_intruder/log sf_log_dir_name: log sf_logging_enabled: 1 sf_logging_history: 10 sf_logging_level: debug sf_logging_period: 7 sf_logging_purge: 1 sf_logging_rotate: sf_login_action: signin sf_login_module: sfGuardAuth sf_max_forwards: 5 sf_model_dir_name: model sf_model_lib_dir: /home/sowodzin/workspace/dhcp_intruder/lib/model sf_module_cache_dir: /home/sowodzin/workspace/dhcp_intruder/cache/frontend/dev/modules sf_module_disabled_action: disabled sf_module_disabled_module: default sf_no_script_name: sf_orm: propel sf_path_info_array: SERVER sf_path_info_key: PATH_INFO sf_plugins_dir: /home/sowodzin/workspace/dhcp_intruder/plugins sf_plugins_dir_name: plugins sf_prototype_web_dir: /sf/prototype sf_rich_text_js_dir: js/tiny_mce sf_root_cache_dir: /home/sowodzin/workspace/dhcp_intruder/cache sf_root_dir: /home/sowodzin/workspace/dhcp_intruder sf_routing_defaults:

sf_culture: en_GB

sf_secure_action: secure sf_secure_module: sfGuardAuth sf_standard_helpers:

  • Partial
  • Cache
  • Form

sf_strip_comments: 1 sf_suffix: . sf_symfony_data_dir: /home/sowodzin/workspace/dhcp_intruder/config/../data/symfony sf_symfony_lib_dir: /home/sowodzin/workspace/dhcp_intruder/config/../lib/symfony sf_template_cache_dir: /home/sowodzin/workspace/dhcp_intruder/cache/frontend/dev/template sf_test: sf_test_cache_dir: /home/sowodzin/workspace/dhcp_intruder/cache/frontend/dev/test sf_test_dir: /home/sowodzin/workspace/dhcp_intruder/test sf_test_dir_name: test sf_timeout: 1800 sf_timer_start: 1213022411.46 sf_unavailable_action: unavailable sf_unavailable_module: default sf_upload_dir: /home/sowodzin/workspace/dhcp_intruder/web/uploads sf_upload_dir_name: uploads sf_url_format: PATH sf_use_database: 1 sf_use_flash: 1 sf_use_process_cache: 1 sf_use_security: 1 sf_validation_error_class: form_error sf_validation_error_id_prefix: error_for_ sf_validation_error_prefix: ↓ sf_validation_error_suffix: ↓ sf_web_debug: 1 sf_web_debug_web_dir: /sf/sf_web_debug sf_web_dir: /home/sowodzin/workspace/dhcp_intruder/web sf_web_dir_name: web

request ...

--- parameterHolder:

symfony/default:

action: list module: host

attributeHolder:

symfony/default:

response ...

--- cookies: httpHeaders: parameterHolder:

global vars ...

--- cookie:

KTRADMIN: e3292c32eebf74067d8bb2ea68f36799 KTRSESSION: a6dafb5829fa5799ce63314d4fcd9c68 MANTIS_PROJECT_COOKIE: 18 MANTIS_VIEW_ALL_COOKIE: 170 ktr_admin_left_menu: 1 symfony: ff9c67b3a5010e50eaad9b78eee82c94

env:

APACHE_PID_FILE: /var/run/apache2.pid APACHE_RUN_GROUP: www-data APACHE_RUN_USER: www-data LANG: C PATH: /usr/local/bin:/usr/bin:/bin PWD: /home/sowodzin/workspace/dhcp_intruder

files: get: post: server:

DOCUMENT_ROOT: /var/www/ GATEWAY_INTERFACE: CGI/1.1 HTTP_ACCEPT: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 HTTP_ACCEPT_CHARSET: ISO-8859-2,utf-8;q=0.7,*;q=0.7 HTTP_ACCEPT_ENCODING: gzip,deflate HTTP_ACCEPT_LANGUAGE: pl,en-us;q=0.7,en;q=0.3 HTTP_CONNECTION: keep-alive HTTP_COOKIE: MANTIS_PROJECT_COOKIE=18; MANTIS_VIEW_ALL_COOKIE=170; ktr_admin_left_menu=1; symfony=ff9c67b3a5010e50eaad9b78eee82c94; KTRADMIN=e3292c32eebf74067d8bb2ea68f36799; KTRSESSION=a6dafb5829fa5799ce63314d4fcd9c68 HTTP_HOST: localhost HTTP_KEEP_ALIVE: 300 HTTP_USER_AGENT: Mozilla/5.0 (X11; U; Linux i686; pl-PL; rv:1.9b5) Gecko/2008050509 Firefox/3.0b5 PATH: /usr/local/bin:/usr/bin:/bin PHP_SELF: /~sowodzin/dhcp_intruder/web/frontend_dev.php QUERY_STRING: REMOTE_ADDR: 127.0.0.1 REMOTE_PORT: 50576 REQUEST_METHOD: GET REQUEST_TIME: 1213022411 REQUEST_URI: /~sowodzin/dhcp_intruder/web/frontend_dev.php SCRIPT_FILENAME: /home/sowodzin/workspace/dhcp_intruder/web/frontend_dev.php SCRIPT_NAME: /~sowodzin/dhcp_intruder/web/frontend_dev.php SERVER_ADDR: 127.0.0.1 SERVER_ADMIN: webmaster@localhost SERVER_NAME: localhost SERVER_PORT: 80 SERVER_PROTOCOL: HTTP/1.1 SERVER_SIGNATURE: |

Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.1 with Suhosin-Patch mod_ssl/2.2.8 OpenSSL/0.9.8g Server at localhost Port 80

SERVER_SOFTWARE: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.1 with Suhosin-Patch mod_ssl/2.2.8 OpenSSL/0.9.8g argc: 0 argv:

session:

symfony/user/sfUser/attributes: symfony/user/sfUser/authenticated: symfony/user/sfUser/credentials: symfony/user/sfUser/culture: en_GB symfony/user/sfUser/lastRequest: 1213022410

symfony v.1.0.16 - php 5.2.4-2ubuntu5.1 for help resolving this issue, please visit http://www.symfony-project.org/.

Attachments

patch.txt (1.4 kB) - added by suntrix on 06/09/08 17:02:43.
Proposition of the patch to the bug
sfParseException.txt (7.4 kB) - added by suntrix on 11/14/08 12:36:58.

Change History

06/09/08 17:02:43 changed by suntrix

  • attachment patch.txt added.

Proposition of the patch to the bug

06/09/08 17:06:12 changed by suntrix

This bug is in symfony 1.0.16 and in 1.1.0.

06/17/08 19:43:06 changed by dwhittle

  • milestone set to 1.1.0.

06/23/08 04:39:28 changed by dwhittle

  • qualification changed from Unreviewed to Ready for core team.
  • milestone changed from 1.1.0 to 1.0.17.

This is fixed in my branch (r9761), and should be applied to 1.0 + 1.1.

06/28/08 09:57:56 changed by fabien

I don't understand the patch. If the regex does not match, then the $generatorParammoduleName? is empty which is not possible. We need to find the module name.

06/28/08 11:37:05 changed by suntrix

Regex isn't the problem. In some cases the array $configFiles is reversed ($configFiles[1] contains the data for $configFiles[0] and $configFiles[0] for $configFiles[1]). I see there is a mistake in my patch, in original code there is:

preg_match('#.*/'.sfConfig::get('sf_app_module_dir_name').'/([^/]+)/#', $configFiles[0], $match);

and in my patch it's

preg_match('#.*/'.sfConfig::get('sf_app_module_dir_name').'/([^/]+)/#', $configFiles[1], $match);

I'm very sorry for that. Of course this code

preg_match('#.*/'.sfConfig::get('sf_app_module_dir_name').'/([^/]+)/#', $configFiles[1], $match);

works every time. The rest code are only precautions if the regex wouldn't match.

06/29/08 16:49:45 changed by gregoire

  • milestone changed from 1.0.17 to 1.0.18.

09/12/08 17:06:53 changed by gregoire

  • status changed from new to closed.
  • resolution set to fixed.

(In [11481]) Applied Dustin's changes from r9761 (closes #3711)

11/14/08 12:36:21 changed by suntrix

  • status changed from closed to reopened.
  • resolution deleted.

Unfortunately this error still occurs in 1.0.18. I found that only one char needs to be changed and this code will work properly.

In line 69 in file /lib/symfony/config/sfGeneratorConfigHandler.class.php

preg_match('#.*/'.sfConfig::get('sf_app_module_dir_name').'/([^/]+)/#', $configFiles[0], $match);

and it must be

preg_match('#.*/'.sfConfig::get('sf_app_module_dir_name').'/([^/]+)/#', $configFiles[1], $match);

11/14/08 12:36:58 changed by suntrix

  • attachment sfParseException.txt added.

11/14/08 12:38:14 changed by suntrix

The file sfParseException.txt contains stack trace of this error in symfony 1.0.18.