Skip to content

Commit

Permalink
Merge pull request #105 from OPUS4/4.8
Browse files Browse the repository at this point in the history
Release 4.8
  • Loading branch information
j3nsch authored Apr 24, 2023
2 parents da67f0c + e6bcfc5 commit 89417a5
Show file tree
Hide file tree
Showing 51 changed files with 536 additions and 527 deletions.
41 changes: 24 additions & 17 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,24 @@ on:
jobs:
build:

runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

strategy:
matrix:
php-versions: ['8.1']

name: PHP ${{ matrix.php-versions }} Test

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Setup PHP 7.1
- name: Setup PHP ${{ matrix.php-versions }}
uses: shivammathur/setup-php@v2
with:
php-version: '7.1'
php-version: ${{ matrix.php-versions }}

- name: Check PHP Version
run: php -v

- name: Install Composer and Dependencies
run: sudo apt-get update && curl -s http://getcomposer.org/installer | php && php composer.phar self-update && php composer.phar install
Expand All @@ -31,22 +40,20 @@ jobs:
- name: Start MySQL
run: sudo systemctl start mysql.service

- name: Prepare workspace
run: ant prepare-workspace

- name: Prepare search config
run: ant prepare-config

- name: Prepare database
run: bash vendor/opus4-repo/framework/bin/prepare-database.sh --admin_pwd root --user_pwd root
run: bash vendor/bin/opus4db --adminpwd root --userpwd root --sqlpwd root

- name: Prepare
run: |
ant prepare-workspace prepare-config lint -DdbUserPassword=root -DdbAdminPassword=root
export APPLICATION_PATH=. && php vendor/opus4-repo/framework/db/createdb.php
- name: Basic PHP file check
run: ant lint

- name: Test
- name: Tests
run: php composer.phar test

- name: Coding-Style
- name: Coding Style
run: php composer.phar cs-check

- name: PHP-LOC
run: php composer.phar phploc

- name: PHP CPD
run: php composer.phar phpcpd
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
build
test/config.ini
cache.properties
/database.ini

# IDE files
.idea
Expand All @@ -16,3 +17,4 @@ vendor

# Vagrant files
.vagrant
.phpunit.result.cache
32 changes: 15 additions & 17 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@
# vi: set ft=ruby :

$software = <<SCRIPT
# Downgrade to PHP 7.1
# Downgrade to PHP 8.1
apt-add-repository -y ppa:ondrej/php
apt-get -yq update
apt-get -yq install php7.1
apt-get -yq install php8.1
# Install MYSQL
debconf-set-selections <<< "mysql-server mysql-server/root_password password root"
debconf-set-selections <<< "mysql-server mysql-server/root_password_again password root"
apt-get -yq install mysql-server
# Install required PHP packages
apt-get -yq install php7.1-dom
apt-get -yq install php7.1-mbstring
apt-get -yq install php7.1-intl
apt-get -yq install php7.1-gd
apt-get -yq install php7.1-mcrypt
apt-get -yq install php7.1-curl
apt-get -yq install php7.1-zip
apt-get -yq install php7.1-mysql
apt-get -yq install php8.1-dom
apt-get -yq install php8.1-mbstring
apt-get -yq install php8.1-intl
apt-get -yq install php8.1-gd
apt-get -yq install php8.1-mcrypt
apt-get -yq install php8.1-curl
apt-get -yq install php8.1-zip
apt-get -yq install php8.1-mysql
# Install Java
apt-get -yq install openjdk-11-jdk
Expand Down Expand Up @@ -58,14 +58,12 @@ fi
SCRIPT

$database = <<SCRIPT
/vagrant/vendor/opus4-repo/framework/bin/prepare-database.sh --admin_pwd root --user_pwd root
/vagrant/vendor/bin/opus4db --adminpwd root --userpwd root --sqlpwd root
SCRIPT

$opus = <<SCRIPT
$workspace = <<SCRIPT
cd /vagrant
ant prepare-workspace prepare-config -DdbUserPassword=root -DdbAdminPassword=root
export APPLICATION_PATH=/vagrant
php vendor/opus4-repo/framework/db/createdb.php
ant prepare-workspace prepare-config
SCRIPT

$environment = <<SCRIPT
Expand Down Expand Up @@ -101,16 +99,16 @@ echo " http://localhost:9983"
SCRIPT

Vagrant.configure("2") do |config|
config.vm.box = "bento/ubuntu-20.04"
config.vm.box = "bento/ubuntu-22.04"

config.vm.network "forwarded_port", guest: 8983, host: 9983, host_ip: "127.0.0.1"

config.vm.provision "Install required software...", type: "shell", inline: $software
config.vm.provision "Install Apache Solr...", type: "shell", privileged: false, inline: $solr
config.vm.provision "Setup environment...", type: "shell", inline: $environment
config.vm.provision "Install Composer dependencies...", type: "shell", privileged: false, inline: $composer
config.vm.provision "Prepare workspace...", type: "shell", privileged: false, inline: $workspace
config.vm.provision "Create database...", type: "shell", inline: $database
config.vm.provision "Configure OPUS 4...", type: "shell", privileged: false, inline: $opus
config.vm.provision "Start services...", type: "shell", privileged: false, run: "always", inline: $start
config.vm.provision "Information", type: "shell", privileged: false, run: "always", inline: $help
end
29 changes: 4 additions & 25 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,14 @@
<project name="opus4search">

<property environment="env" />
<property name="bindir" value="${basedir}/vendor/bin" />
<property name="solrVersion" value="7.7.1" />
<property name="downloadDir" value="${basedir}/downloads" />

<!-- Properties for configuration files (tests/config.ini) used for testing. -->
<property name="dbName" value="opusdb" />
<property name="dbUserName" value="opus4" />
<property name="dbUserPassword" value="" />
<property name="dbAdminName" value="opus4admin" />
<property name="dbAdminPassword" value="" />
<property name="solrDefaultHost" value="localhost" />
<property name="solrDefaultPort" value="8983" />
<property name="solrDefaultPath" value="/solr/opus4" />
<property name="solrIndexHost" value="localhost" />
<property name="solrIndexPort" value="8983" />
<property name="solrIndexPath" value="/solr/opus4" />
<property name="solrExtractHost" value="localhost" />
<property name="solrExtractPort" value="8983" />
<property name="solrExtractPath" value="/solr/opus4" />
<property name="solrIndexPath" value="/" />
<property name="solrIndexCore" value="opus4" />

<target name="clean">
<delete dir="${basedir}/build/logs" />
Expand Down Expand Up @@ -50,20 +39,10 @@
<copy file="${basedir}/test/config.ini.template" toFile="${basedir}/test/config.ini" filtering="true"
overwrite="true">
<filterset>
<filter token="db.user.name" value="${dbUserName}" />
<filter token="db.user.password" value="${dbUserPassword}" />
<filter token="db.admin.name" value="${dbAdminName}" />
<filter token="db.admin.password" value="${dbAdminPassword}" />
<filter token="db.name" value="${dbName}" />
<filter token="searchengine.default.host" value="${solrDefaultHost}" />
<filter token="searchengine.default.port" value="${solrDefaultPort}" />
<filter token="searchengine.default.path" value="${solrDefaultPath}" />
<filter token="searchengine.index.host" value="${solrIndexHost}" />
<filter token="searchengine.index.port" value="${solrIndexPort}" />
<filter token="searchengine.index.app" value="${solrIndexPath}" />
<filter token="searchengine.extract.host" value="${solrExtractHost}" />
<filter token="searchengine.extract.port" value="${solrExtractPort}" />
<filter token="searchengine.extract.app" value="${solrExtractPath}" />
<filter token="searchengine.index.path" value="${solrIndexPath}" />
<filter token="searchengine.index.core" value="${solrIndexCore}" />
</filterset>
</copy>
</target>
Expand Down
18 changes: 10 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,23 @@
],
"homepage": "http://www.opus-repository.org",
"require": {
"php": ">=7.1",
"php": ">=8",
"ext-xsl": "*",
"ext-dom": "*",
"ext-iconv": "*",
"ext-simplexml": "*",
"ext-mbstring": "*",
"solarium/solarium": "3.8.*",
"opus4-repo/framework": "dev-master",
"opus4-repo/opus4-common": "dev-master",
"zendframework/zendframework1": "1.12.*",
"solarium/solarium": "6.*",
"symfony/event-dispatcher": "*",
"opus4-repo/framework": "^4.8",
"opus4-repo/opus4-common": "^4.8",
"opus4-repo/opus4-job": "^4.8",
"opus4/zf1-future": "1.21.*",
"symfony/console": "*"
},
"require-dev": {
"phpunit/phpunit": "6.*",
"laminas/laminas-coding-standard": "<2.3",
"phpunit/phpunit": "<9",
"opus4-repo/codesniffer": "dev-laminas",
"phpmd/phpmd": "@stable",
"phploc/phploc": "@stable",
"sebastian/phpcpd": "*",
Expand Down Expand Up @@ -67,7 +69,7 @@
"phpunit --colors=always --log-junit build/phpunit.xml"
],
"test-coverage": "phpunit --log-junit build/phpunit.xml --colors=always --coverage-html build/ --coverage-clover build/clover.xml",
"cs-check": "phpcs -n",
"cs-check": "phpcs -n -p",
"cs-check-report": "phpcs -n --report=checkstyle --report-file=build/checkstyle.xml",
"cs-fix": "phpcbf -v",
"phpmd": "phpmd src xml cleancode,unusedcode,design,naming --reportfile build/phpmd.xml --ignore-violations-on-exit",
Expand Down
2 changes: 1 addition & 1 deletion phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<ruleset name="OPUS 4 coding standard">
<rule ref="./vendor/laminas/laminas-coding-standard/src/LaminasCodingStandard/ruleset.xml" />
<rule ref="./vendor/opus4-repo/codesniffer/src/ruleset.xml" />
<file>src</file>
<file>test</file>
</ruleset>
7 changes: 4 additions & 3 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* along with OPUS; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* @copyright Copyright (c) 2009-2022, OPUS 4 development team
* @copyright Copyright (c) 2009, OPUS 4 development team
* @license http://www.gnu.org/licenses/gpl.html General Public License
*/

Expand Down Expand Up @@ -75,6 +75,7 @@
*/
class Config
{
/** @var array */
protected static $configurationsPool = [];

/**
Expand Down Expand Up @@ -215,7 +216,7 @@ public static function getServiceConfiguration($serviceType, $serviceName = null

// finally adopt all basically deprecated service-related configuration
// (old-style options are thus always preferred over any new-style ones)
$result = static::mergeWithDeprecatedServiceConfiguration($result, $serviceType);
// TODO Solarium $result = static::mergeWithDeprecatedServiceConfiguration($result, $serviceType);

$result->setReadOnly();

Expand Down Expand Up @@ -364,7 +365,7 @@ public static function getFacetNames($facetSetName = null, $serviceDomain = null
}

if ($config && is_scalar($config)) {
$set = preg_split('/[\s,]+/', trim($config), null, PREG_SPLIT_NO_EMPTY);
$set = preg_split('/[\s,]+/', trim($config), 0, PREG_SPLIT_NO_EMPTY);
} else {
$set = [];
}
Expand Down
7 changes: 5 additions & 2 deletions src/Console/ExtractCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

namespace Opus\Search\Console;

use Opus\Common\Console\AbstractBaseDocumentCommand;
use Opus\Common\Console\AbstractDocumentCommand;
use Opus\Search\Console\Helper\IndexHelper;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
Expand All @@ -42,14 +42,17 @@
* TODO use some kind of helper instead of base class?
* TODO need to have a way to access/check cache (perhaps another command)
*/
class ExtractCommand extends AbstractBaseDocumentCommand
class ExtractCommand extends AbstractDocumentCommand
{
const OPTION_TIMEOUT = 'timeout';

/** @var string */
protected static $defaultName = 'index:extract';

/** @var string */
protected $startIdDescription = 'ID of document where extraction should start (or \'-\')';

/** @var string */
protected $endIdDescription = 'ID of document where extraction should stop (or \'-\')';

protected function configure()
Expand Down
7 changes: 7 additions & 0 deletions src/Console/ExtractFileCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class ExtractFileCommand extends Command

const OPTION_TIMEOUT = 'timeout';

/** @var string */
protected static $defaultName = 'tools:extract-file';

protected function configure()
Expand Down Expand Up @@ -95,6 +96,10 @@ protected function configure()
);
}

/**
* @return int
* @throws SearchException
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$file = $input->getArgument(self::ARGUMENT_FILE);
Expand Down Expand Up @@ -133,5 +138,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
} else {
$output->writeln($text);
}

return 0;
}
}
7 changes: 6 additions & 1 deletion src/Console/Helper/DocumentHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,21 @@ class DocumentHelper
*
* @param int $start Start of ID range
* @param int $end End of ID range
* @param int $colId
* @return array Array of document IDs
*
* TODO move somewhere else, not Index specific functionality
*/
public function getDocumentIds($start, $end)
public function getDocumentIds($start, $end, $colId = 0)
{
$finder = Repository::getInstance()->getDocumentFinder();

$finder->setDocumentIdRange($start, $end);

if ($colId > 0) {
$finder->setCollectionId($colId);
}

return $finder->getIds();
}
}
Loading

0 comments on commit 89417a5

Please sign in to comment.