Skip to content

MSSQL fix sql syntax in administrator/components/com_admin/sql/updates/sqlazure#14102

Merged
rdeutz merged 1 commit intojoomla:stagingfrom
csthomas:msfixupdate
Mar 3, 2017
Merged

MSSQL fix sql syntax in administrator/components/com_admin/sql/updates/sqlazure#14102
rdeutz merged 1 commit intojoomla:stagingfrom
csthomas:msfixupdate

Conversation

@csthomas
Copy link
Copy Markdown
Contributor

@csthomas csthomas commented Feb 16, 2017

Summary of Changes

Update sql files for mssql database has invalid syntax.
This PR fix files from 3.5.0 and one older to correct syntax.

Testing Instructions

  • Install Joomla 3.5.0 on sqlsrv (mssql) database in folder joomla
  • Download and extract Joomla from https://github.com/csthomas/joomla-cms/archive/msfixupdate.zip to folder joomla37
  • Move joomla to joomla_old
  • Move joomla37 to joomla
  • Copy joomla_old/configuration.php to joomla/configuration.php
  • Download postupdate.php file from https://gist.github.com/mbabker/d7bfb4e1e2fbc6b7815a733607f89281#file-postupdate-php and save it in joomla/administrator/ folder.
  • [optional] Add a few changes as on below diff file to debugging if you like:
diff --git a/libraries/joomla/database/driver/sqlsrv.php b/libraries/joomla/database/driver/sqlsrv.php
index a0b4285cfb..d2a2097a3d 100644
--- a/libraries/joomla/database/driver/sqlsrv.php
+++ b/libraries/joomla/database/driver/sqlsrv.php
@@ -630,7 +630,7 @@ class JDatabaseDriverSqlsrv extends JDatabaseDriver
                {
                        $array = array();
                }
-
+echo "$query\n\n";
                // Execute the query. Error suppression is used here to prevent warnings/notices that the connection has been lost.
                $this->cursor = @sqlsrv_query($this->connection, $query, array(), $array);
 
@@ -685,7 +685,7 @@ class JDatabaseDriverSqlsrv extends JDatabaseDriver
                        {
                                // Get the error number and message from before we tried to reconnect.
                                $this->errorNum = $errorNum;
-                               $this->errorMsg = $errorMsg;
+                               $this->errorMsg = $errorMsg;echo "\n\n $errorMsg\n\n";
 
                                // Throw the normal query exception.
                                JLog::add(JText::sprintf('JLIB_DATABASE_QUERY_FAILED', $this->errorNum, $this->errorMsg), JLog::ERROR, 'database-error');
  • run php -f administrator/postupdate.php
  • From time to time if you apply diff file to see debug info you may see:
DELETE 
FROM [j37_session]
WHERE [time] < N'1487235471'

Error displaying the error page: Application Instantiation Error: Failed to start the session because headers have already been sent by ".../libraries/joomla/database/driver/sqlsrv.php" at line 633.

Then try again run php file, after a few times it won't failed:)

  • At the end of logs you should see:
Update to 3.7.0-beta3 completed successfully.

or if this PR is still not perfect then (TEST FAILED):

Failed to finalize the upgrade, please check the logs for additional details.

Alternative way to test for git users:

git clone ...
git checkout -f 3.5.0
rm configuration.php # if exists
# Install Joomla 3.5.0 on sqlsrv
git checkout -f staging
curl https://patch-diff.githubusercontent.com/raw/joomla/joomla-cms/pull/14102.diff | git apply
# Apply above diff file
php -f administrator/postupdate.php
...

I have tested only from Joomla 3.5.0 because I have not php 5.6 or less.

Expected result

Upgrade from Joomla 3.5.0 to 3.7 will go without errors.

Actual result

Upgrade fails.

Documentation Changes Required

None

@csthomas csthomas changed the title MSSQL update files - fix query syntax MSSQL fix sql syntax in administrator/components/com_admin/sql/updates/sqlazure Feb 16, 2017
@zero-24 zero-24 added this to the Joomla 3.7.0 milestone Feb 17, 2017
@alikon
Copy link
Copy Markdown
Contributor

alikon commented Feb 18, 2017

i've followed first test info
upgraded from 3.6.5 to Joomla! 3.7.0-beta3 dev [ Amani ] 8-February-2017 14:11 GMT
on Microsoft SQL Server 12.00.2000
successfully

but after visiting home page got a 404 Component not found.
and on backend
driver

@alikon
Copy link
Copy Markdown
Contributor

alikon commented Feb 18, 2017

I have tested this item ✅ successfully on 2ec04fa


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/14102.

cause previous mentioned isssues are present on a fresh install of current staging too

@csthomas
Copy link
Copy Markdown
Contributor Author

Backend error become from $query->group() which I fixed at #13262.

The 404 error is unrelated, but I do not see it on linux.
I get only error message from joomla generated by some plugin (default enabled).
I have to turn on windows on virtual machine:)

@csthomas
Copy link
Copy Markdown
Contributor Author

The 404 error also appears on staging joomla installation on mssql. So it is not related.

@waader
Copy link
Copy Markdown
Contributor

waader commented Feb 18, 2017

I tried it with Joomla 3.4.8 and php 5.3.29. postupdate.php gives some warnings on each invocation. After logging into backend I get
Error loading component: com_fields, Component not found.
and Manage > Database gives this list, that is not fixable:
Database schema version (None) does not match CMS version (3.7.0-2017-02-02).
Database update version (3.7.0-beta2) does not match CMS version (3.7.0-beta3).
Table N'epik2_fields' does not exist. (From file 3.7.0-2016-08-29.sql.)
Table N'epik2_fields_categories' does not exist. (From file 3.7.0-2016-08-29.sql.)
Table N'epik2_fields_groups' does not exist. (From file 3.7.0-2016-08-29.sql.)
Table N'epik2_fields_values' does not exist. (From file 3.7.0-2016-08-29.sql.)

@csthomas
Copy link
Copy Markdown
Contributor Author

@waader I have fixed one another file from 3.5.0. your upgrade stop on this file, there is a reason of above problems.

@csthomas
Copy link
Copy Markdown
Contributor Author

I have merged branch 'staging' into 'msfixupdate' in order to add #14133 changes.

@csthomas
Copy link
Copy Markdown
Contributor Author

Now you can upgrade from joomla >= 3.4.0 but there is still a few bugs in updates files IIRC 3.03, 3.2.x and 3.4.0

@waader
Copy link
Copy Markdown
Contributor

waader commented Feb 19, 2017

Upgrade from Joomla 3.4.8 works now.

@csthomas
Copy link
Copy Markdown
Contributor Author

csthomas commented Feb 23, 2017

I have to rebase this patch, there is not changes. Now should be easier to test by Patch Tester.

@waader
Copy link
Copy Markdown
Contributor

waader commented Feb 24, 2017

I have tested this item ✅ successfully on d441d0d

Could it be that mssql didn´t work for joomla3.0.2 at all. I tried to install this version but couldn´t reach the second tab (database). As upgrade from 3.4.8 works I mark this as successfull.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/14102.

@csthomas
Copy link
Copy Markdown
Contributor Author

csthomas commented Feb 25, 2017

When I choose no sample then it works better but you should not use Database -> Fix button on that PR.
After you click on Fix button then probably not all queries will be performed.

I do it in different way on windows. In general it is described at the Test Instruction above.
But for wamp installation my last command looks like:

C:\wamp\www\joomla370>..\..\bin\php\php5.6.25\php.exe -c ..\..\bin\php\php5.6.25
\phpForApache.ini -f administrator\postupdate.php
Update to 3.7.0-beta3 completed successfully.

@csthomas
Copy link
Copy Markdown
Contributor Author

csthomas commented Mar 2, 2017

Can someone with privilege can merge this PR. This is for mssql only with last success test.
There are only sql updates files. Last php file is already merged.

It is blocking me from creating a next PR.

@ghost
Copy link
Copy Markdown

ghost commented Mar 3, 2017

pinging @infograf768

@joomla-cms-bot joomla-cms-bot removed this from the Joomla 3.7.0 milestone Mar 3, 2017
@infograf768
Copy link
Copy Markdown
Member

RTC, as it is unlikely that we will get more MSSQL testers.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/14102.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Mar 3, 2017
@ghost
Copy link
Copy Markdown

ghost commented Mar 3, 2017

thanks @infograf768

@zero-24 zero-24 added this to the Joomla 3.7.0 milestone Mar 3, 2017
@rdeutz rdeutz merged commit 9ea3444 into joomla:staging Mar 3, 2017
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Mar 3, 2017
@csthomas csthomas deleted the msfixupdate branch March 3, 2017 15:07
jjaracz pushed a commit to jjaracz/joomla-cms that referenced this pull request Mar 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants