Applied required changes to install and use PHP 5.6 for testing the Zammad PHP API client - until @jepf adds PHP 7 support (for tests).

This commit is contained in:
Thorsten Eckel 2019-06-27 20:26:28 +02:00
parent 29f96527a7
commit 83c77a4a35
26 changed files with 264 additions and 265 deletions

View file

@ -11,7 +11,7 @@ jobs:
install-mysql:
docker:
- image: circleci/ruby:2.4.4
- image: circleci/ruby:2.5.5
- image: circleci/mysql:5.7-ram
command: --max_allowed_packet=64MB
environment:
@ -28,7 +28,7 @@ jobs:
install-postgresql:
docker:
- image: circleci/ruby:2.4.4
- image: circleci/ruby:2.5.5
- image: circleci/postgres:11-ram
environment:
POSTGRES_DB: zammad_test

View file

@ -1,4 +1,4 @@
image: registry.znuny.com/docker/zammad-ruby:2.4.4
image: registry.znuny.com/docker/zammad-ruby:2.5.5
# Global variables added to the ENV of each job
variables:
@ -61,7 +61,7 @@ variables:
# Cache gems in between jobs and pipelines
cache:
key: "ruby24"
key: "ruby25"
paths:
- vendor/ruby

View file

@ -1 +1 @@
2.4.4
2.5.5

View file

@ -1,7 +1,7 @@
source 'https://rubygems.org'
# core - base
ruby '2.4.4'
ruby '2.5.5'
gem 'rails', '5.1.7'
# core - rails additions

View file

@ -641,7 +641,7 @@ DEPENDENCIES
zendesk_api
RUBY VERSION
ruby 2.4.4p296
ruby 2.5.5p157
BUNDLED WITH
1.17.3

View file

@ -10,7 +10,7 @@ class Integration::LdapController < ApplicationController
def discover
answer_with do
begin
ldap = ::Ldap.new(params)
{
@ -22,7 +22,7 @@ class Integration::LdapController < ApplicationController
# return empty result
{}
end
end
end

View file

@ -250,7 +250,7 @@ class ReportsController < ApplicationController
row = 2
result[:ticket_ids].each do |ticket_id|
begin
ticket = Ticket.lookup(id: ticket_id)
row += 1
worksheet.write_string(row, 0, ticket.number)
@ -295,7 +295,7 @@ class ReportsController < ApplicationController
end
rescue => e
Rails.logger.error "SKIP: #{e.message}"
end
end
row += 2

View file

@ -188,7 +188,7 @@ stream all accounts
# start threads for each channel
@@channel_stream[channel_id][:thread] = Thread.new do
begin
logger.info "Started stream channel for '#{channel.id}' (#{channel.area})..."
channel.status_in = 'ok'
channel.last_log_in = ''
@ -210,7 +210,7 @@ stream all accounts
channel.save!
@@channel_stream.delete(channel_id)
@@channel_stream_started_till_at[channel_id] = Time.zone.now
end
end
end

View file

@ -127,11 +127,11 @@ example
message_ids = nil
timeout(6.minutes) do
begin
message_ids = @imap.sort(['DATE'], filter, 'US-ASCII')
rescue
message_ids = @imap.search(filter)
end
end
# check mode only

View file

@ -586,14 +586,14 @@ process unprocessable_mails (tmp/unprocessable_mail/*.eml) again
end
mail.parts.each do |part|
begin
new_attachments = get_attachments(part, attachments, mail).flatten.compact
attachments.push(*new_attachments)
rescue => e # Protect process to work with spam emails (see test/fixtures/mail15.box)
raise e if (fail_count ||= 0).positive?
(fail_count += 1) && retry
end
end
attachments
@ -608,7 +608,7 @@ process unprocessable_mails (tmp/unprocessable_mail/*.eml) again
file.header.fields.each do |field|
# full line, encode, ready for storage
begin
value = field.to_utf8
if value.blank?
value = field.raw_value
@ -616,7 +616,7 @@ process unprocessable_mails (tmp/unprocessable_mail/*.eml) again
headers_store[field.name.to_s] = value
rescue => e
headers_store[field.name.to_s] = field.raw_value
end
end
# cleanup content id, <> will be added automatically later

View file

@ -12,7 +12,7 @@ module Channel::Filter::Database
all_matches_ok = true
min_one_rule_exists = false
filter[:match].each do |key, meta|
begin
next if meta.blank? || meta['value'].blank?
value = mail[ key.downcase.to_sym ]
@ -37,7 +37,7 @@ module Channel::Filter::Database
all_matches_ok = false
Rails.logger.error "can't use match rule #{match_rule} on #{value}"
Rails.logger.error e.inspect
end
end
next if !min_one_rule_exists

View file

@ -69,6 +69,7 @@ class Store::Provider::File
local_location = locations[0, count].join('/')
break if local_location.match?(%r{storage/fs/{0,4}$})
break if Dir["#{local_location}/*"].present?
next if !Dir.exist?(local_location)
FileUtils.rmdir(local_location)
end

View file

@ -444,7 +444,7 @@ get count of tickets and tickets which match on selector
return [] if !query
ActiveRecord::Base.transaction(requires_new: true) do
begin
if !current_user
ticket_count = Ticket.distinct.where(query, *bind_params).joins(tables).count
tickets = Ticket.distinct.where(query, *bind_params).joins(tables).limit(limit)
@ -459,7 +459,7 @@ get count of tickets and tickets which match on selector
rescue ActiveRecord::StatementInvalid => e
Rails.logger.error e
raise ActiveRecord::Rollback
end
end
[]
end

View file

@ -5,7 +5,7 @@ class TriggerRecipientUpdate < ActiveRecord::Migration[4.2]
return if !Setting.find_by(name: 'system_init_done')
['auto reply (on new tickets)', 'auto reply (on follow up of tickets)'].each do |name|
begin
trigger = Trigger.find_by(name: name)
next if trigger.blank?
next if trigger.perform.blank?
@ -17,7 +17,7 @@ class TriggerRecipientUpdate < ActiveRecord::Migration[4.2]
trigger.save!
rescue => e
Rails.logger.error "Unable to update Trigger.find(#{trigger.id}) '#{trigger.inspect}': #{e.message}"
end
end
end

View file

@ -220,11 +220,11 @@ class ForeignKeys < ActiveRecord::Migration[4.2]
foreign_keys.each do |foreign_key|
ActiveRecord::Base.transaction do
begin
add_foreign_key(*foreign_key)
rescue => e
Rails.logger.error "Inconsistent data status detected while adding foreign key '#{foreign_key.inspect}': #{e.message}"
end
end
end
end

View file

@ -5,11 +5,11 @@ class AgendBasedSenderIssue1351 < ActiveRecord::Migration[4.2]
return if !Setting.find_by(name: 'system_init_done')
EmailAddress.all.each do |email_address|
begin
email_address.save!
rescue => e
Rails.logger.error "Unable to update EmailAddress.find(#{email_address.id}) '#{email_address.inspect}': #{e.message}"
end
end
end
end

View file

@ -7,11 +7,11 @@ class FixedStoreUpgradeRor45 < ActiveRecord::Migration[5.0]
Cache.clear
[Macro, Taskbar, Calendar, Trigger, Channel, Job, PostmasterFilter, Report::Profile, Setting, Sla, Template].each do |class_name|
class_name.all.each do |record|
begin
record.save!
rescue => e
Rails.logger.error "Unable to save/update #{class_name}.find(#{record.id}): #{e.message}"
end
end
end

View file

@ -24,13 +24,13 @@ class Issue1977RemoveInvalidUserForeignKeys < ActiveRecord::Migration[5.1]
]
foreign_keys.each do |args|
begin
add_foreign_key(*args)
rescue ActiveRecord::StatementInvalid => e
Rails.logger.info "Can't add foreign_keys '#{args.inspect}'"
Rails.logger.info e
ActiveRecord::Base.connection.reconnect!
end
end
end
end

View file

@ -444,14 +444,14 @@ class String
#map['word-en-de'] = "[^#{marker}].{1,250}\s(wrote|schrieb):"
map.each_value do |regexp|
begin
string.sub!(/#{regexp}/) do |placeholder|
placeholder = "#{marker}#{placeholder}"
end
rescue
# regexp was not possible because of some string encoding issue, use next
Rails.logger.debug { "Invalid string/charset combination with regexp #{regexp} in string" }
end
end
string
@ -494,11 +494,11 @@ class String
# try to find valid encodings of string
viable_encodings.each do |enc|
begin
return encode!('utf-8', enc)
rescue EncodingError => e
Rails.logger.error { e.inspect }
end
end
case options[:fallback]

View file

@ -14,7 +14,6 @@ class Sequencer
ews_folder_ids.collect do |folder_id|
begin
ews_folder.find(folder_id).items.each do |resource|
attributes = ::Import::Exchange::ItemAttributes.extract(resource)
extractor.extract(attributes)
@ -25,7 +24,7 @@ class Sequencer
logger.error e
logger.error "Skipping folder_id '#{folder_id}' due to unsupported entries."
end
end
end.examples
end

View file

@ -10,14 +10,13 @@ namespace :zammad do
# there is no way in rake to achive that
%w[db:drop:_unsafe db:create db:schema:load db:seed].each do |task|
begin
$stdout = StringIO.new if task == 'db:schema:load'.freeze
Rake::Task[task].reenable
Rake::Task[task].invoke
ensure
$stdout = STDOUT
end
end
ActiveRecord::Base.connection.reconnect!

View file

@ -294,7 +294,7 @@ returns
end
if title == '-'
%i[sticker photo document voice].each do |area|
begin
next if !params[:message]
next if !params[:message][area]
next if !params[:message][area][:emoji]
@ -304,7 +304,7 @@ returns
rescue
# just go ahead
title
end
end
end
if title.length > 60

View file

@ -25,14 +25,14 @@ RSpec.describe NotificationFactory do
let(:template_path) { Rails.root.to_s + "/app/views/mailer/signup/#{rendered_locale}.html.erb.custom" }
it 'uses that file' do
begin
File.write(template_path, "Subject\nBody\nbody\n")
expect(described_class.template_read(read_params))
.to eq({ subject: "Subject\n", body: "Body\nbody\n" })
ensure
File.delete(template_path)
end
end
end

View file

@ -27,7 +27,7 @@ describe 'websocket-server', type: :script do
end
it 'starts up successfully' do
begin
system("RAILS_ENV=test #{ws_server} start -db #{ipv6_addr} -p #{port} >/dev/null 2>&1")
# Wait for daemon to start
@ -38,7 +38,7 @@ describe 'websocket-server', type: :script do
expect(File.read(error_log)).not_to include(error_msg)
ensure
system("#{ws_server} stop >/dev/null 2>&1") if File.exist?(pidfile)
end
end
end
end

View file

@ -38,10 +38,10 @@ module BrowserTestHelper
#
def until_exists
self.until do
begin
yield
rescue Capybara::ElementNotFound # rubocop:disable Lint/HandleExceptions
end
end
rescue Selenium::WebDriver::Error::TimeOutError => e
# cleanup backtrace

View file

@ -105,14 +105,14 @@ class TestCase < ActiveSupport::TestCase
# avoid "Cannot read property 'get_Current' of undefined" issues
(1..5).each do |count|
begin
local_browser = browser_instance_remote
break
rescue => e
wait_until_ready = rand(5..13)
log('browser_instance', { rescure: true, count: count, sleep: wait_until_ready, exception: e })
sleep wait_until_ready
end
end
local_browser
@ -1579,7 +1579,7 @@ wait untill text in selector disabppears
99.times do
#sleep 0.5
begin
if instance.find_elements(css: '#navigation .tasks .task:first-child')[0]
instance.action.move_to(instance.find_elements(css: '#navigation .tasks .task:first-child')[0]).release.perform
click_element = instance.find_elements(css: '#navigation .tasks .task:first-child .js-close')[0]
@ -1597,7 +1597,7 @@ wait untill text in selector disabppears
end
rescue
# try again
end
end
assert(true, 'all tasks closed')
end
@ -1790,13 +1790,13 @@ wait untill text in selector disabppears
if data[:roles]
99.times do
begin
element = instance.find_elements(css: '.modal .js-selected[data-name=role_ids] .js-option:not(.is-hidden)')[0]
break if !element
element.click
sleep 0.1
end
end
data[:roles].each do |role|
instance.execute_script("$(\".modal [data-name=role_ids] .js-pool .js-option:not(.is-hidden):contains('#{role}')\").first().click()")
@ -1945,13 +1945,13 @@ wait untill text in selector disabppears
end
if data[:roles]
99.times do
begin
element = instance.find_elements(css: '.modal .js-selected[data-name=role_ids] .js-option:not(.is-hidden)')[0]
break if !element
element.click
sleep 0.1
end
end
data[:roles].each do |role|
instance.execute_script("$(\".modal [data-name=role_ids] .js-pool .js-option:not(.is-hidden):contains('#{role}')\").first().click()")