Skip to content
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

Change version to 6.0.alpha1 #31763

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CRM/Core/I18n/SchemaStructure.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static function &columns() {
if (!$result) {
$result = [];
global $civicrm_root;
$sqlGenerator = require "$civicrm_root/mixin/lib/civimix-schema/src/SqlGenerator.php";
$sqlGenerator = require "$civicrm_root/mixin/lib/civimix-schema@5/src/SqlGenerator.php";
foreach (\Civi\Schema\EntityRepository::getEntities() as $entity) {
if (empty($entity['getFields'])) {
continue;
Expand Down
2 changes: 1 addition & 1 deletion CRM/Upgrade/Incremental/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ public static function checkFKExists($table_name, $constraint_name) {
public static function alterSchemaField($ctx, string $entityName, string $fieldName, array $fieldSpec): bool {
$tableName = Civi::entity($entityName)->getMeta('table');
global $civicrm_root;
$sqlGenerator = require "$civicrm_root/mixin/lib/civimix-schema/src/SqlGenerator.php";
$sqlGenerator = require "$civicrm_root/mixin/lib/civimix-schema@5/src/SqlGenerator.php";
$fieldSql = $sqlGenerator::generateFieldSql($fieldSpec);
if (CRM_Core_BAO_SchemaHandler::checkIfFieldExists($tableName, $fieldName, FALSE)) {
return self::alterColumn($ctx, $tableName, $fieldName, $fieldSql, !empty($fieldSpec['localizable']));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@
*/

/**
* Upgrade logic for the 5.83.x series.
* Upgrade logic for the 6.0.x series.
*
* Each minor version in the series is handled by either a `5.83.x.mysql.tpl` file,
* or a function in this class named `upgrade_5_83_x`.
* Each minor version in the series is handled by either a `6.0.x.mysql.tpl` file,
* or a function in this class named `upgrade_6_0_x`.
* If only a .tpl file exists for a version, it will be run automatically.
* If the function exists, it must explicitly add the 'runSql' task if there is a corresponding .mysql.tpl.
*
* This class may also implement `setPreUpgradeMessage()` and `setPostUpgradeMessage()` functions.
*/
class CRM_Upgrade_Incremental_php_FiveEightyThree extends CRM_Upgrade_Incremental_Base {
class CRM_Upgrade_Incremental_php_SixZero extends CRM_Upgrade_Incremental_Base {

/**
* Upgrade step; adds tasks including 'runSql'.
*
* @param string $rev
* The version number matching this function name
*/
public function upgrade_5_83_alpha1($rev): void {
public function upgrade_6_0_alpha1($rev): void {
$this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev);
}

Expand Down
1 change: 0 additions & 1 deletion CRM/Upgrade/Incremental/sql/5.83.alpha1.mysql.tpl

This file was deleted.

1 change: 1 addition & 0 deletions CRM/Upgrade/Incremental/sql/6.0.alpha1.mysql.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{* file to handle db changes in 6.0.alpha1 during upgrade *}
2 changes: 1 addition & 1 deletion js/version.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"5.83.alpha1"
"6.0.alpha1"
20 changes: 14 additions & 6 deletions mixin/lib/pathload.index.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,19 @@
//
// pathload()->addSearchDir(__DIR__ . '/lib');
//
// However, that would detect version#'s from the filenames. In this folder,
// we want all subprojects to have the same version-number as the main
// project. It would be quite inconvenient to rename them every month.
// However, that would detect version#'s from the filenames. While that
// convention is handy for downstreams (using backports), it can be annoying
// here (as canonical source). It would be inconvenient to have to rename
// the canonical files/folders whenever we make an edit.
//
// So instead, we use `addSearchItem()` and register with explicit versions.
// `addSearchItem()` allows us to register with a programmatic
// version-number -- so we don't have to manually set the number.

$version = \CRM_Utils_System::version() . '.1'; /* Higher priority than contrib copies of same version... */
\pathload()->addSearchItem('civimix-schema', $version, __DIR__ . '/civimix-schema');
$version6 = \CRM_Utils_System::version() . '.1'; /* Higher priority than contrib copies of same version... */
$version5 = preg_replace_callback(';^6\.(\d+)\.;', function ($m) {
/* [email protected]=>6.0 was purely superficial (to match core#)s. Continue 5.x option for compat. */
return '5.' . (83 + $m[1]) . '.';
}, $version6);

// Register [email protected]
\pathload()->addSearchItem('civimix-schema@5', $version5, __DIR__ . '/civimix-schema');
2 changes: 1 addition & 1 deletion sql/civicrm_generated.mysql
Original file line number Diff line number Diff line change
Expand Up @@ -2960,7 +2960,7 @@ UNLOCK TABLES;
LOCK TABLES `civicrm_domain` WRITE;
/*!40000 ALTER TABLE `civicrm_domain` DISABLE KEYS */;
INSERT INTO `civicrm_domain` (`id`, `name`, `description`, `version`, `contact_id`, `locales`, `locale_custom_strings`) VALUES
(1,'Default Domain Name',NULL,'5.83.alpha1',1,NULL,'a:1:{s:5:\"en_US\";a:0:{}}');
(1,'Default Domain Name',NULL,'6.0.alpha1',1,NULL,'a:1:{s:5:\"en_US\";a:0:{}}');
/*!40000 ALTER TABLE `civicrm_domain` ENABLE KEYS */;
UNLOCK TABLES;

Expand Down
2 changes: 1 addition & 1 deletion sql/test_data_second_domain.mysql
Original file line number Diff line number Diff line change
Expand Up @@ -907,4 +907,4 @@ INSERT INTO civicrm_navigation
VALUES
( @domainID, CONCAT('civicrm/report/instance/', @instanceID,'&reset=1'), 'Mailing Detail Report', 'Mailing Detail Report', 'administer CiviMail', 'OR', @reportlastID, '1', NULL, @instanceID+2 );
UPDATE civicrm_report_instance SET navigation_id = LAST_INSERT_ID() WHERE id = @instanceID;
UPDATE civicrm_domain SET version = '5.83.alpha1';
UPDATE civicrm_domain SET version = '6.0.alpha1';
136 changes: 81 additions & 55 deletions tools/mixin/bin/build-lib
Original file line number Diff line number Diff line change
@@ -1,70 +1,96 @@
#!/usr/bin/env bash

#!/usr/bin/env php
<?php

## Take the contents of 'mixin/lib/' and export reusable library files.

###############################################################################
## Bootstrap

## Determine the absolute path of the directory with the file
## usage: absdirname <file-path>
function absdirname() {
pushd $(dirname $0) >> /dev/null
pwd
popd >> /dev/null
}

BINDIR=$(absdirname "$0")
set -e

###############################################################################

function getCiviVer() {
pushd "$1" >> /dev/null
if [ -f xml/version.xml ]; then
## Works in any git-based build, even if gencode hasn't run yet.
php -r 'echo simplexml_load_file("xml/version.xml")->version_no;'
else
## works in any tar-based build.
php -r 'require "civicrm-version.php"; $a = civicrmVersion(); echo $a["version"];'
fi
popd >> /dev/null
/**
* Get the CiviCRM version from the specified directory.
*
* @param string $directory
* @return string|null
*/
function getCiviVer(string $directory): ?string {
$version = NULL;

if (file_exists($directory . '/xml/version.xml')) {
$version = simplexml_load_file($directory . '/xml/version.xml')->version_no;
}
elseif (file_exists($directory . '/civicrm-version.php')) {
require $directory . '/civicrm-version.php';
$versionArray = civicrmVersion();
$version = $versionArray['version'] ?? NULL;
}

return $version;
}

/**
* Execute a PHAR command.
*
* @param string $command
* @return void
*/
function executePhar(string $pwd, string $command): void {
$cmd = 'cd ' . escapeshellarg($pwd) . ' && ';
$cmd .= "php -d phar.readonly=0 `which phar` $command";
// echo "$cmd\n";

passthru($cmd, $result);
if ($result !== 0) {
throw new \RuntimeException("Failed to execute command: $cmd");
}
}

function PHAR() {
php -d phar.readonly=0 `which phar` "$@"
/**
* Take a source folder and generate a PHAR.
*
* @param string $src
* @param string $outputPhar
* @return void
*/
function buildLib(string $src, string $outputPhar): void {
echo "\n====================================\n";
echo "Read $src\n";
echo "Create $outputPhar\n";
echo "\n";

if (file_exists($outputPhar)) {
unlink($outputPhar);
}

$stubFile = escapeshellarg("$GLOBALS[toolMix]/src/empty-stub.php");
$outputPhar = escapeshellarg($outputPhar);
executePhar($src, "pack -f $outputPhar -s $stubFile -i '.php$' .");

// Or for concatenated PHP format:
// php "$CIVI_CORE/scripts/concat-php.php" pathload.main.php $( find src -name '*.php' ) >"$OUTPUT_PHP"
}

###############################################################################
## Setup

TOOLMIX=$(dirname "$BINDIR")
CIVI_CORE=$(dirname $(dirname "$TOOLMIX"))
OUTPUT="$1"
VERSION=$(getCiviVer "$CIVI_CORE")

if [ -z "$OUTPUT" ]; then
echo 2>&1 "usage: $0 <output-dir>"
echo 2>&1 "example: $0 /tmp/civimix"
exit 1
fi
$toolMix = dirname(__DIR__);
$civiCore = dirname(dirname($toolMix));
$output = $argv[1] ?? NULL;
$version = getCiviVer($civiCore);

if [ ! -d "$OUTPUT" ]; then
mkdir "$OUTPUT"
fi

for PACKAGE in civimix-schema ; do

SRC="${CIVI_CORE}/mixin/lib/${PACKAGE}"
OUTPUT_PHAR="${OUTPUT}/${PACKAGE}@${VERSION}.phar"
#OUTPUT_PHP="${OUTPUT}/${PACKAGE}@${VERSION}.php"

echo "Read $SRC"
echo "Create $OUTPUT_PHAR"
if (empty($output)) {
fwrite(STDERR, "usage: build-lib <output-dir>\n");
fwrite(STDERR, "example: build-lib /tmp/civimix\n");
exit(1);
}

[ -f "$OUTPUT_PHAR" ] && rm -f "$OUTPUT_PHAR" || true
#[ -f "$OUTPUT_PHP" ] && rm -f "$OUTPUT_PHP" || true
if (!is_dir($output)) {
mkdir($output, 0755, TRUE);
}

(cd "$SRC" ; PHAR pack -f "$OUTPUT_PHAR" -s "$TOOLMIX/src/empty-stub.php" -i '\.php$' . )
#php "$CIVI_CORE/scripts/concat-php.php" pathload.main.php $( find src -name '*.php' ) >"$OUTPUT_PHP"
###############################################################################
## Build rules

done
/* Tracked core version up until 5.83. After 6.0 split, this stayed on 5.x.*/
$civimixSchemaVer = preg_replace_callback(';^6\.(\d+)\.;', function ($m) {
return '5.' . (83 + $m[1]) . '.';
}, getCiviVer($civiCore));
buildLib("$civiCore/mixin/lib/civimix-schema@5", "$output/civimix-schema@$civimixSchemaVer.phar");
2 changes: 1 addition & 1 deletion xml/version.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<version>
<version_no>5.83.alpha1</version_no>
<version_no>6.0.alpha1</version_no>
<releaseDate>(unreleased)</releaseDate>
</version>