Skip to content

Commit

Permalink
Apply coding style around FunctionCallSignature #3
Browse files Browse the repository at this point in the history
  • Loading branch information
sgiehl committed Feb 13, 2024
1 parent 340cfba commit bdb37ef
Show file tree
Hide file tree
Showing 30 changed files with 292 additions and 92 deletions.
13 changes: 10 additions & 3 deletions core/Tracker/TrackerCodeGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,16 @@ public function generate(
$codeImpl['protocol'] = 'https://';
}

$parameters = compact('mergeSubdomains', 'groupPageTitlesByDomain', 'mergeAliasUrls', 'visitorCustomVariables',
'pageCustomVariables', 'customCampaignNameQueryParam', 'customCampaignKeywordParam',
'doNotTrack');
$parameters = compact(
'mergeSubdomains',
'groupPageTitlesByDomain',
'mergeAliasUrls',
'visitorCustomVariables',
'pageCustomVariables',
'customCampaignNameQueryParam',
'customCampaignKeywordParam',
'doNotTrack'
);

/**
* Triggered when generating JavaScript tracking code server side. Plugins can use
Expand Down
9 changes: 6 additions & 3 deletions core/Tracker/Visit.php
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,8 @@ protected function updateExistingVisit($valuesToUpdate)
throw new VisitorNotFoundInDb(
"The visitor with idvisitor=" . bin2hex($this->visitProperties->getProperty('idvisitor'))
. " and idvisit=" . @$this->visitProperties->getProperty('idvisit')
. " wasn't found in the DB, we fallback to a new visitor");
. " wasn't found in the DB, we fallback to a new visitor"
);
}
}

Expand Down Expand Up @@ -557,8 +558,10 @@ protected function getAllVisitDimensions()
$dimensionNames[] = $dimension->getColumnName();
}

Common::printDebug("Following dimensions have been collected from plugins: " . implode(", ",
$dimensionNames));
Common::printDebug("Following dimensions have been collected from plugins: " . implode(
", ",
$dimensionNames
));
}

return self::$dimensions;
Expand Down
21 changes: 18 additions & 3 deletions core/Translation/Weblate/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,24 @@ protected function getApiResults($apiPath, $raw = false)
{
$apiUrl = $this->apiUrl . $apiPath;

$response = Http::sendHttpRequestBy(Http::getTransportMethod(), $apiUrl, 60, null, null, null, 5, false,
false, false, true, 'GET', null, null, null,
['Authorization: Token ' . $this->apiToken]);
$response = Http::sendHttpRequestBy(
Http::getTransportMethod(),
$apiUrl,
60,
null,
null,
null,
5,
false,
false,
false,
true,
'GET',
null,
null,
null,
['Authorization: Token ' . $this->apiToken]
);

$httpStatus = $response['status'];
$response = $response['data'];
Expand Down
3 changes: 2 additions & 1 deletion core/Twig.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ public function __construct()
// Create new Twig Environment and set cache dir
$cache = StaticContainer::get('twig.cache');

$this->twig = new Environment($chainLoader,
$this->twig = new Environment(
$chainLoader,
array(
'debug' => true, // to use {{ dump(var) }} in twig templates
'strict_variables' => true, // throw an exception if variables are invalid
Expand Down
8 changes: 6 additions & 2 deletions core/Updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -590,8 +590,12 @@ public function executeMigration($file, Migration $migration)
$migration->exec();
} catch (\Exception $e) {
if (!$migration->shouldIgnoreError($e)) {
$message = sprintf("%s:\nError trying to execute the migration '%s'.\nThe error was: %s",
$file, $migration->__toString(), $e->getMessage());
$message = sprintf(
"%s:\nError trying to execute the migration '%s'.\nThe error was: %s",
$file,
$migration->__toString(),
$e->getMessage()
);
throw new UpdaterErrorException($message);
}
}
Expand Down
10 changes: 8 additions & 2 deletions core/Updater/Migration/Db/CreateTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,14 @@ public function __construct(Db\Settings $dbSettings, $table, $columnNames, $prim
}


$sql = rtrim(sprintf('CREATE TABLE `%s` (%s) ENGINE=%s DEFAULT CHARSET=%s %s',
$table, implode(', ', $columns), $dbSettings->getEngine(), $dbSettings->getUsedCharset(), $dbSettings->getRowFormat()));
$sql = rtrim(sprintf(
'CREATE TABLE `%s` (%s) ENGINE=%s DEFAULT CHARSET=%s %s',
$table,
implode(', ', $columns),
$dbSettings->getEngine(),
$dbSettings->getUsedCharset(),
$dbSettings->getRowFormat()
));

parent::__construct($sql, static::ERROR_CODE_TABLE_EXISTS);
}
Expand Down
6 changes: 4 additions & 2 deletions core/Updates/0.9.1.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@ public function getMigrations(Updater $updater)
return array(
$this->migration->db->sql(
'UPDATE ' . Common::prefixTable('site') . '
SET timezone = "UTC" WHERE timezone IN (' . $timezoneList . ')'),
SET timezone = "UTC" WHERE timezone IN (' . $timezoneList . ')'
),

$this->migration->db->sql(
'UPDATE `' . Common::prefixTable('option') . '`
SET option_value = "UTC" WHERE option_name = "SitesManager_DefaultTimezone" AND option_value IN (' . $timezoneList . ')'),
SET option_value = "UTC" WHERE option_name = "SitesManager_DefaultTimezone" AND option_value IN (' . $timezoneList . ')'
),
);
}

Expand Down
2 changes: 1 addition & 1 deletion core/Updates/1.2.3.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function getMigrations(Updater $updater)

// Various performance improvements schema updates
$this->migration->db->sql(
'ALTER TABLE `' . Common::prefixTable('log_visit') . '`
'ALTER TABLE `' . Common::prefixTable('log_visit') . '`
DROP INDEX index_idsite_datetime_config,
DROP INDEX index_idsite_idvisit,
ADD INDEX index_idsite_config_datetime (idsite, config_id, visit_last_action_time),
Expand Down
4 changes: 3 additions & 1 deletion core/Updates/1.2.5-rc1.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ public function getMigrations(Updater $updater)
'ALTER TABLE `' . Common::prefixTable('log_conversion') . '`
ADD buster int unsigned NOT NULL AFTER revenue,
DROP PRIMARY KEY,
ADD PRIMARY KEY (idvisit, idgoal, buster)', Updater\Migration\Db::ERROR_CODE_DUPLICATE_COLUMN),
ADD PRIMARY KEY (idvisit, idgoal, buster)',
Updater\Migration\Db::ERROR_CODE_DUPLICATE_COLUMN
),
);
}

Expand Down
40 changes: 24 additions & 16 deletions core/Updates/1.8.4-b1.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function getMigrations(Updater $updater)

// remove protocol and www and store information in url_prefix
$this->migration->db->sql(
" UPDATE `$action`
" UPDATE `$action`
SET
url_prefix = IF (
LEFT(name, 11) = 'http://www.', 1, IF (
Expand All @@ -71,7 +71,8 @@ public function getMigrations(Updater $updater)
WHERE
type = 1 AND
url_prefix IS NULL;
"),
"
),
$this->migration->db->dropTable('log_action_duplicates'),
$this->migration->db->createTable('log_action_duplicates', array(
'before' => 'int(10) unsigned NOT NULL',
Expand All @@ -82,7 +83,7 @@ public function getMigrations(Updater $updater)
// grouping by name only would be case-insensitive, so we GROUP BY name,hash
// ON (action.type = 1 AND canonical.hash = action.hash) will use index (type, hash)
$this->migration->db->sql(
" INSERT INTO `$duplicates` (
" INSERT INTO `$duplicates` (
SELECT
action.idaction AS `before`,
canonical.idaction AS `after`
Expand All @@ -107,11 +108,12 @@ public function getMigrations(Updater $updater)
AND canonical.name = action.name
AND canonical.idaction != action.idaction
);
"),
"
),

// replace idaction in log_link_visit_action
$this->migration->db->sql(
" UPDATE
" UPDATE
`$visitAction` AS link
LEFT JOIN
`$duplicates` AS duplicates_idaction_url
Expand All @@ -120,9 +122,10 @@ public function getMigrations(Updater $updater)
link.idaction_url = duplicates_idaction_url.after
WHERE
duplicates_idaction_url.after IS NOT NULL;
"),
"
),
$this->migration->db->sql(
" UPDATE
" UPDATE
`$visitAction` AS link
LEFT JOIN
`$duplicates` AS duplicates_idaction_url_ref
Expand All @@ -131,11 +134,12 @@ public function getMigrations(Updater $updater)
link.idaction_url_ref = duplicates_idaction_url_ref.after
WHERE
duplicates_idaction_url_ref.after IS NOT NULL;
"),
"
),

// replace idaction in log_conversion
$this->migration->db->sql(
" UPDATE
" UPDATE
`$conversion` AS conversion
LEFT JOIN
`$duplicates` AS duplicates
Expand All @@ -144,11 +148,12 @@ public function getMigrations(Updater $updater)
conversion.idaction_url = duplicates.after
WHERE
duplicates.after IS NOT NULL;
"),
"
),

// replace idaction in log_visit
$this->migration->db->sql(
" UPDATE
" UPDATE
`$visit` AS visit
LEFT JOIN
`$duplicates` AS duplicates_entry
Expand All @@ -157,9 +162,10 @@ public function getMigrations(Updater $updater)
visit.visit_entry_idaction_url = duplicates_entry.after
WHERE
duplicates_entry.after IS NOT NULL;
"),
"
),
$this->migration->db->sql(
" UPDATE
" UPDATE
`$visit` AS visit
LEFT JOIN
`$duplicates` AS duplicates_exit
Expand All @@ -168,18 +174,20 @@ public function getMigrations(Updater $updater)
visit.visit_exit_idaction_url = duplicates_exit.after
WHERE
duplicates_exit.after IS NOT NULL;
"),
"
),

// remove duplicates from log_action
$this->migration->db->sql(
" DELETE action FROM
" DELETE action FROM
`$action` AS action
LEFT JOIN
`$duplicates` AS duplicates
ON action.idaction = duplicates.before
WHERE
duplicates.after IS NOT NULL;
"),
"
),

// remove the duplicates table
$this->migration->db->dropTable('log_action_duplicates')
Expand Down
4 changes: 3 additions & 1 deletion core/Updates/2.1.1-b11.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ public function doUpdate(Updater $updater)
$sql = "SELECT idarchive, idsite, period, date1, date2 FROM $table
WHERE name = ? GROUP BY idarchive";
$visitSummaryReturningSegmentDone = Rules::getDoneFlagArchiveContainsOnePlugin(
new Segment(VisitFrequencyApi::RETURNING_VISITOR_SEGMENT, $idSites = array()), 'VisitsSummary');
new Segment(VisitFrequencyApi::RETURNING_VISITOR_SEGMENT, $idSites = array()),
'VisitsSummary'
);
$idArchivesWithVisitReturningSegment = Db::fetchAll($sql, array($visitSummaryReturningSegmentDone));

// collect info for new visitssummary archives have to be created to match archives w/ *._returning
Expand Down
6 changes: 4 additions & 2 deletions core/Updates/3.0.0-b1.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,10 @@ private function getSiteSettingsMigrations($queries)
));

$table = Common::prefixTable($table);
$queries[] = $this->migration->db->sql("ALTER TABLE `$table` ADD INDEX(idsite, plugin_name);",
Migration\Db::ERROR_CODE_COLUMN_NOT_EXISTS);
$queries[] = $this->migration->db->sql(
"ALTER TABLE `$table` ADD INDEX(idsite, plugin_name);",
Migration\Db::ERROR_CODE_COLUMN_NOT_EXISTS
);

return $queries;
}
Expand Down
12 changes: 8 additions & 4 deletions core/Updates/3.13.1-b2.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,14 @@ public function getMigrations(Updater $updater)
{
$geoIpLiteUrl = 'https://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz';
$optionTable = Common::prefixTable('option');
$migration1 = $this->migration->db->boundSql("UPDATE `$optionTable` SET option_value = ? WHERE option_name = ? AND option_value = ?",
[GeoIp2::getDbIpLiteUrl(), GeoIP2AutoUpdater::LOC_URL_OPTION_NAME, $geoIpLiteUrl]);
$migration2 = $this->migration->db->boundSql("UPDATE `$optionTable` SET option_value = ? WHERE option_name = ? AND option_value = ?",
[GeoIp2::getDbIpLiteUrl('country'), GeoIP2AutoUpdater::LOC_URL_OPTION_NAME, self::GEO_LITE_COUNTRY_URL]);
$migration1 = $this->migration->db->boundSql(
"UPDATE `$optionTable` SET option_value = ? WHERE option_name = ? AND option_value = ?",
[GeoIp2::getDbIpLiteUrl(), GeoIP2AutoUpdater::LOC_URL_OPTION_NAME, $geoIpLiteUrl]
);
$migration2 = $this->migration->db->boundSql(
"UPDATE `$optionTable` SET option_value = ? WHERE option_name = ? AND option_value = ?",
[GeoIp2::getDbIpLiteUrl('country'), GeoIP2AutoUpdater::LOC_URL_OPTION_NAME, self::GEO_LITE_COUNTRY_URL]
);
return [$migration1, $migration2];
}

Expand Down
7 changes: 5 additions & 2 deletions core/Updates/3.6.0-b2.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,11 @@ public function getMigrations(Updater $updater)
}

// changes for session auth
$migrations[] = $this->migration->db->addColumn('user', 'ts_password_modified',
'TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP');
$migrations[] = $this->migration->db->addColumn(
'user',
'ts_password_modified',
'TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP'
);

return $migrations;
}
Expand Down
6 changes: 4 additions & 2 deletions core/Updates/3.8.0-b4.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ public function __construct(MigrationFactory $factory)

public function getMigrations(Updater $updater)
{
$trackingFailureTable = $this->migration->db->createTable('tracking_failure',
$trackingFailureTable = $this->migration->db->createTable(
'tracking_failure',
array('idsite' => 'BIGINT(20) UNSIGNED NOT NULL',
'idfailure' => 'SMALLINT UNSIGNED NOT NULL',
'date_first_occurred' => 'DATETIME NOT NULL',
'request_url' => 'MEDIUMTEXT NOT NULL'),
array('idsite', 'idfailure'));
array('idsite', 'idfailure')
);

$columns = array(
'id_brute_force_log' => 'bigint(11) NOT NULL AUTO_INCREMENT',
Expand Down
4 changes: 3 additions & 1 deletion core/Updates/4.0.0-rc4.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ public function getMigrations(Updater $updater)

if (DbHelper::tableExists($blobTable) && DbHelper::tableExists($numericTable)) {
$migrations[] = $this->migration->db->sql(
"DELETE FROM `$blobTable` WHERE idarchive NOT IN (SELECT idarchive FROM `$numericTable`)", []);
"DELETE FROM `$blobTable` WHERE idarchive NOT IN (SELECT idarchive FROM `$numericTable`)",
[]
);
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions core/Updates/4.7.0-b2.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ public function getMigrations(Updater $updater)
$migrations = [];

// add column to track the last change a user viewed the changes list
$migrations[] = $this->migration->db->addColumn('user', 'idchange_last_viewed',
'INTEGER UNSIGNED NULL');
$migrations[] = $this->migration->db->addColumn(
'user',
'idchange_last_viewed',
'INTEGER UNSIGNED NULL'
);

$migrations[] = $this->migration->db->createTable('changes', array(
'idchange' => 'INT(11) NOT NULL AUTO_INCREMENT',
Expand Down
3 changes: 2 additions & 1 deletion core/Updates/5.0.0-b1.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ private function appendLogVisitTableMigrations($migrations)
// already existing index has the correct fields. Try renaming, but ignore syntax error thrown if rename command does not exist
$migrations[] = $this->migration->db->sql(
"ALTER TABLE `{$this->tableName}` RENAME INDEX `{$this->indexName}` TO `{$this->newIndexName}`",
[DbAlias::ERROR_CODE_SYNTAX_ERROR]);
[DbAlias::ERROR_CODE_SYNTAX_ERROR]
);
}

// create the new index if it does not yet exist and drop the old one
Expand Down
3 changes: 2 additions & 1 deletion core/UrlHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ public static function getLossyUrl($url)
'.{}$4',
'$1{}.',
),
$url);
$url
);
}

/**
Expand Down
Loading

0 comments on commit bdb37ef

Please sign in to comment.