The categories didn't get saved when posting a new BLOG entry under postgresql

This is the place to report bugs and get support. When posting in this forum, please always provide as much detail as possible.

Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum, do not report it as a bug.

This is the place to report bugs and get support

When posting in this forum, please try to provide as many relevant details as possible. Particularly the following:

  • What operating system were you running when the bug appeared?
  • What database platform is your site using?
  • What version of mojoPortal are you running?
  • What version of .NET do you use?
  • What steps are necessary to reproduce the issue? Compare expected results vs actual results.
Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum.
This thread is closed to new posts. You must sign in to post in the forums.
9/1/2005 2:07:43 PM
Gravatar
Total Posts 15

The category Items didn't get saved when posting a new BLOG entry under postgresql

The categories didn't get saved when posting a new BLOG entry under postgresql. You have to go back and edit the post and recheck the categories so they would stay. This was a bug in dbportal.cs. I've attached the procedure that fixes the issue.  Changes are Underlined bellow.

Let me know if it works as advertised.

Phil

 public static int Blog_AddBlog(
   int ModuleID,
   string UserName,
   string Title, 
   string Excerpt,
   string Description,
   DateTime StartDate,
   bool IsInNewsletter,
   bool IncludeInFeed)
  {
   
   NpgsqlConnection Connection = GetConnection();
   NpgsqlParameter[] arParams = new NpgsqlParameter[9];
   if(ConfigurationSettings.AppSettings.Get("CachePostgreSQLParameters").ToLower()  == "true")
   {
    arParams = NpgsqlHelperParameterCache.GetSpParameterSet(ConfigurationSettings.AppSettings.Get("PostgreSQLConnectionString"),
     "mp_blog_insert(:moduleid,:username,:title,:excerpt,:description,:startdate,:isinnewsletter,:includeinfeed,:category)");

    arParams[0].Value = ModuleID;
    arParams[1].Value = UserName;
    arParams[2].Value = Title;
    arParams[3].Value = Excerpt;
    arParams[4].Value = Description;
    arParams[5].Value = StartDate;
    arParams[6].Value = IsInNewsletter;
    arParams[7].Value = IncludeInFeed;
    arParams[8].Value = string.Empty;  
    
    
   }
   else
   {
    arParams[0] = new NpgsqlParameter("moduleid", NpgsqlTypes.NpgsqlDbType.Integer);
    arParams[0].Direction = ParameterDirection.Input;
    arParams[0].Value = ModuleID;
   
    arParams[1] = new NpgsqlParameter("username", NpgsqlTypes.NpgsqlDbType.Text,100);
    arParams[1].Direction = ParameterDirection.Input;
    arParams[1].Value = UserName;

    arParams[2] = new NpgsqlParameter("title", NpgsqlTypes.NpgsqlDbType.Text,100);
    arParams[2].Direction = ParameterDirection.Input;
    arParams[2].Value = Title;

    arParams[3] = new NpgsqlParameter("excerpt", NpgsqlTypes.NpgsqlDbType.Text,512);
    arParams[3].Direction = ParameterDirection.Input;
    arParams[3].Value = Excerpt;

    arParams[4] = new NpgsqlParameter("description", NpgsqlTypes.NpgsqlDbType.Text);
    arParams[4].Direction = ParameterDirection.Input;
    arParams[4].Value = Description;

    arParams[5] = new NpgsqlParameter("startdate", NpgsqlTypes.NpgsqlDbType.Timestamp);
    arParams[5].Direction = ParameterDirection.Input;
    arParams[5].Value = StartDate;

    arParams[6] = new NpgsqlParameter("isinnewsletter", NpgsqlTypes.NpgsqlDbType.Boolean);
    arParams[6].Direction = ParameterDirection.Input;
    arParams[6].Value = IsInNewsletter;

    arParams[7] = new NpgsqlParameter("includeinfeed", NpgsqlTypes.NpgsqlDbType.Boolean);
    arParams[7].Direction = ParameterDirection.Input;
    arParams[7].Value = IncludeInFeed;

    arParams[8] = new NpgsqlParameter("category", NpgsqlTypes.NpgsqlDbType.Text, 50);
    arParams[8].Direction = ParameterDirection.Input;
    arParams[8].Value = string.Empty;
    
   }
   
   try
   {
    int newID =
      Convert.ToInt16(NpgsqlHelper.ExecuteScalar(Connection,
     CommandType.StoredProcedure,
     "mp_blog_insert(:moduleid,:username,:title,:excerpt,:description,:startdate,:isinnewsletter,:includeinfeed,:category)",
     arParams));
   
    Connection.Close();
    return newID;
   }
   catch(Exception ex)
   {
    Connection.Close();
    throw ex;
   }
  }

9/1/2005 2:19:03 PM
Gravatar
Total Posts 18439

Re: The categories didn't get saved when posting a new BLOG entry under postgresql

I can see why you thought that was the fix but it is not. Catgories column on the mp_Blogs table is a legacy column. Categories are stored in a related table these days. You have to click the Add Category button before you post the blog and it will work.

Joe
9/1/2005 2:57:36 PM
Gravatar
Total Posts 15

Re: The categories didn't get saved when posting a new BLOG entry under postgresql

Sorry its the category Items that go in the mp_blogitemcategories table that didn't get save properly because the old blog_add method didn't get the proper return code from the mp_blog_insert stored proc the proc was ok but

"NpgsqlHelper.ExecuteNonQuery(Connection, CommandType.StoredProcedure, mp_blog_insert(:moduleid,:username,:title,:excerpt,:description,:startdate,:isinnewsletter,:includeinfeed,:category)", arParams);"

always came back with a -1 So the category Items never got the proper Foreign key Itemid so it didn't point to the mp_blog entry .


I hope that cleared up my problem.
9/1/2005 3:28:32 PM
Gravatar
Total Posts 18439

Re: The categories didn't get saved when posting a new BLOG entry under postgresql

Are you running the new release?
9/1/2005 3:36:51 PM
Gravatar
Total Posts 15

Re: The categories didn't get saved when posting a new BLOG entry under postgresql

My test site is running the newest code SVN as of yesterday and my live site is running the older 20050710 code and both had the same issue. This did fix the issue on the SVN code I have not tired it on the live site.

9/1/2005 3:49:12 PM
Gravatar
Total Posts 18439

Re: The categories didn't get saved when posting a new BLOG entry under postgresql

My bad, you are totally right! I should have read your fix more carefully, its been along day and I'm sleepy

I' ll commit to svn now.

Thanks,

Joe
2/22/2006 3:51:28 PM
Gravatar
Total Posts 22

Re: The categories didn't get saved when posting a new BLOG entry under postgresql

I seem to be having a similar problem.  I'm not running SVN.  I'm running v2.0, .NET 2.0 on MySQL (version 0.5?).  I have categories established.  I just can't associate any blog postings with a category.  Is there a correction that I need to make to the database.  Should I get the svn version and make a correction there as described below?

2/22/2006 4:45:57 PM
Gravatar
Total Posts 18439

Re: The categories didn't get saved when posting a new BLOG entry under postgresql

Hi Craig,

Your other error also seems to be db related. I don't know it may be a MySQL 5 issue, I haven't tested with MySQL > 4.x on my local machines. It could also be a bug in the 2.0 release.

I can say that this site is running on the svn code and using MySQL. I'm actually not sure of the MySQL version I'll check with my host.

A lot of things have been improved and fixed in svn since the first 2.0 release which did not use any 2.0 .NET features.
There is an upgrade script you would have to run named Upgradefrom1.0tonext.sql and be aware that not all the skins are updated to the new css layout but the one you are using, gotmono is ready as is subblue and theblues1

Be sure and back up everything, site and db before doing the upgrade in case things go south.

Let me know how it goes or if you need help.

Cheers,

Joe
2/23/2006 2:21:41 AM
Gravatar
Total Posts 22

Re: The categories didn't get saved when posting a new BLOG entry under postgresql

Where can I find the upgrade script that you referenced?
2/23/2006 2:43:02 AM
Gravatar
Total Posts 18439

Re: The categories didn't get saved when posting a new BLOG entry under postgresql

Its in the MySqlData folder in the source tree that you pull down from svn.
You must sign in to post in the forums. This thread is closed to new posts.