This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » support » General discussion » newbie-correct intersal server error
newbie-correct intersal server error [message #97218] Tue, 13 April 2010 02:08 Go to next message
naeluh  is currently offline naeluh
Messages: 9
Registered: April 2010
Junior Member
Hello,

I am writing to try to:

A. Become more informed with the symfony framework

B. Also I wanted to correct the following problem:
There is an image that gives a picture of the error I receive.
I am working the backend of the site, trying to delete blog account profiles from the site so that do not show up anymore because they are no longer employed by the magazine anymore. When I delete the profile the application returns the following error is returned. Which is pasted below.
Let me know if there are any questions.

thanks


500 | Internal Server Error | Doctrine_Connection_Mysql_Exception
SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`flaunt_prod/blog_post`, CONSTRAINT `blog_post_ibfk_3` FOREIGN KEY (`blog_id`) REFERENCES `blog` (`id`))
stack trace

* at ()
in SF_ROOT_DIR/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/ lib/vendor/doctrine/Doctrine/Connection.php line 1086 ...
1083.
1084. $name = 'Doctrine_Connection_' . $this->driverName . '_Exception';
1085.
1086. $exc = new $name($e->getMessage(), (int) $e->getCode());
1087. if ( ! isset($e->errorInfo) || ! is_array($e->errorInfo)) {
1088. $e->errorInfo = array(null, null, null, null);
1089. }
* at Doctrine_Connection->rethrowException(object('PDOException'), object('Doctrine_Connection_Statement'))
in SF_ROOT_DIR/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/ lib/vendor/doctrine/Doctrine/Connection/Statement.php line 253 ...
250. } catch (Doctrine_Adapter_Exception $e) {
251. }
252.
253. $this->_conn->rethrowException($e, $this);
254.
255. return false;
256. }
* at Doctrine_Connection_Statement->execute(array('5'))
in SF_ROOT_DIR/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/ lib/vendor/doctrine/Doctrine/Connection.php line 1051 ...
1048. try {
1049. if ( ! empty($params)) {
1050. $stmt = $this->prepare($query);
1051. $stmt->execute($params);
1052.
1053. return $stmt->rowCount();
1054. } else {
* at Doctrine_Connection->exec('DELETE FROM blog WHERE id = ?', array('5'))
in SF_ROOT_DIR/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/ lib/vendor/doctrine/Doctrine/Connection/UnitOfWork.php line 267 ...
264. $this->conn->exec($sql, $params);
265. } else {
266. $sql .= $this->_buildSqlSingleKeyCondition($columnNames, count($params));
267. $this->conn->exec($sql, $params);
268. }
269.
270. // adjust state, remove from identity map and inform postDelete listeners
* at Doctrine_Connection_UnitOfWork->_executeDeletions(array(object('Blog')))
in SF_ROOT_DIR/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/ lib/vendor/doctrine/Doctrine/Connection/UnitOfWork.php line 184 ...
181. {
182. $deletions = array();
183. $this->_collectDeletions($record, $deletions);
184. return $this->_executeDeletions($deletions);
185. }
186.
187. /**
* at Doctrine_Connection_UnitOfWork->delete(object('Blog'))
in SF_ROOT_DIR/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/ lib/vendor/doctrine/Doctrine/Record.php line 1752 ...
1749. if ($conn == null) {
1750. $conn = $this->_table->getConnection();
1751. }
1752. return $conn->unitOfWork->delete($this);
1753. }
1754.
1755. /**
* at Doctrine_Record->delete()
in SF_ROOT_DIR/cache/backend/prod/modules/autoBlog/actions/acti ons.class.php line 113 ...
110.
111. $this->dispatcher->notify(new sfEvent($this, 'admin.delete_object', array('object' => $this->getRoute()->getObject())));
112.
113. $this->getRoute()->getObject()->delete();
114.
115. $this->getUser()->setFlash('notice', 'The item was deleted successfully.');
116.
* at autoBlogActions->executeDelete(object('sfWebRequest'))
in SF_ROOT_DIR/lib/vendor/symfony/lib/action/sfActions.class.ph p line 53 ...
50. }
51.
52. // run action
53. return $this->$actionToRun($request);
54. }
55. }
56.
* at sfActions->execute(object('sfWebRequest'))
in SF_ROOT_DIR/lib/vendor/symfony/lib/filter/sfExecutionFilter. class.php line 90 ...
87. {
88. // execute the action
89. $actionInstance->preExecute();
90. $viewName = $actionInstance->execute($this->context->getRequest());
91. $actionInstance->postExecute();
92.
93. return is_null($viewName) ? sfView::SUCCESS : $viewName;
* at sfExecutionFilter->executeAction(object('blogActions'))
in SF_ROOT_DIR/lib/vendor/symfony/lib/filter/sfExecutionFilter. class.php line 76 ...
73. return sfView::SUCCESS;
74. }
75.
76. return $this->executeAction($actionInstance);
77. }
78.
79. /**
* at sfExecutionFilter->handleAction(object('sfFilterChain'), object('blogActions'))
in SF_ROOT_DIR/lib/vendor/symfony/lib/filter/sfExecutionFilter. class.php line 42 ...
39. {
40. $timer = sfTimerManager::getTimer(sprintf('Action "%s/%s"', $actionInstance->getModuleName(), $actionInstance->getActionName()));
41.
42. $viewName = $this->handleAction($filterChain, $actionInstance);
43.
44. $timer->addTime();
45. $timer = sfTimerManager::getTimer(sprintf('View "%s" for "%s/%s"', $viewName, $actionInstance->getModuleName(), $actionInstance->getActionName()));
* at sfExecutionFilter->execute(object('sfFilterChain'))
in SF_ROOT_DIR/lib/vendor/symfony/lib/filter/sfFilterChain.clas s.php line 53 ...
50. }
51.
52. // execute the next filter
53. $this->chain[$this->index]->execute($this);
54. }
55. }
56.
* at sfFilterChain->execute()
in SF_ROOT_DIR/lib/vendor/symfony/lib/filter/sfCommonFilter.cla ss.php line 29 ...
26. public function execute($filterChain)
27. {
28. // execute next filter
29. $filterChain->execute();
30.
31. // execute this filter only once
32. $response = $this->context->getResponse();
* at sfCommonFilter->execute(object('sfFilterChain'))
in SF_ROOT_DIR/lib/vendor/symfony/lib/filter/sfFilterChain.clas s.php line 53 ...
50. }
51.
52. // execute the next filter
53. $this->chain[$this->index]->execute($this);
54. }
55. }
56.
* at sfFilterChain->execute()
in SF_ROOT_DIR/lib/vendor/symfony/lib/filter/sfBasicSecurityFil ter.class.php line 62 ...
59. }
60.
61. // the user has access, continue
62. $filterChain->execute();
63. }
64.
65. /**
* at sfBasicSecurityFilter->execute(object('sfFilterChain'))
in SF_ROOT_DIR/plugins/sfDoctrineGuardPlugin/lib/sfGuardBasicSe curityFilter.class.php line 50 ...
47. }
48. }
49.
50. parent::execute($filterChain);
51. }
52. }
* at sfGuardBasicSecurityFilter->execute(object('sfFilterChain'))
in SF_ROOT_DIR/lib/vendor/symfony/lib/filter/sfFilterChain.clas s.php line 53 ...
50. }
51.
52. // execute the next filter
53. $this->chain[$this->index]->execute($this);
54. }
55. }
56.
* at sfFilterChain->execute()
in SF_ROOT_DIR/lib/vendor/symfony/lib/filter/sfRenderingFilter. class.php line 33 ...
30. public function execute($filterChain)
31. {
32. // execute next filter
33. $filterChain->execute();
34.
35. // get response object
36. $response = $this->context->getResponse();
* at sfRenderingFilter->execute(object('sfFilterChain'))
in SF_ROOT_DIR/lib/vendor/symfony/lib/filter/sfFilterChain.clas s.php line 53 ...
50. }
51.
52. // execute the next filter
53. $this->chain[$this->index]->execute($this);
54. }
55. }
56.
* at sfFilterChain->execute()
in SF_ROOT_DIR/lib/vendor/symfony/lib/controller/sfController.c lass.php line 245 ...
242. }
243.
244. // process the filter chain
245. $filterChain->execute();
246. }
247. else
248. {
* at sfController->forward('blog', 'delete')
in SF_ROOT_DIR/lib/vendor/symfony/lib/controller/sfFrontWebCont roller.class.php line 48 ...
45. }
46.
47. // make the first request
48. $this->forward($moduleName, $actionName);
49. }
50. catch (sfException $e)
51. {
* at sfFrontWebController->dispatch()
in SF_ROOT_DIR/lib/vendor/symfony/lib/util/sfContext.class.php line 159 ...
156. */
157. public function dispatch()
158. {
159. $this->getController()->dispatch();
160. }
161.
162. /**
* at sfContext->dispatch()
in SF_ROOT_DIR/web/backend.php line 6 ...
3. require_once(dirname(__FILE__).'/../config/ProjectConfigurat ion.class.php');
4.
5. $configuration = ProjectConfiguration::getApplicationConfiguration('backend', 'prod', true);
6. sfContext::createInstance($configuration)->dispatch();
7.

symfony settings ...

app_sdAssets_pdf2swf: pdf2swf
app_sf_combine_filter_plugin_cache_dir: /mnt/data-store/sites/flaunt.com/prod/cache/combined
app_sf_combine_filter_plugin_css_filtered_paths:
- /mnt/data-store/sites/flaunt.com/prod
- plugins/
- web/
app_sf_combine_filter_plugin_js_exclude_files:
- tiny_mce
app_sf_guard_plugin_algorithm_callable: sha1
mod_blog_enabled: true
mod_blog_is_internal: false
mod_blog_view_class: sfPHP
sf_admin_module_web_dir: /sfDoctrinePlugin
sf_admin_web_dir: /sf/sf_admin
sf_app: backend
sf_app_base_cache_dir: /mnt/data-store/sites/flaunt.com/prod/cache/backend
sf_app_cache_dir: /mnt/data-store/sites/flaunt.com/prod/cache/backend/prod
sf_app_config_dir: /mnt/data-store/sites/flaunt.com/prod/apps/backend/config
sf_app_dir: /mnt/data-store/sites/flaunt.com/prod/apps/backend
sf_app_i18n_dir: /mnt/data-store/sites/flaunt.com/prod/apps/backend/i18n
sf_app_lib_dir: /mnt/data-store/sites/flaunt.com/prod/apps/backend/lib
sf_app_module_dir: /mnt/data-store/sites/flaunt.com/prod/apps/backend/modules
sf_app_template_dir: /mnt/data-store/sites/flaunt.com/prod/apps/backend/templates
sf_apps_dir: /mnt/data-store/sites/flaunt.com/prod/apps
sf_cache: false
sf_cache_dir: /mnt/data-store/sites/flaunt.com/prod/cache
sf_calendar_web_dir: /sf/calendar
sf_charset: utf-8
sf_check_lock: false
sf_check_symfony_version: false
sf_compressed: false
sf_config_cache_dir: /mnt/data-store/sites/flaunt.com/prod/cache/backend/prod/con fig
sf_config_dir: /mnt/data-store/sites/flaunt.com/prod/config
sf_csrf_secret: false
sf_data_dir: /mnt/data-store/sites/flaunt.com/prod/data
sf_debug: true
sf_default_culture: en
sf_doc_dir: /mnt/data-store/sites/flaunt.com/prod/doc
sf_enabled_modules:
- default
- sfGuardAuth
- sfGuardUser
- sfGuardGroup
- sfGuardPermission
- sdAssets
sf_environment: prod
sf_error_404_action: error404
sf_error_404_module: default
sf_error_reporting: 341
sf_escaping_method: ESC_SPECIALCHARS
sf_escaping_strategy: false
sf_etag: true
sf_i18n: false
sf_i18n_cache_dir: /mnt/data-store/sites/flaunt.com/prod/cache/backend/prod/i18 n
sf_lib_dir: /mnt/data-store/sites/flaunt.com/prod/lib
sf_log_dir: /mnt/data-store/sites/flaunt.com/prod/log
sf_logging_enabled: true
sf_login_action: signin
sf_login_module: sfGuardAuth
sf_max_forwards: 5
sf_module_cache_dir: /mnt/data-store/sites/flaunt.com/prod/cache/backend/prod/mod ules
sf_module_disabled_action: disabled
sf_module_disabled_module: default
sf_no_script_name: false
sf_orm: doctrine
sf_plugins_dir: /mnt/data-store/sites/flaunt.com/prod/plugins
sf_prototype_web_dir: /sfProtoculousPlugin
sf_rich_text_js_dir: js/tiny_mce
sf_root_dir: /mnt/data-store/sites/flaunt.com/prod
sf_secure_action: secure
sf_secure_module: sfGuardAuth
sf_standard_helpers:
- Url
- sd
- Partial
- Cache
- Form
- sdAssets
sf_strip_comments: true
sf_symfony_lib_dir: /mnt/data-store/sites/flaunt.com/prod/lib/vendor/symfony/lib
sf_template_cache_dir: /mnt/data-store/sites/flaunt.com/prod/cache/backend/prod/tem plate
sf_test_cache_dir: /mnt/data-store/sites/flaunt.com/prod/cache/backend/prod/tes t
sf_test_dir: /mnt/data-store/sites/flaunt.com/prod/test
sf_upload_dir: /mnt/data-store/sites/flaunt.com/prod/web/uploads
sf_use_database: true
sf_validation_error_class: form_error
sf_validation_error_id_prefix: error_for_
sf_validation_error_prefix: ' ↓ '
sf_validation_error_suffix: ' ↓'
sf_web_debug: false
sf_web_debug_web_dir: /sf/sf_web_debug
sf_web_dir: /mnt/data-store/sites/flaunt.com/prod/web

request ...

parameterHolder:
action: delete
id: '5'
module: blog
sf_format: html
attributeHolder:
sf_route: 'sfDoctrineRoute Object()'

response ...

options:
http_protocol: HTTP/1.1
logging: '1'
charset: utf-8
send_http_headers: true
content_type: 'text/html; charset=utf-8'
cookies: { }
httpHeaders:
Content-Type: 'text/html; charset=utf-8'
javascripts: { }
stylesheets: { }
metas: { }
httpMetas: { }

user ...

options:
auto_shutdown: false
culture: null
default_culture: en
use_flash: true
logging: '1'
timeout: 1800
attributeHolder:
admin_module: { blog.sort: [null, null] }
sfGuardSecurityUser: { user_id: '2' }
symfony/user/sfUser/attributes: { }
culture: en

global vars ...

cookie:
symfony: 438842a9013bb31f7e1e1e2ba444e532
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: /mnt/data-store/sites/flaunt.com/prod
files: { }
get: { }
post:
sf_method: delete
server:
CONTENT_LENGTH: '16'
CONTENT_TYPE: application/x-www-form-urlencoded
DOCUMENT_ROOT: /mnt/data-store/sites/flaunt.com/prod/web
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-1,utf-8;q=0.7,*;q=0.7'
HTTP_ACCEPT_ENCODING: 'gzip,deflate'
HTTP_ACCEPT_LANGUAGE: 'en-us,en;q=0.5'
HTTP_CONNECTION: keep-alive
HTTP_COOKIE: symfony=438842a9013bb31f7e1e1e2ba444e532
HTTP_HOST: flaunt.com
HTTP_KEEP_ALIVE: '300'
HTTP_REFERER: 'http://flaunt.com/backend.php/blog'
HTTP_USER_AGENT: 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.9) Gecko/20100317 SeaMonkey/2.0.4'
PATH: '/usr/local/bin:/usr/bin:/bin'
PATH_INFO: /blog/5
PATH_TRANSLATED: 'redirect:/index.php/5'
PHP_SELF: /backend.php/blog/5
QUERY_STRING: ''
REMOTE_ADDR: 207.212.171.163
REMOTE_PORT: '1355'
REQUEST_METHOD: POST
REQUEST_TIME: 1271114992
REQUEST_URI: /backend.php/blog/5
SCRIPT_FILENAME: /mnt/data-store/sites/flaunt.com/prod/web/backend.php
SCRIPT_NAME: /backend.php
SERVER_ADDR: 10.248.107.160
SERVER_ADMIN: dylan@sweepingdesign.ccom
SERVER_NAME: flaunt.com
SERVER_PORT: '80'
SERVER_PROTOCOL: HTTP/1.1
SERVER_SIGNATURE: "
Apache/2.2.9 (Ubuntu) Server at flaunt.com Port 80
\n"
SERVER_SOFTWARE: 'Apache/2.2.9 (Ubuntu)'
argc: 0
argv: { }
session:
symfony/user/sfUser/attributes: { symfony/user/sfUser/attributes: { }, sfGuardSecurityUser: { user_id: '2' }, admin_module: { blog.sort: [null, null] } }
symfony/user/sfUser/authenticated: true
symfony/user/sfUser/credentials: { }
symfony/user/sfUser/culture: en
symfony/user/sfUser/lastRequest: 1271114973

symfony v.1.2.3-DEV - php 5.2.6-2ubuntu4.3
for help resolving this issue, please visit http://www.symfony-project.org/.

  • Attachment: error2.jpg
    (Size: 285.60KB, Downloaded 37 time(s))

Re: newbie-correct intersal server error [message #97233 is a reply to message #97218 ] Tue, 13 April 2010 08:10 Go to previous messageGo to next message
hsostock  is currently offline hsostock
Messages: 96
Registered: November 2009
Member
Hi naeluh,

Without digging too deep into your error message, I can tell you that it's probably caused by the relationship between a "user" and their "blogs". If the user has created any blog posts, they will probably indicate the user who created them, through the use of a foreign key dependancy pointing to that user's record in the User table.

So, when you try to delete the user, you will receive that error because, by deleting the user, any blog posts he created will no longer be pointing at him (null), and if it is an identifying relationship, you'll get that error.

But anyways, there are few ways to go about this. If you can modify the schema/databse directly, you can first manually remove the user's blogposts (and any other records which refer to the user by a foreign key (FK)), then you can modify your schema to set up the relationship between Blog and User using CASCADE, for example, which would avoid this problem.

I'm not going to get into the best way of setting up the schema for this, since It's not my area of expertise, but there are a decent number of resources:
Doctrine's website includes several chapters on defining models and working with the YAML schema files:
Defining Models
YAML Schema Files

Alternatively, if you can't or decide you don't want to adjust the schema or work directly with the database, there's another method to handle this from the php/symfony side of things.

When you get the error "Cannot delete or update a parent row: a foreign key constraint fails", it just means that some other database object still contains references to the one you're trying to delete, so they need to be removed before this one. The code required would be specific to your application, but this is a much simpler, "friendlier" solution, especially since you'll be handling those error messages which no one likes to see.

To actually implement it this way, my thinking is that it's probably best, in your lib/model/doctrine/User.class.php, to override Doctrine_Record's delete method. To do that, create the method in your class:
<?php
// lib/model/doctrine/User.class.php

public class user extends BaseUser
{
  ...

  public function 
delete(Doctrine_Connection $conn null)
  {
    
// TODO: first delete all the dependant records of user,  e.g.
    //  $this->getBlogs()->delete();
    //  $this->save();
    // then, call the parent delete method to delete  this user object:
    //  parent::delete()
  
}
}
?>

Asi I mentioned, it's a very pseudocode explanation, but hopefully it will get you started. I probably could have spent another hour or so researching database design, but i think you'll be fine. If you are having trouble with implementing this, just let me know and I could take a look.

Cheers,

Hale

}
Re: newbie-correct intersal server error [message #97291 is a reply to message #97233 ] Tue, 13 April 2010 22:52 Go to previous message
naeluh  is currently offline naeluh
Messages: 9
Registered: April 2010
Junior Member
Thanks Hale!

That worked perfect. I just deleted the posts associated with the user and them I was able to delete the blog identities.

thanks again your awesome!
Previous Topic:symfony session problem with doamin name
Next Topic:Symfony data import and export issue? use excel or other
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software