We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 5811
    • 1,717 Posts
    Sorry, I am pretty sure that this topic has been already treated, but I have missed the answer and I am greatly interested by the answer.

    After the installation, the database_connection_charset is always initialized with an empty string. With 0.9.6.2, is it planned to modify the installer in order to intialize correctly this variable ? by asking the value to the user or by deduction from the collation value set by the user ?

    AjaxSearch can’t work without this variable correctly initialized and this empty value generate lot of posts and exasperation.
      • 22303 MODX Staff
      • 10,725 Posts
      It’s definitely a bug and needs to be addressed in the 0.9.6.x installer.
        • 6726
        • 7,075 Posts
        Funny, I was about to post a bug report (I guess that’s already done then), I’ve experienced it too with new installs and it messed up my content undecided
          .: COO - Commerce Guys - Community Driven Innovation :.


          MODx est l'outil id
          • 25663 MODX Staff
          • 12,272 Posts
          Is there a bug filed?
            Ryan Thrash, MODX Co-Founder
            Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
            • 7231
            • 4,205 Posts
            the problem is how the charset is determined in instprocessor.php.
            	$database_collation = $_POST['database_collation'];
            	$database_charset = substr($database_collation, 0, strpos($database_collation, '_'));

            If the user inputs the collation as utf8_general_ci it will correctly set the charset to utf8, however if the user inputs only utf8 it will return a blank string. I don’t know of a solution, a suggestion would be to provide a pull down selector to control how the collation is input rather than leaving it to the user.
              [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

              Something is happening here, but you don't know what it is.
              Do you, Mr. Jones? - [bob dylan]
              • 22303 MODX Staff
              • 10,725 Posts
              Thanks for the research; that’s actually very helpful.

              Now the problem, like you alluded to, is how to provide the user a list of collations that are valid for their MySQL server configuration. And until we connect, we do not know this. undecided
                • 17883
                • 1,039 Posts
                Isn´t it possible to let the user type in the database connection and then automatically read out the collation and charset and set it to the config?
                  • 6726
                  • 7,075 Posts
                  Forgive me to ask such a stupid question, but I think the installer should be very precise : currently, it says "Connection character set:" but in phpMyAdmin there are two things "MySQL charset" and "MySQL connection collation" and they can be different (in my case, MySQL charset is utf8 and default collation is utf8_unicode_ci but all my MODx installs use latin_swedish_ci as collation huh => I am a bit lost as to why it is so...).

                  Easy to get confused since the label we apply is a combination of both ("connection" + "charset").
                  If I understand correctly MODx looks up the DB collation to determine which charset is used... in my case it won’t work since one is utf8 and the DB’s collation is (somehow) different from the default collation for my server...

                  Do I make sense ?
                    .: COO - Commerce Guys - Community Driven Innovation :.


                    MODx est l'outil id
                    • 7231
                    • 4,205 Posts
                    latin_swedish_ci is the MySQL default regardless the settings in phpmyadmin, it will use this if there is no valid charset selected, this has puzzled me as well.

                    I don’t know if this fixes the problem but it will resolve the error resulting in blank charset selection. Replace:
                    $database_charset = substr($database_collation, 0, strpos($database_collation, '_'));


                    with this:
                    if (strpos($database_collation, '_')) {
                    	$database_charset = substr($database_collation, 0, strpos($database_collation, '_'));
                    } else { 	
                    	$database_charset = $database_collation;}


                    The problem here is that utf8 (for example) is not a valid collation, so if the collation has no _ it should not be accepted. Maybe the problem is not here but when the collation is verified in the test database or in the summary pages. Or am I missing something?

                    OK, just checked over at MySQL and all valid collations seem to have a _ underscore in the name, therefore the problem is not in the function above but in the db test and the summary pages of the install that are allowing a poorly formated collation to go through. Need to add the strpos check to these functions.
                      [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                      Something is happening here, but you don't know what it is.
                      Do you, Mr. Jones? - [bob dylan]
                      • 5811
                      • 1,717 Posts
                      Hi dev_cw,

                      I examine the code and I share partially your feedback:
                      If the user inputs the collation as utf8_general_ci it will correctly set the charset to utf8, however if the user inputs only utf8 it will return a blank string. I don’t know of a solution, a suggestion would be to provide a pull down selector to control how the collation is input rather than leaving it to the user.
                      When you keep the default value for collation (utf8_general_ci) for your first installation at the end you get an empty value for the connection_charset undecided
                      This issue is due to the fact that $_POST[’database_connection_charset’] is not set in the action.options.php (the page which follow the connection page). So at the end, whatever the value of collation you get an empty connection_charset empty !

                      So to correct this issue, I suggest the following improvement:
                      1/ check the form of the collation provided by the user. For that I have added a new javascript function in the action.connection.php. script tested under firebug. This script test that your collation has the form *_*_xx with xx=ci or xx=cs or xx=bin.
                      		if(wrongCollation(f.database_collation.value)) {
                      			alert('<?php echo $_lang['alert_collation']?>');
                      			f.database_collation.focus();
                      			return false;
                      		}
                      
                      	function wrongCollation(col) {
                          p1=col.indexOf('_');
                          if (p1>0){
                            col2 = col.substr(p1+1,col.length-p1-1);
                            p2=col2.indexOf('_');
                            if (p2>0){
                              pcs=col.indexOf('cs');
                              pci=col.indexOf('ci');
                              pbin=col.indexOf('bin');
                              if (pcs>0 || pci>0 || pbin>0) return false;
                            }
                          }
                          return true;
                        }
                      
                      If it is not the case a new message is displayed to the user: "Your collation is incorrect". For the moment I have updated only the english lang file. The others files are not changed.
                      $_lang["alert_collation"] = 'Your collation is incorrect!';


                      2/ in the action.options.php the $_POST[’database_connection_charset’] should be initialised as follow:
                      if ($installMode == 0) {
                        $_POST['database_connection_charset'] = substr($_POST['database_collation'], 0, strpos($_POST['database_collation'], '_'));
                      }
                      else if ($installMode == 1) {
                      I have tested the nominal case (a first installation). I need now to test that it is ok for the migration case.
                      I got the source code from SVN, but once my tests will be finished, how could i deliver the new version of these files ? and how can I get the translation for the other languages (for French and Spanish it’s ok) ?

                      Find enclosed the changed files to test again these changes