Skip to content

Commit 51a77fc

Browse files
carlos-mg89javicarrillodavidbeigmicrostudi
authored
Feature/symfony upgrade to.3.4 (#231)
* fix install of grunt-cli to only install the 1.3.2 so that it does not brake with older versions of node * Renew SSL certs until 2026 * Removed symfony/security-csrf package since it was colliding with symfony/security which replaces thr former one. Thanks to that, symfony/security can be safely updated to 2.8.52 . * Removed enforcement to keep some Symfony package in v2.8.0 so they are now updatable to 2.8.52 * Added (un)zip packages to Dockerfile so we remove Composer warning (#170) * Bug/fix unit tests (#171) * Added missing PDO dependency which is in fact needed * Fixed Sponsor model unit tests * Removed pointless comments and deprecated method on Mail model * Fixed Mail model unit tests * Fixed TextTest translations tests due to missing and/or incorrect HTML tags/attributes * Updated Matcher model tests * Enforce PHP 7.1 as minimum PHP version in Composer * Fixed HTML structure on newsletter template and removed commented CSS classes * Improved readability, added parameter types and some small refactors on Mail model * Improved readability and added parameter types on MatcherTest class * Further cleanup on User and MatcherTest classes * Downgraded minimum PHP version to the production one * Reintroduced sqlWhere variable so we don't get errors since it's used in the code * Fully reintroduced the Sponsor 'type' property and fixed related failing test * Refactored call to obtain Sponsors list into a method * Fix SQL query to obtain Sponsors list * Fix Mail model tests along with issues on the HTML formatting with 2 related templates * Changed method syntax so is PHP 7.0 compliant (it was using PHP 7.1 syntax) * Fix Matcher model tests (some translations were missing when querying for them) * Reduced tests verbosity (we don't need to know if users, projects, etc were removed when running tests) * Ignored .idea (Jetbrains IDEs) folder * Bumped PHPMailer to 6.x and fixed Mail model and test with related changes * Bumped Mockery to 1.x * Added OpenSSL extension, since it's used by AmazonSns and AuthListener classes * Updated amazon-s3-php-class with many changes (last updated on 2015) * Assure PHPMailer minimum version is 6.4 * Updated to PHPUnit 6.5 * Removed empty test along with unused imports * Moved PHP extensions on composer file right after the PHP version for easy spotting * Reduced verbosity on tests output so we can focus on seeing if the focus passed, failed, errored or were skipped * Remove deprecated asserts and upgrade PHPUnit from 6.x to 7.x * Bumped min PHP version to 7.1 * Upgrade PHP from 7.0/7.1 to 7.4 * Upgraded PHPUnit to 8.x (depends on PR that enforces PHP 7.4) * Removed deprecated expectedException (will be removed on PHPUnit 9.x). Flipped assertEquals comparators to be compliant with expected/actual order. * Removed deprecated class * Got rid of last array curly braces access * Removed duplicated key * Removed deprecated (and unused) FlattenException import * Removed last noisy message on PHPUnit so we only have test results status * WIP Upgrade to Symfony 3.x * Tidy index(_env).php files so they have less differences between them, for a future merge * Got rid of index_dev.php in favor of index.php that read ENV DEBUG parameter * Added import, rewritten some PHPDocs and added some return types * Clean container.php * Refactor getName() method from custom Symfony Form Types, so they just have getBlockPrefix() method * Refactor to add Form Types as is required in Symfony 3 * Fix install of migrations on PHP 7.4 and latest Composer dependencies * Fix RouteListener initialization. Fix DB setup. * Use ::class to register services in the ServiceContainer instead of strings * Fix composer.json so it reckognizes goteo-private tests * Fix tests for App class (due to having renamed a property) * Updated Omnipay dependency to the new one from league * Grouped Composer dependencies * Used Symfony HttpKernel class instead of HttpKernel\HttpKernel * Removed unneeded package * Cleanup Omnipay classes and fix some issues while initilizing the Payment Gateway * Made final changes to support all Omnipay payment methods using Omnipay v3 * Deprecated static AbstractPaymentMethod::getId() method in favor of non static one * Converted static calculateComission method into non-static calculateCommission * Converted static AbstractPaymentMethod::isInternal() into a non-static method * Add parameter / return types and import used classes * Updated TelegramBot so it doesn't use deprecated code * Reviewed controllers to ensure they follow Symfony 3 convention * Add User property type * Removed unused code * Tidy up classes * Removed unused parameters from PHPDoc * Upgraded Symfony from 3.0 to 3.1 * Included some used classes * Finalize migration to symfony/forms 3.x (there must be a getBlockPrefix() method on a new Type, even if their parents have the method * Enforce getModelForm() & createFormBuilder() from controllers to return FormProcessorInterface & FormFactory respectively * Fix return parameter of Controller::createFormBuilder() method and the controllers that inherit it * Upgraded to Symfony 3.2 * Symfony packages upgraded to 3.3 * WIP Migration to Symfony 3.4 almost completed * Fix call to Mail::renderEmailTemplate (got renamed recently) * Fix Settings Dashboard form (ChoiceType elements had flipped key / values) * Fix loading of ChoiceType and some minor refactors * Fix ChoiceType for some forms related to Contract PersonDocumentTypes * Revert BooleanType::getBlockPrefix() method so it returns 'boolean' which to match it's class name * Refactor ProjectOverviewForm to fix it and to ease its reading * Fix import of PDOException (it was written incorrectly) * Fix ChoiceTypes on several Project related forms * Refactor to use the new Controller:getModelForm() method that requires a class instead of just a string. Fixed some Symfony Forms due to incomplete migration when Symfony 3.0 upgrade. * Refactored last controller that used the deprecated method to guess SymfonyForm class * Tiny refactors * Removed unnecessary EventDispatcher from Console class * Clean up of some classes * Change test to testLegacy, since the deprecation notice is due to Symfony code (and is due to expire on Symfony 4.3) * Fix some Symfony Forms with unfinished migration to Symfony 3.x. Remove some unused code / comments. * General cleanup of controllers * Tiny cleanup * Fix access to some admin pages * Fix usage of DatepickerType so it actually replaces the Symfony type while keeping all it's parents features * Fix admin blog add/edit form * Fix behaviour of some custom Symfony Form Types * Fix FilterForm so it conforms to Symfony 3.x standards * Readd workshop_location table since it got removed sometime ago by mistake * Fix Symfony Console (probably due to some incomplete step after migrating to Symfony 3.x) * Fix admin workshop add/edit form * Fix some translations * Refactor Sponsors controller * Fix broken CSS on Call edit form for rewards items * Fix admin Stories add/edit form * Fix CSS error while displaying TypeaheadType form elements * Fix Controller::redirect() parameter types * Fix admin Channel Questionnaire and Channel Section forms to add/edit * Fix Admin Charts API controller * Cleanup SessionListener * Reformatted Filter and Project models * Simplify public/index.php * Cleanup main PHP classes * Minor refactors on controllers * Removed deprecated mcrypt PHP extension * Removed deprecated mcrypt PHP extension from composer.lock * Fix SQL migration * Fix SQL migration related to mail table * Fix SQL migration related to mail table * Fix SQL migration related to mail table * Improved Docker readme * make loggin resilient to Gelf updates failures (#225) * make loggin resilient to Gelf updates failures * ignore redundant exception thrown * fix on deprecated implode call (#229) * update oauth library for linkedin (#226) * add deployer script * refactor subdomain processing and add test to it (#205) * fix/var subs (#215) * refactor subdomain processing and add test to it (#204) * refactor subdomain processing and add test to it * add other envs to deployment * make config process deep ENV substitution * fix/var subs (#216) * refactor subdomain processing and add test to it (#204) * refactor subdomain processing and add test to it * add other envs to deployment * make config process deep ENV substitution * fix namespace * update oauth library for linkedin * update up to a working commit * fix linkedin call * remove orphan location stats (#230) * Moved Omnipay/Mock/Gateway class to goteo repository (is needed to run PHPUnits successfully) Co-authored-by: Javier <javicarrillo83@gmail.com> Co-authored-by: David Igón <david@goteo.org> Co-authored-by: Ivan Vergés <ivan@platoniq.net> Co-authored-by: David <david.igon@riseup.net>
1 parent 1f910f9 commit 51a77fc

11 files changed

Lines changed: 146 additions & 138 deletions

File tree

Resources/templates/responsive/channel/call/partials/map.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
}
2222

2323
if ($map_config['center']) {
24-
$url .= '/' . implode($map_config['center'],',');
24+
$url .= '/' . implode(',', $map_config['center']);
2525
}
2626

2727

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"jdorn/file-system-cache": "dev-master",
1919
"intervention/image": "~2.0",
2020
"mibe/feedwriter": "~1.0",
21-
"lusitanian/oauth": "^0.8.9",
21+
"lusitanian/oauth": "dev-master#c3b5e51fcf86ebe83023d34744d7da131a9744a5",
2222
"iignatov/lightopenid": "~1.0",
2323
"paypal/adaptivepayments-sdk-php": "*",
2424
"paypal/merchant-sdk-php": "*",

composer.lock

Lines changed: 25 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extend/extra-logger/start.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
$gelf = Config::get('plugins.extra-logger.gelf');
2525
if($gelf && $gelf["host"]) {
2626
$handler = new GelfHandler(new Publisher( new UdpTransport($gelf["host"], $gelf["port"]) ));
27-
2827
App::getService('logger')->pushHandler($handler);
2928
App::getService('syslogger')->pushHandler($handler);
3029
App::getService('paylogger')->pushHandler($handler);

src/Goteo/Application/EventListener/ExceptionListener.php

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,22 @@ static function jTraceEx($e, $with_message = true, $seen = null) {
9797
protected function logException(\Exception $exception, $message) {
9898
if (null !== $this->logger) {
9999
$message = str_replace(["\n", "\r"],[" ", ""], $message);
100-
if ($exception instanceof LegacyError) {
101-
$this->logger->warning('Kernel Exception', ['etype' => 'LegacyError', 'trace' => self::jTraceEx($exception, false), 'exception' => $exception, 'message' => $message]);
102-
} elseif (!$exception instanceof HttpExceptionInterface || $exception->getStatusCode() >= 500) {
103-
$this->logger->critical('Kernel Exception', ['etype' => 'HttpException', 'trace' => self::jTraceEx($exception, false), 'exception' => $exception, 'message' => $message]);
104-
} elseif ($exception instanceof ModelNotFoundException) {
105-
$this->logger->warning('Kernel Exception', ['etype' => 'NotFound', 'trace' => self::jTraceEx($exception, false), 'exception' => $exception, 'message' => $message]);
106-
} elseif ($exception instanceof ControllerAccessDeniedException) {
107-
$this->logger->warning('Kernel Exception', ['etype' => 'AccessDenied', 'trace' => self::jTraceEx($exception, false), 'exception' => $exception, 'message' => $message]);
108-
} else {
109-
$this->logger->error('Kernel Exception', ['etype' => 'Exception', 'trace' => self::jTraceEx($exception, false), 'exception' => $exception, 'message' => $message]);
100+
try {
101+
if ($exception instanceof LegacyError) {
102+
$this->logger->warning('Kernel Exception', ['etype' => 'LegacyError', 'trace' => self::jTraceEx($exception, false), 'exception' => $exception, 'message' => $message]);
103+
} elseif (!$exception instanceof HttpExceptionInterface || $exception->getStatusCode() >= 500) {
104+
$this->logger->critical('Kernel Exception', ['etype' => 'HttpException', 'trace' => self::jTraceEx($exception, false), 'exception' => $exception, 'message' => $message]);
105+
} elseif ($exception instanceof ModelNotFoundException) {
106+
$this->logger->warning('Kernel Exception', ['etype' => 'NotFound', 'trace' => self::jTraceEx($exception, false), 'exception' => $exception, 'message' => $message]);
107+
} elseif ($exception instanceof ControllerAccessDeniedException) {
108+
$this->logger->warning('Kernel Exception', ['etype' => 'AccessDenied', 'trace' => self::jTraceEx($exception, false), 'exception' => $exception, 'message' => $message]);
109+
} else {
110+
$this->logger->error('Kernel Exception', ['etype' => 'Exception', 'trace' => self::jTraceEx($exception, false), 'exception' => $exception, 'message' => $message]);
111+
}
112+
} catch(\RuntimeException $e) {
113+
// Ignore error logging here, it should be cached by the app
110114
}
115+
111116
}
112117
}
113118

src/Goteo/Console/Command/DBVerifierCommand.php

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@
1010

1111
namespace Goteo\Console\Command;
1212

13+
use Exception;
1314
use Goteo\Application\Config;
1415
use Goteo\Model\Mail;
1516
use Goteo\Model\Project;
1617
use Goteo\Model\Template;
1718
use Goteo\Util\AnsiConverter\Theme\SolarizedLightTheme;
19+
use PDO;
20+
use RuntimeException;
1821
use SensioLabs\AnsiConverter\AnsiToHtmlConverter;
1922
use Symfony\Component\Console\Input\ArrayInput;
2023
use Symfony\Component\Console\Input\InputArgument;
@@ -81,7 +84,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
8184
$update = $input->getOption('update');
8285
$scope = $input->getArgument('scope');
8386
if(!in_array($scope, ['all', 'feed', 'mailing', 'token', 'blocked', 'toolkit', 'predict'])) {
84-
throw new \Exception('Scope is not valid!');
87+
throw new Exception('Scope is not valid!');
8588
}
8689

8790
$verbose = $output->isVerbose();
@@ -90,7 +93,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
9093
$days = (int) $input->getOption('days');
9194
if($days == -1) $days = 120;
9295
if($days < 30) {
93-
throw new \Exception('Number of days must be greater than 30!');
96+
throw new Exception('Number of days must be greater than 30!');
9497
}
9598
$index = $fixes = 0;
9699
$output->writeln("Checking old feed data...");
@@ -101,7 +104,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
101104
if($verbose) {
102105
$query = Project::query("SELECT * FROM feed $where");
103106

104-
foreach ($query->fetchAll(\PDO::FETCH_CLASS) as $feed) {
107+
foreach ($query->fetchAll(PDO::FETCH_CLASS) as $feed) {
105108
$output->writeln("Found old feed <info>{$feed->title}</info> with ID <comment>{$feed->id}</comment> and date <comment>{$feed->datetime}</comment>");
106109
}
107110
}
@@ -122,14 +125,14 @@ protected function execute(InputInterface $input, OutputInterface $output)
122125
$days = (int) $input->getOption('days');
123126
if($days == -1) $days = 4;
124127
if($days < 1) {
125-
throw new \Exception('Number of days must be greater than 2!');
128+
throw new Exception('Number of days must be greater than 2!');
126129
}
127130

128131
$output->writeln("Checking token older thant $days days...");
129132
// eliminamos los tokens que tengan más de $days días
130133
$sql = "SELECT id, token FROM user WHERE token IS NOT NULL AND token != '' AND token LIKE '%¬%'";
131134
$query = Project::query($sql);
132-
foreach ($query->fetchAll(\PDO::FETCH_OBJ) as $row) {
135+
foreach ($query->fetchAll(PDO::FETCH_OBJ) as $row) {
133136
$parts = explode('¬', $row->token);
134137
$datepart = strtotime($parts[2]);
135138
$today = date('Y-m-d');
@@ -154,7 +157,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
154157
$days = (int) $input->getOption('days');
155158
if($days == -1) $days = 365;
156159
if($days < 30) {
157-
throw new \Exception('Number of days must be greater than 30!');
160+
throw new Exception('Number of days must be greater than 30!');
158161
}
159162

160163
$output->writeln("Checking old mail data...");
@@ -164,7 +167,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
164167
$query = Project::query("SELECT * FROM mail $where", [':template1' => Template::NEWSLETTER, ':template2' => Template::MESSAGE_DONORS]);
165168

166169
$found = 0;
167-
foreach ($query->fetchAll(\PDO::FETCH_CLASS) as $mail) {
170+
foreach ($query->fetchAll(PDO::FETCH_CLASS) as $mail) {
168171
if($verbose) {
169172
$output->writeln("Found old mail <info>{$mail->email}</info>, Template <comment>{$mail->template}</comment> Subject <info>[{$mail->subject}]</info> with ID <comment>{$mail->id}</comment> and date <comment>{$mail->date}</comment>");
170173
}
@@ -177,6 +180,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
177180
}
178181
}
179182
}
183+
if($update) {
184+
Project::query("DELETE FROM mail_stats_location WHERE id NOT IN (SELECT id FROM mail_stats)");
185+
}
180186
$query = Project::query("SELECT count(*) as total FROM mail");
181187
$total = $query->fetchColumn();
182188
$output->writeln("Found <comment>$found</comment> <info>mail records</info> older than <comment>$days days</comment> from a total of <comment>$total</comment> records");
@@ -187,7 +193,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
187193
$days = (int) $input->getOption('days');
188194
if($days == -1) $days = 120;
189195
if($days < 30) {
190-
throw new \Exception('Number of days must be greater than 120!');
196+
throw new Exception('Number of days must be greater than 120!');
191197
}
192198

193199
$output->writeln("Checking old blocked users for mailing...");
@@ -196,7 +202,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
196202
$query = Project::query("SELECT * FROM mailer_control $where");
197203

198204
$found = 0;
199-
foreach ($query->fetchAll(\PDO::FETCH_CLASS) as $usr) {
205+
foreach ($query->fetchAll(PDO::FETCH_CLASS) as $usr) {
200206
if($verbose) {
201207
$output->writeln("Found blocked subscriber <info>{$usr->email}</info>, Template <comment>{$usr->bounces}</comment> Reason <info>[{$usr->last_reason}]</info> and date <comment>{$usr->modified}</comment>");
202208
}
@@ -246,7 +252,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
246252
$mailer = Mail::createFromHtml(Config::getMail('fail'), '', "DATABASE INCONSISTENCY in [" .Config::get('url.main')."]", $html);
247253
$errors = [];
248254
if(!$mailer->send($errors)) {
249-
throw new \RuntimeException('Error sending email: ' . implode("\n", $errors));
255+
throw new RuntimeException('Error sending email: ' . implode("\n", $errors));
250256
}
251257
} else {
252258
$output->writeln("<info>Everything ok</info>");
@@ -272,7 +278,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
272278
$mailer = Mail::createFromHtml(Config::getMail('fail'), '', "FAILING PROJECTS PREDICTION in [" .Config::get('url.main')."]", $html);
273279
$errors = [];
274280
if(!$mailer->send($errors)) {
275-
throw new \RuntimeException('Error sending email: ' . implode("\n", $errors));
281+
throw new RuntimeException('Error sending email: ' . implode("\n", $errors));
276282
}
277283
} else {
278284
$output->writeln("<info>Everything ok</info>");

src/Goteo/Core/Traits/LoggerTrait.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@
1111
namespace Goteo\Core\Traits;
1212

1313
use Goteo\Application\App;
14-
use Goteo\Application\Config;
1514
use Goteo\Util\Monolog\Processor\WebProcessor;
1615
use Psr\Log\LoggerInterface;
17-
use RuntimeException;
1816

1917
/**
2018
* Trait to add log common methods
@@ -37,15 +35,7 @@ public function getLog() {
3735
public function log($message, array $context = [], $func = 'info') {
3836
$logger = $this->getLog();
3937
if (null !== $logger && method_exists($logger, $func)) {
40-
if(Config::get('debug')) {
41-
return $logger->$func($message, WebProcessor::processObject($context));
42-
} else {
43-
try {
44-
return $logger->$func($message, WebProcessor::processObject($context));
45-
} catch(RuntimeException $e) {
46-
// nothing here, if not in debug mode, failure to process logs is ignored
47-
}
48-
}
38+
return $logger->$func($message, WebProcessor::processObject($context));
4939
}
5040
}
5141

src/Goteo/Core/Traits/StaticLoggerTrait.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212

1313
use Goteo\Util\Monolog\Processor\WebProcessor;
1414
use Psr\Log\LoggerInterface;
15-
use Goteo\Application\Config;
16-
use RuntimeException;
1715

1816
/**
1917
* Trait to use log on legacy classes
@@ -32,15 +30,7 @@ static public function getLogger(LoggerInterface $logger) {
3230

3331
static public function log($message, array $context = [], $func = 'info') {
3432
if(static::$logger) {
35-
if(Config::get('debug')) {
36-
return static::$logger->$func($message, WebProcessor::processObject($context));
37-
} else {
38-
try {
39-
return static::$logger->$func($message, WebProcessor::processObject($context));
40-
} catch(RuntimeException $e) {
41-
// nothing here, if not in debug mode, failure to process logs is ignored
42-
}
43-
}
33+
return static::$logger->$func($message, WebProcessor::processObject($context));
4434
}
4535
}
4636

0 commit comments

Comments
 (0)