New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing version comparison for database schema #3249

Merged
merged 7 commits into from Mar 10, 2014

Conversation

Projects
None yet
@Hackwar
Member

Hackwar commented Mar 6, 2014

#2146 tried to fix a broken version comparison that was there, but did it in a wrong way. The schema was compared against the Joomla version, although the two have actually very little in common.

$this->schemaVersion is the schema version stored in the database. $this->changeset->getSchema() is the latest available file in the respective folder of com_admin. Those 2 should be compared and not $this->schemaVersion with the Joomla version.

Since before #2146 it only compared the first 5 characters of the schemaVersion and the Joomla version, the check was always positive for all Joomla 2.5.1x versions and it only wanted to update for new Joomla 3.x.x versions, but didn't really react during development time. Introducing the version comparison showed that bug, but didn't really fix it. This PR should do that.

Mea culpa.

@komodore

This comment has been minimized.

Show comment
Hide comment
@komodore

komodore Mar 7, 2014

In Your patch is error:
is: $this->changeset->getschema()
corrrect is: $this->changeSet->getSchema()

komodore commented Mar 7, 2014

In Your patch is error:
is: $this->changeset->getschema()
corrrect is: $this->changeSet->getSchema()

@infograf768

This comment has been minimized.

Show comment
Hide comment
@infograf768

infograf768 Mar 7, 2014

Member

Please create a tracker item and cross reference here.

Member

infograf768 commented Mar 7, 2014

Please create a tracker item and cross reference here.

@infograf768

This comment has been minimized.

Show comment
Hide comment
@infograf768

infograf768 Mar 7, 2014

Member

@test
PR works fine:

Database schema version (in #__schemas): 3.2.3-2014-02-20.
Update version (in #__extensions): 3.2.3.
Database driver: mysqli.
82 database changes were checked successfully.
137 database changes did not alter table structure and were skipped.
Member

infograf768 commented Mar 7, 2014

@test
PR works fine:

Database schema version (in #__schemas): 3.2.3-2014-02-20.
Update version (in #__extensions): 3.2.3.
Database driver: mysqli.
82 database changes were checked successfully.
137 database changes did not alter table structure and were skipped.
@sovainfo

This comment has been minimized.

Show comment
Hide comment
@sovainfo

sovainfo Mar 7, 2014

Contributor

Should also use $this->changSet->getSchema() as parameter in the message. Maybe the message can be reworded as well:
Database structure at version (#1), CMS expects version (#2). Press Fix to resolve.

Original issue [32179] in JC.

Contributor

sovainfo commented Mar 7, 2014

Should also use $this->changSet->getSchema() as parameter in the message. Maybe the message can be reworded as well:
Database structure at version (#1), CMS expects version (#2). Press Fix to resolve.

Original issue [32179] in JC.

@Hackwar

This comment has been minimized.

Show comment
Hide comment
@Hackwar

Hackwar Mar 7, 2014

Member

Fixed in both PRs.

Member

Hackwar commented Mar 7, 2014

Fixed in both PRs.

@sovainfo

This comment has been minimized.

Show comment
Hide comment
@sovainfo

sovainfo Mar 7, 2014

Contributor

That only leaves the override in Hathor.
Tried to contribute those changes to your patch-12 branch, failed with 404 from github!

Contributor

sovainfo commented Mar 7, 2014

That only leaves the override in Hathor.
Tried to contribute those changes to your patch-12 branch, failed with 404 from github!

@infograf768

This comment has been minimized.

Show comment
Hide comment
@infograf768

infograf768 Mar 8, 2014

Member

I confirm Hathor has also to be patched and, please, again, create a tracker on joomlacode as we have not switched to JISSUEs

Member

infograf768 commented Mar 8, 2014

I confirm Hathor has also to be patched and, please, again, create a tracker on joomlacode as we have not switched to JISSUEs

@wilsonge

This comment has been minimized.

Show comment
Hide comment
@jms2win

This comment has been minimized.

Show comment
Hide comment
@jms2win

jms2win Mar 9, 2014

Contributor

Another solution to this issue that avoid modifying multiple files could be to modify the models/database.php to cleanup the getSchemaversion function.

Here it is the code that I propose.

public function getSchemaVersion()
{
    $db = JFactory::getDbo();
    $query = $db->getQuery(true)
        ->select('version_id')
        ->from($db->quoteName('#__schemas'))
        ->where('extension_id = 700');
    $db->setQuery($query);
    $result = $db->loadResult();

//_jms2win_begin
if ( !empty( $result)) {
// Cleanup the schema version to just keep the (nn.nn.nn)
if ( preg_match( '#([0-9]+.[0-9]+.[0-9]+)#', $result, $match)) {
$result = $match[1];
}
}
//_jms2win_end

    return $result;
}

So that, the other files does not need to be changed.

Contributor

jms2win commented Mar 9, 2014

Another solution to this issue that avoid modifying multiple files could be to modify the models/database.php to cleanup the getSchemaversion function.

Here it is the code that I propose.

public function getSchemaVersion()
{
    $db = JFactory::getDbo();
    $query = $db->getQuery(true)
        ->select('version_id')
        ->from($db->quoteName('#__schemas'))
        ->where('extension_id = 700');
    $db->setQuery($query);
    $result = $db->loadResult();

//_jms2win_begin
if ( !empty( $result)) {
// Cleanup the schema version to just keep the (nn.nn.nn)
if ( preg_match( '#([0-9]+.[0-9]+.[0-9]+)#', $result, $match)) {
$result = $match[1];
}
}
//_jms2win_end

    return $result;
}

So that, the other files does not need to be changed.

@Hackwar

This comment has been minimized.

Show comment
Hide comment
@Hackwar

Hackwar Mar 9, 2014

Member

That unfortunately does not work, since we actually do want to compare the full schema versions against each other in order to also get the updates during development time.

Member

Hackwar commented Mar 9, 2014

That unfortunately does not work, since we actually do want to compare the full schema versions against each other in order to also get the updates during development time.

@jms2win

This comment has been minimized.

Show comment
Hide comment
@jms2win

jms2win Mar 9, 2014

Contributor

OK - that was just a proposal to minimize the fix but effectively, I didn't took in consideration that now, you would like to check the full schema version including the date that is present after the version number because in the past, the objective was to just verify the number (excluding the date).
That explain why I proposed an alternative solution but yours is better to also take in account the date.

Well done.

Contributor

jms2win commented Mar 9, 2014

OK - that was just a proposal to minimize the fix but effectively, I didn't took in consideration that now, you would like to check the full schema version including the date that is present after the version number because in the past, the objective was to just verify the number (excluding the date).
That explain why I proposed an alternative solution but yours is better to also take in account the date.

Well done.

mbabker added a commit that referenced this pull request Mar 10, 2014

Merge pull request #3249 from Hackwar/patch-12
Fixing version comparison for database schema

@mbabker mbabker merged commit bb3327a into joomla:staging Mar 10, 2014

1 check passed

default The Travis CI build passed
Details
@jmcnally1

This comment has been minimized.

Show comment
Hide comment
@jmcnally1

jmcnally1 Mar 17, 2014

I'm getting this error in my database and the fix doesn't resolve it. Will your patch help with that?

Database schema version (in #__schemas): 3.2.3-2014-02-20.
Update version (in #__extensions): 3.2.3.
Database driver: mysqli.
82 database changes were checked successfully.
136 database changes did not alter table structure and were skipped.

jmcnally1 commented Mar 17, 2014

I'm getting this error in my database and the fix doesn't resolve it. Will your patch help with that?

Database schema version (in #__schemas): 3.2.3-2014-02-20.
Update version (in #__extensions): 3.2.3.
Database driver: mysqli.
82 database changes were checked successfully.
136 database changes did not alter table structure and were skipped.
@Hackwar

This comment has been minimized.

Show comment
Hide comment
@Hackwar

Hackwar Mar 17, 2014

Member

I don't see any error in your paste. that is what should be displayed if everything is okay.

Member

Hackwar commented Mar 17, 2014

I don't see any error in your paste. that is what should be displayed if everything is okay.

@jmcnally1

This comment has been minimized.

Show comment
Hide comment
@jmcnally1

jmcnally1 Mar 17, 2014

Okay thanks. The reason I thought there was one was I can't edit and save existing articles nor add new ones.

This message says my database is out of date but the fix button doesn't change that.

screen shot 2014-03-17 at 3 42 01 pm

jmcnally1 commented Mar 17, 2014

Okay thanks. The reason I thought there was one was I can't edit and save existing articles nor add new ones.

This message says my database is out of date but the fix button doesn't change that.

screen shot 2014-03-17 at 3 42 01 pm

@Hackwar

This comment has been minimized.

Show comment
Hide comment
@Hackwar

Hackwar Mar 18, 2014

Member

Please check the forums for support. This is not the right place for that. In any case, you should check the other tab to see what the error actually is.

Member

Hackwar commented Mar 18, 2014

Please check the forums for support. This is not the right place for that. In any case, you should check the other tab to see what the error actually is.

@Hackwar Hackwar deleted the Hackwar:patch-12 branch Mar 18, 2014

@mafthegreat

This comment has been minimized.

Show comment
Hide comment
@mafthegreat

mafthegreat Mar 22, 2014

hi guys, I am completely new in joomla, can anyone please help me how to patch this up to get my data base schema fixed? i tried fixing it from the extension manager update section and the button fix does not work. i would appreciate any help in advance. :)

mafthegreat commented Mar 22, 2014

hi guys, I am completely new in joomla, can anyone please help me how to patch this up to get my data base schema fixed? i tried fixing it from the extension manager update section and the button fix does not work. i would appreciate any help in advance. :)

@zero-24

This comment has been minimized.

Show comment
Hide comment
@zero-24

zero-24 Mar 22, 2014

Contributor

@mafthegreat

This is only a view issue that will fixed with the next release. You don't need to fix it manualy.
See: http://docs.joomla.org/J3.2:Database_schema_version_%283.2.3-2014-02-20%29_does_not_match_CMS_version_%283.2.3%29
You may blame the J!Tracker Application for transmitting this comment.

EDIT:
If you (know what you do and) will fix it. You only need to do the changes that show here:
https://github.com/joomla/joomla-cms/pull/3249/files

Contributor

zero-24 commented Mar 22, 2014

@mafthegreat

This is only a view issue that will fixed with the next release. You don't need to fix it manualy.
See: http://docs.joomla.org/J3.2:Database_schema_version_%283.2.3-2014-02-20%29_does_not_match_CMS_version_%283.2.3%29
You may blame the J!Tracker Application for transmitting this comment.

EDIT:
If you (know what you do and) will fix it. You only need to do the changes that show here:
https://github.com/joomla/joomla-cms/pull/3249/files

@mafthegreat

This comment has been minimized.

Show comment
Hide comment
@mafthegreat

mafthegreat Mar 22, 2014

@zero-24 thank you ok so some edit on these files that are found from https://github.com/joomla/joomla-cms/pull/3249/files . Can I edit the lines with using my file manager of cpanel?

mafthegreat commented Mar 22, 2014

@zero-24 thank you ok so some edit on these files that are found from https://github.com/joomla/joomla-cms/pull/3249/files . Can I edit the lines with using my file manager of cpanel?

@mafthegreat

This comment has been minimized.

Show comment
Hide comment
@mafthegreat

mafthegreat Mar 22, 2014

@zero-24 thank you man your instructions were clear i edited it through my cpanel file manager and now it is ok. cheers! :)

mafthegreat commented Mar 22, 2014

@zero-24 thank you man your instructions were clear i edited it through my cpanel file manager and now it is ok. cheers! :)

@speedbird86

This comment has been minimized.

Show comment
Hide comment
@speedbird86

speedbird86 Apr 2, 2014

Hi there,

I actually modified the 3 files but still get the same error:

Database schema version (3.2.3-2014-02-20) does not match CMS version (3.2.2-2014-01-23).
Database update version (3.2.3) does not match CMS version (3.2.2).

Any thoughts?

speedbird86 commented Apr 2, 2014

Hi there,

I actually modified the 3 files but still get the same error:

Database schema version (3.2.3-2014-02-20) does not match CMS version (3.2.2-2014-01-23).
Database update version (3.2.3) does not match CMS version (3.2.2).

Any thoughts?

@Hackwar

This comment has been minimized.

Show comment
Hide comment
@Hackwar

Hackwar Apr 2, 2014

Member

Your versions are NOT correct. Your CMS is not up-to-date. Please update.

Member

Hackwar commented Apr 2, 2014

Your versions are NOT correct. Your CMS is not up-to-date. Please update.

@speedbird86

This comment has been minimized.

Show comment
Hide comment
@speedbird86

speedbird86 Apr 2, 2014

Updated, re-modified files and now its working great.

Thanks!

speedbird86 commented Apr 2, 2014

Updated, re-modified files and now its working great.

Thanks!

Bakual added a commit to Bakual/joomla-cms that referenced this pull request May 12, 2014

Merge pull request joomla#3249 from Hackwar/patch-12
Fixing version comparison for database schema
@Alexzxc

This comment has been minimized.

Show comment
Hide comment
@Alexzxc

Alexzxc Apr 7, 2016

help me please
1054 Unknown column 'type_alias' in 'where clause' SQL=SELECT * FROM #__content_types WHERE type_alias IN ('com_content.category')

Alexzxc commented Apr 7, 2016

help me please
1054 Unknown column 'type_alias' in 'where clause' SQL=SELECT * FROM #__content_types WHERE type_alias IN ('com_content.category')

@wilsonge

This comment has been minimized.

Show comment
Hide comment
@wilsonge

wilsonge Apr 7, 2016

Contributor

Guys this is a issue tracker not a support portal. Please use the forum for support http://forum.joomla.org/. I'm locking this issue

Contributor

wilsonge commented Apr 7, 2016

Guys this is a issue tracker not a support portal. Please use the forum for support http://forum.joomla.org/. I'm locking this issue

@joomla joomla locked and limited conversation to collaborators Apr 7, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.