Skip to content

Commit

Permalink
Tweaked content type version checking to ignore point releases.
Browse files Browse the repository at this point in the history
  • Loading branch information
cheesegrits committed Jan 15, 2016
1 parent 1303da4 commit 1a5bd3a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<contenttype>
<name>Contact us</name>
<fabrikversion>3.4</fabrikversion>
<fabrikversion>3.4.2</fabrikversion>
<group join_id="" is_join="0" id="5" name="details" label="" css="" published="1" created="2015-12-15 22:49:20" private="0">
<params split_page="0" list_view_and_query="1" access="1" intro="" outro="" repeat_group_button="0" repeat_template="repeatgroup" repeat_max="" repeat_min="" repeat_error_message="" repeat_intro="" repeat_add_access="1" repeat_delete_access="1" repeat_delete_access_user="" repeat_copy_element_values="0" group_columns="2" group_column_widths="" repeat_group_show_first="1" random="0" labels_above="0" labels_above_details="0"/>
<element label="id" published="1" name="id" id="17" plugin="internalid" created="2015-12-15 22:49:20" width="3" height="0" default="" hidden="1" eval="0" ordering="1" show_in_list_summary="0" filter_type="" filter_exact_match="" link_to_detail="1" primary_key="1" auto_increment="1" access="1" use_in_page_title="0" parent_id="0">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<contenttype ignoreacl="true">
<name>Default</name>
<fabrikversion>3.4.1</fabrikversion>
<fabrikversion>3.4.2</fabrikversion>
<group join_id="" is_join="0" id="118" name="{label}" label="{label}" css="" published="1" created="2016-01-10 08:53:39" private="0">
<params repeat_group_button="0" repeat_group_show_first="1"/>

Expand Down
15 changes: 13 additions & 2 deletions administrator/components/com_fabrik/models/contenttypeimport.php
Original file line number Diff line number Diff line change
Expand Up @@ -885,11 +885,22 @@ private function checkVersion($xpath, &$layoutData)
{
$xml = simplexml_load_file(JPATH_COMPONENT_ADMINISTRATOR . '/fabrik.xml');
$layoutData->siteVersion = (string) $xml->version;
if (!strstr($layoutData->siteVersion, '.'))
{
$layoutData->siteVersion .= '.0';
}

$contentTypeVersion = $xpath->query('/contenttype/fabrikversion');
$contentTypeVersion = iterator_to_array($contentTypeVersion);
$layoutData->contentTypeVersion = empty($contentTypeVersion) ? 0 : (string) $contentTypeVersion[0]->nodeValue;
$layoutData->contentTypeVersion = empty($contentTypeVersion) ? '0.0' : (string) $contentTypeVersion[0]->nodeValue;
if (!strstr($layoutData->contentTypeVersion, '.'))
{
$layoutData->contentTypeVersion .= '.0';
}

$layoutData->versionMismatch = $layoutData->siteVersion !== $layoutData->contentTypeVersion;
// Only check for major.minor, ignore point release
$minorSite = preg_replace('#^(\d+\.\d+)(.*)#', '${1}', $layoutData->siteVersion);
$minorContentType = preg_replace('#^(\d+\.\d+)(.*)#', '${1}', $layoutData->contentTypeVersion);
$layoutData->versionMismatch = version_compare($minorSite, $minorContentType, 'ne');
}
}

0 comments on commit 1a5bd3a

Please sign in to comment.