Skip to content

Commit

Permalink
Fixes #4203 DevicesDetection 1.14 version schema update to account fo…
Browse files Browse the repository at this point in the history
…r longer strings ( fields config_os_version and config_device_type are not large enough )

Refs #4204 Plugin schema example with DevicesDetection
  • Loading branch information
mattab committed Oct 7, 2013
1 parent 4737bb6 commit 16f8dd6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 26 deletions.
21 changes: 11 additions & 10 deletions core/Updater.php
Expand Up @@ -122,14 +122,14 @@ public function getSqlQueriesToExecute()
require_once $file; // prefixed by PIWIK_INCLUDE_PATH

$className = $this->getUpdateClassName($componentName, $fileVersion);
if (class_exists($className, false)) {
$queriesForComponent = call_user_func(array($className, 'getSql'));
foreach ($queriesForComponent as $query => $error) {
$queries[] = $query . ';';
}

$this->hasMajorDbUpdate = $this->hasMajorDbUpdate || call_user_func(array($className, 'isMajorUpdate'));
if (!class_exists($className, false)) {
throw new \Exception("The class $className was not found in $file");
}
$queriesForComponent = call_user_func(array($className, 'getSql'));
foreach ($queriesForComponent as $query => $error) {
$queries[] = $query . ';';
}
$this->hasMajorDbUpdate = $this->hasMajorDbUpdate || call_user_func(array($className, 'isMajorUpdate'));
}
// unfortunately had to extract this query from the Option class
$queries[] = 'UPDATE `' . Common::prefixTable('option') . '`
Expand All @@ -141,12 +141,13 @@ public function getSqlQueriesToExecute()

private function getUpdateClassName($componentName, $fileVersion)
{
////unprefixClass TODOA FIXME
$suffix = strtolower(str_replace(array('-', '.'), '_', $fileVersion));
$className = 'Updates_' . $suffix;

if ($componentName == 'core') {
return 'Piwik_Updates_' . $suffix;
return '\\Piwik\\Updates\\' . $className;
}
return 'Piwik_' . $componentName . '_Updates_' . $suffix;
return '\\Piwik\\Plugins\\' . $componentName . '\\'. $className;
}

/**
Expand Down
Expand Up @@ -48,7 +48,7 @@
disable visitor Tracking and put the Piwik User Interface in maintenance mode</a>.
</li>
<li>{{ 'CoreUpdater_YouCouldManuallyExecuteSqlQueries'|translate }}<br/>
<a href="#" id="showSql" style="margin-left:20px;">› {{ 'CoreUpdater_ClickHereToViewSqlQueries'|translate }}</a>
<a href="#titleUpdate" id="showSql" style="margin-left:20px;">› {{ 'CoreUpdater_ClickHereToViewSqlQueries'|translate }}</a>

<div id="sqlQueries" style="display:none;">
<br/>
Expand Down
30 changes: 15 additions & 15 deletions plugins/DevicesDetection/DevicesDetection.php
Expand Up @@ -25,6 +25,19 @@

class DevicesDetection extends \Piwik\Plugin
{
/**
* @see Piwik_Plugin::getInformation
*/
public function getInformation()
{
return array(
'description' => "[Beta Plugin] " . Piwik_Translate("DevicesDetection_PluginDescription"),
'author' => 'Piwik PRO',
'author_homepage' => 'http://piwik.pro',
'version' => '1.14',
);
}

/** The set of related reports displayed under the 'Operating Systems' header. */
private $osRelatedReports = null;
private $browserRelatedReports = null;
Expand Down Expand Up @@ -69,19 +82,6 @@ protected function getRawMetadataDeviceType()
);
}

/**
* @see Piwik_Plugin::getInformation
*/
public function getInformation()
{
return array(
'description' => "[Beta Plugin] " . Piwik_Translate("DevicesDetection_PluginDescription"),
'author' => 'Piwik PRO',
'author_homepage' => 'http://piwik.pro',
'version' => '1.13',
);
}

/**
* @see Piwik_Plugin::getListHooksRegistered
*/
Expand Down Expand Up @@ -230,8 +230,8 @@ public function install()
// we catch the exception
try {
$q1 = "ALTER TABLE `" . Common::prefixTable("log_visit") . "`
ADD `config_os_version` VARCHAR( 10 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL AFTER `config_os` ,
ADD `config_device_type` TINYINT( 10 ) NULL DEFAULT NULL AFTER `config_browser_version` ,
ADD `config_os_version` VARCHAR( 100 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL AFTER `config_os` ,
ADD `config_device_type` TINYINT( 100 ) NULL DEFAULT NULL AFTER `config_browser_version` ,
ADD `config_device_brand` VARCHAR( 100 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL AFTER `config_device_type` ,
ADD `config_device_model` VARCHAR( 100 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL AFTER `config_device_brand`";
Db::exec($q1);
Expand Down

0 comments on commit 16f8dd6

Please sign in to comment.