Skip to content

Commit

Permalink
Merge pull request #3873 from ushahidi/develop
Browse files Browse the repository at this point in the history
Freeze v4.4.0
  • Loading branch information
tuxpiper authored Mar 9, 2020
2 parents d4b0c37 + 8e4d6f8 commit bfe9153
Show file tree
Hide file tree
Showing 175 changed files with 2,313 additions and 1,596 deletions.
55 changes: 55 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,61 @@
"contributions": [
"code"
]
},
{
"login": "himil-vasava",
"name": "Himil Vasava",
"avatar_url": "https://avatars3.githubusercontent.com/u/55590415?v=4",
"profile": "https://github.com/himil-vasava",
"contributions": [
"code"
]
},
{
"login": "johnmurray4",
"name": "johnmurray4",
"avatar_url": "https://avatars1.githubusercontent.com/u/54542562?v=4",
"profile": "https://github.com/johnmurray4",
"contributions": [
"doc"
]
},
{
"login": "Jenniline",
"name": "Jenniline ",
"avatar_url": "https://avatars0.githubusercontent.com/u/39647995?v=4",
"profile": "https://github.com/Jenniline",
"contributions": [
"code"
]
},
{
"login": "rohit645",
"name": "Rohit Kumar",
"avatar_url": "https://avatars2.githubusercontent.com/u/33249010?v=4",
"profile": "http://rohit645.github.io",
"contributions": [
"bug",
"code"
]
},
{
"login": "ljvargh",
"name": "ljvargh",
"avatar_url": "https://avatars3.githubusercontent.com/u/47359729?v=4",
"profile": "https://github.com/ljvargh",
"contributions": [
"doc"
]
},
{
"login": "individual-it",
"name": "Artur Neumann",
"avatar_url": "https://avatars1.githubusercontent.com/u/2425577?v=4",
"profile": "https://www.jankaritech.com",
"contributions": [
"infra"
]
}
],
"projectName": "platform",
Expand Down
2 changes: 1 addition & 1 deletion .env.travis
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ DB_HOST_REPLICA=127.0.0.1
DB_PORT=3306
DB_DATABASE=ushahidi
DB_USERNAME=travis
DB_PASSWORD=
DB_PASSWORD=password

CACHE_DRIVER=array
QUEUE_DRIVER=sync
Expand Down
16 changes: 3 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,17 @@
sudo: false
dist: precise
#notifications:
# slack:
# secure: NxhzhKGYnZYZiWVZM4w1PlZpTy9bbmNlvbqjL+9d4PvK4hFzPwQU12CchhBPeXNGLWBHg/ti6Scn/t5XIS3YJrkk4ydWmJBht5UId8uFZ1A7GCUnNNPTt2RG55lbJJdZSj01rOGZjEQbE5RyckEjgRzhZjdZ+HsjoPaRzWIBrvE=
language: php
php:
- '7.0'
- '7.1'
- '7.2'
- 'nightly'
- '7.3'
env:
- coverage="--coverage"
- coverage=""
matrix:
exclude:
- php: '7.1'
- php: '7.3'
env: coverage="--coverage"
- php: '7.2'
env: coverage="--coverage"
- php: 'nightly'
env: coverage="--coverage"
allow_failures:
- env: coverage="--coverage"
- php: 'nightly'
fast_finish: true
cache:
directories:
Expand All @@ -31,6 +20,7 @@ services:
- mysql
before_install:
- mysql -e 'CREATE DATABASE ushahidi;'
- mysql -e "SET PASSWORD FOR travis@localhost = PASSWORD('password')";
- mysql -e "select version();"
- mysql -e "SET GLOBAL sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'"
- cp .env.travis .env
Expand Down
103 changes: 103 additions & 0 deletions .tx/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
; recommended pull command
;
; tx pull -a --minimum-perc 1 --mode onlytranslated
;

[main]
host = https://www.transifex.com

[ushahidi-v3-api.configphp]
file_filter = resources/lang/<lang>/config.php
source_lang = en
type = PHP_ARRAY

[ushahidi-v3-api.contactsphp]
file_filter = resources/lang/<lang>/contacts.php
source_lang = en
type = PHP_ARRAY

[ushahidi-v3-api.csvphp]
file_filter = resources/lang/<lang>/csv.php
source_lang = en
type = PHP_ARRAY

[ushahidi-v3-api.exportphp]
file_filter = resources/lang/<lang>/export.php
source_lang = en
type = PHP_ARRAY

[ushahidi-v3-api.form_attributephp]
file_filter = resources/lang/<lang>/form_attribute.php
source_lang = en
type = PHP_ARRAY

[ushahidi-v3-api.form_contactphp]
file_filter = resources/lang/<lang>/form_contact.php
source_lang = en
type = PHP_ARRAY

[ushahidi-v3-api.formphp]
file_filter = resources/lang/<lang>/form.php
source_lang = en
type = PHP_ARRAY

[ushahidi-v3-api.form_rolephp]
file_filter = resources/lang/<lang>/form_role.php
source_lang = en
type = PHP_ARRAY

[ushahidi-v3-api.hxl_metadataphp]
file_filter = resources/lang/<lang>/hxl_metadata.php
source_lang = en
type = PHP_ARRAY

[ushahidi-v3-api.layersphp]
file_filter = resources/lang/<lang>/layers.php
source_lang = en
type = PHP_ARRAY

[ushahidi-v3-api.mediaphp]
file_filter = resources/lang/<lang>/media.php
source_lang = en
type = PHP_ARRAY

[ushahidi-v3-api.messagephp]
file_filter = resources/lang/<lang>/message.php
source_lang = en
type = PHP_ARRAY

[ushahidi-v3-api.notificationsphp]
file_filter = resources/lang/<lang>/notifications.php
source_lang = en
type = PHP_ARRAY

[ushahidi-v3-api.postphp]
file_filter = resources/lang/<lang>/post.php
source_lang = en
type = PHP_ARRAY

[ushahidi-v3-api.rolephp]
file_filter = resources/lang/<lang>/role.php
source_lang = en
type = PHP_ARRAY

[ushahidi-v3-api.tagphp]
file_filter = resources/lang/<lang>/tag.php
source_lang = en
type = PHP_ARRAY

[ushahidi-v3-api.userphp]
file_filter = resources/lang/<lang>/user.php
source_lang = en
type = PHP_ARRAY

[ushahidi-v3-api.user_settingphp]
file_filter = resources/lang/<lang>/user_setting.php
source_lang = en
type = PHP_ARRAY

[ushahidi-v3-api.validationphp]
file_filter = resources/lang/<lang>/validation.php
source_lang = en
type = PHP_ARRAY

2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ushahidi/php-fpm-nginx:php-7.1
FROM ushahidi/php-fpm-nginx:php-7.2

WORKDIR /var/www
COPY composer.json ./
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/RESTController.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ protected function prepResponse(array $responsePayload = null, Request $request)
if (! in_array($request->method(), $this->cacheableMethods)) {
$response->headers->set('Cache-Control', 'no-cache, no-store, max-age=0, must-revalidate');
}

$response->headers->set('Content-language', app('translator')->getLocale());
return $response;
}
}
61 changes: 61 additions & 0 deletions app/Http/Middleware/SetLocale.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php
namespace Ushahidi\App\Http\Middleware;

use Closure;
use \Negotiation\LanguageNegotiator;

class SetLocale
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param mixed ...$features
* @return mixed
*/
public function handle($request, Closure $next, ...$features)
{
$langHeader = $request->header('Accept-language');
if ($langHeader) {
$negotiator = new LanguageNegotiator();
$priorities = config('language.locales');

/**
* NOTE: the negotiation library does not support providing a list of ordered elements in its
* stable version so defaulting to english is the best we can do right now without a more complex
* custom class. I'd rather we support the willduran/negotiation library if we go down that path.
*/
$type = $fallback = $this->getPriorityFallback($langHeader, $priorities, 'en');
/**
* TODO:
* decide if we would like to work on extending willduran/negotiation and bring
* v3.0.3 to stable so that we have getOrderedElements available if it's still
* being maintained (or I guess fork if it is no longer mantained)
*/
$bestLanguage = $negotiator->getBest($langHeader, $priorities);
if ($bestLanguage) {
$type = $bestLanguage->getType();
}
app('translator')->setLocale($type);
app('translator')->setFallback($fallback);
}

return $next($request);
}
/**
* Find a secondary language as fallback within our list of available lang codes without region
* or use the default ('en' normally) if none is available.
* When we migrate to v3 of negotiation package we can just use the orderedElements function
* and take q=0.x into account easily.
*/
private function getPriorityFallback($languageCode, $locales, $default)
{
$decision = $default;
$splitLangCode = substr($languageCode, 0, 2);
if (array_search($splitLangCode, $locales) > -1) {
$decision = $splitLangCode;
}
return $decision;
}
}
5 changes: 3 additions & 2 deletions bootstrap/lumen.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
// The exception handler class relies on this configuration to be loaded
// in order to provide CORS headers for requests that fail before the middleware stage
$app->configure('cors');

$app->configure('language');
/*
|--------------------------------------------------------------------------
| Register Container Bindings
Expand Down Expand Up @@ -61,7 +61,8 @@
$app->middleware([
Ushahidi\App\Multisite\DetectSiteMiddleware::class,
Barryvdh\Cors\HandleCors::class,
Ushahidi\App\Http\Middleware\MaintenanceMode::class
Ushahidi\App\Http\Middleware\MaintenanceMode::class,
Ushahidi\App\Http\Middleware\SetLocale::class
]);

$app->routeMiddleware([
Expand Down
2 changes: 1 addition & 1 deletion captainhook.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
{
"action": "\\Tests\\CaptainHook\\PHPCS",
"options": [
"--ignore=vendor/*,application/*,modules/*,plugins/*,httpdocs/*,tests/spec/*,migrations/*,bin/*,database/*,resources/views/*",
"--ignore=vendor/*,application/*,modules/*,plugins/*,httpdocs/*,tests/spec/*,migrations/*,bin/*,database/*,resources/views/*,resources/lang/*",
"--standard=src/ruleset.xml",
"--tab-width=4"
]
Expand Down
15 changes: 0 additions & 15 deletions codeship-services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ mysql/base: &_mysql_base
- MYSQL_USER=ushahidi
- MYSQL_PASSWORD=ushahidi
- MYSQL_ROOT_PASSWORD=root
mysql-7.1:
<<: *_mysql_base
mysql-7.2:
<<: *_mysql_base
mysql-7.3:
Expand All @@ -70,19 +68,6 @@ test/base: &_test_defaults
cached: true
default_cache_branch: develop

test/php-7.1:
<<: *_test_defaults
build:
<<: *_test_build_defaults
image: test-7.1
args:
PHP_MAJOR_VERSION: "7.1"
environment:
<<: *_test_env_defaults
DB_HOST: mysql-7.1
depends_on:
- mysql-7.1

test/php-7.2:
<<: *_test_defaults
build:
Expand Down
3 changes: 0 additions & 3 deletions codeship-steps.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
- name: "Test"
type: parallel
steps:
- name: "Test PHP 7.1"
service: test/php-7.1
command: test_reporter composer run test --timeout 0
- name: "Test PHP 7.2"
service: test/php-7.2
command: test_reporter composer run test --timeout 0
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}
],
"require": {
"php": ">=7.0 <7.4",
"php": ">=7.2 <7.4",
"aura/di": "~3.4",
"league/flysystem-aws-s3-v3": "~1.0",
"league/flysystem-rackspace": "~1.0",
Expand Down Expand Up @@ -43,7 +43,8 @@
"germanazo/laravel-ckan-api": "^1.0",
"asm89/stack-cors": "1.2.0",
"predis/predis": "~1.1",
"illuminate/redis": "5.5.*"
"illuminate/redis": "5.5.*",
"willdurand/negotiation": "^2.3"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
Expand Down
Loading

0 comments on commit bfe9153

Please sign in to comment.