Skip to content

Commit

Permalink
Merge branch 'develop' into issue-userfrosting#867
Browse files Browse the repository at this point in the history
  • Loading branch information
amosfolz committed Jul 11, 2019
2 parents 8c87ba7 + df8495e commit 87e59cb
Show file tree
Hide file tree
Showing 26 changed files with 129 additions and 73 deletions.
22 changes: 19 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,23 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Changed Requirements
- Changed minimum PHP Version to 7.1

### Changed Dependencies
- Updated Laravel Illuminate packages to 5.8
- Updated Twig to 2.11
- Updated PHPUnit to 7.5
- Updated Mockery to 1.2
- Updated nikic/php-parser to 4.2.2
- Updated PHPMailer/PHPMailer to 6.0.7
- Updated league/csv to 9.2.1
- Updated symfony/console to 4.3
- Updated vlucas/phpdotenv to 3.4.0

### Added
- Separated `BakeCommand` class into multiple methods to make it easier for sprinkle to add custom command to the `bake` command.

### Fix
- `bake` command return error if account sprinkle is not included ([#944])
- Email is case-sensitive ([#881]; [#1012])

### Changed
- Account sprinkle now extend the Core `BakeCommand` class to add the `create-admin` to the general bake command. Any sprinkle already extending the Core `BakeCommand` might need adjustments.
Expand All @@ -26,12 +38,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [v4.2.3]

### Added
- Config to set Domain of RememberMe Cookie ([#990]; [#991]; Thanks @xrobau!)
- Config to set Domain of RememberMe Cookie ([#990], [#991]; Thanks @xrobau !)
- Config settings for password min/max length ([#993])

### Fixed
- [PHPMailer] Turn off opportunistic TLS when disabled ([#986]; [#987])
- Migrator now ignore files that don't end in `.php` ([#965]; Temporary fix for [#998])
- [PHPMailer] Turn off opportunistic TLS when disabled ([#986], [#987])
- Migrator now ignore files that don't end in `.php` ([#965], [#998])
- Respects CSRF_ENABLED environment variable ([#976]; Thanks @Poldovico !)

## [v4.2.2]

Expand Down Expand Up @@ -773,6 +786,7 @@ See [http://learn.userfrosting.com/upgrading/40-to-41](Upgrading 4.0.x to 4.1.x
[#854]: https://github.com/userfrosting/UserFrosting/issues/854
[#869]: https://github.com/userfrosting/UserFrosting/issues/869
[#872]: https://github.com/userfrosting/UserFrosting/issues/872
[#881]: https://github.com/userfrosting/UserFrosting/issues/881
[#888]: https://github.com/userfrosting/UserFrosting/issues/888
[#893]: https://github.com/userfrosting/UserFrosting/issues/893
[#919]: https://github.com/userfrosting/UserFrosting/issues/919
Expand All @@ -785,6 +799,7 @@ See [http://learn.userfrosting.com/upgrading/40-to-41](Upgrading 4.0.x to 4.1.x
[#963]: https://github.com/userfrosting/UserFrosting/issues/963
[#965]: https://github.com/userfrosting/UserFrosting/issues/965
[#968]: https://github.com/userfrosting/UserFrosting/issues/968
[#976]: https://github.com/userfrosting/UserFrosting/issues/976
[#981]: https://github.com/userfrosting/UserFrosting/issues/981
[#983]: https://github.com/userfrosting/UserFrosting/issues/983
[#986]: https://github.com/userfrosting/UserFrosting/issues/986
Expand All @@ -793,6 +808,7 @@ See [http://learn.userfrosting.com/upgrading/40-to-41](Upgrading 4.0.x to 4.1.x
[#991]: https://github.com/userfrosting/UserFrosting/issues/991
[#993]: https://github.com/userfrosting/UserFrosting/issues/993
[#998]: https://github.com/userfrosting/UserFrosting/issues/998
[#1012]: https://github.com/userfrosting/UserFrosting/issues/1012

[v4.2.0]: https://github.com/userfrosting/UserFrosting/compare/v4.1.22...v4.2.0
[v4.2.1]: https://github.com/userfrosting/UserFrosting/compare/v4.2.0...v.4.2.1
Expand Down
2 changes: 1 addition & 1 deletion app/sprinkles/account/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
],
"require": {
"birke/rememberme" : "^2.0",
"nikic/php-parser" : "^1"
"nikic/php-parser" : "^4.2.2"
},
"autoload": {
"psr-4": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@

use Monolog\Logger;
use PhpParser\Error as PhpParserException;
use PhpParser\Lexer\Emulative as EmulativeLexer;
use PhpParser\NodeTraverser;
use PhpParser\Parser as Parser;
use PhpParser\ParserFactory as Parser;
use PhpParser\PrettyPrinter\Standard as StandardPrettyPrinter;
use UserFrosting\Sprinkle\Account\Database\Models\Interfaces\UserInterface;

Expand Down Expand Up @@ -75,7 +74,7 @@ public function __construct(ParserNodeFunctionEvaluator $nodeVisitor, UserInterf
{
$this->nodeVisitor = $nodeVisitor;
$this->user = $user;
$this->parser = new Parser(new EmulativeLexer());
$this->parser = (new Parser())->create(Parser::ONLY_PHP7);
$this->traverser = new NodeTraverser();
$this->traverser->addVisitor($nodeVisitor);
$this->prettyPrinter = new StandardPrettyPrinter();
Expand Down Expand Up @@ -119,7 +118,7 @@ public function evaluateCondition($condition, $params)
$stmts = $this->traverser->traverse($stmts);

// Evaluate boolean statement. It is safe to use eval() here, because our expression has been reduced entirely to a boolean expression.
$expr = $this->prettyPrinter->prettyPrintExpr($stmts[0]);
$expr = $this->prettyPrinter->prettyPrintExpr($stmts[0]->expr);
$expr_eval = 'return ' . $expr . ";\n";
$result = eval($expr_eval);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function leaveNode(Node $node)
{
// Look for function calls
if ($node instanceof \PhpParser\Node\Expr\FuncCall) {
$eval = new \PhpParser\Node\Scalar\LNumber();
$eval = new \PhpParser\Node\Scalar\LNumber(0);

// Get the method name
$callbackName = $node->name->toString();
Expand Down
25 changes: 12 additions & 13 deletions app/sprinkles/core/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,27 @@
"illuminate/database": "5.8.*",
"illuminate/events": "5.8.*",
"illuminate/filesystem": "5.8.*",
"league/csv": "^8.1",
"league/csv": "^9.2.1",
"league/flysystem": "~1.0",
"league/flysystem-aws-s3-v3": "~1.0",
"league/flysystem-cached-adapter": "~1.0",
"league/flysystem-rackspace": "~1.0",
"league/flysystem-sftp": "~1.0",
"monolog/monolog": "^1",
"phpmailer/phpmailer": "5.2.10",
"rockettheme/toolbox": "1.3.1",
"phpmailer/phpmailer": "^6.0.7",
"slim/csrf": "^0.8",
"slim/slim": "^3",
"slim/twig-view": "^1.2",
"slim/twig-view": "^2.5",
"symfony/http-foundation": "*",
"twig/twig": "^1.18",
"userfrosting/assets": "^5.0.4",
"userfrosting/config": "~4.2.0",
"userfrosting/cache": "~4.2.0",
"userfrosting/fortress": "~4.2.0",
"userfrosting/i18n": "~4.2.0",
"userfrosting/session": "~4.2.2",
"userfrosting/support": "~4.2.0",
"vlucas/phpdotenv": "^2"
"twig/twig": "^2.11",
"userfrosting/assets": "^6.0.0",
"userfrosting/config": "~4.3.0",
"userfrosting/cache": "~4.3.0",
"userfrosting/fortress": "~4.3.0",
"userfrosting/i18n": "~4.3.0",
"userfrosting/session": "~4.3.0",
"userfrosting/support": "~4.3.0",
"vlucas/phpdotenv": "^3.4.0"
},
"autoload": {
"files" : [
Expand Down
2 changes: 1 addition & 1 deletion app/sprinkles/core/config/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
* Note : CSRF Middleware should only be disabled for dev or debug purposes.
*/
'csrf' => [
'enabled' => getenv('CSRF_ENABLED') ?: true,
'enabled' => (getenv('CSRF_ENABLED') !== false) ? getenv('CSRF_ENABLED') : true,
'name' => 'csrf',
'storage_limit' => 200,
'strength' => 16,
Expand Down
17 changes: 15 additions & 2 deletions app/sprinkles/core/src/Bakery/MigrateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use UserFrosting\Sprinkle\Core\Bakery\Helper\ConfirmableTrait;
use UserFrosting\Sprinkle\Core\Database\Migrator\Migrator;
use UserFrosting\System\Bakery\BaseCommand;

/**
Expand Down Expand Up @@ -79,13 +80,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
try {
$migrated = $migrator->run(['pretend' => $pretend, 'step' => $step]);
} catch (\Exception $e) {
$this->io->writeln($migrator->getNotes());
$this->displayNotes($migrator);
$this->io->error($e->getMessage());
exit(1);
}

// Get notes and display them
$this->io->writeln($migrator->getNotes());
$this->displayNotes($migrator);

// If all went well, there's no fatal errors and we have migrated
// something, show some success
Expand Down Expand Up @@ -128,4 +129,16 @@ protected function setupMigrator(InputInterface $input)

return $migrator;
}

/**
* Display migrator notes.
*
* @param Migrator $migrator
*/
protected function displayNotes(Migrator $migrator)
{
if (!empty($notes = $migrator->getNotes())) {
$this->io->writeln($notes);
}
}
}
6 changes: 3 additions & 3 deletions app/sprinkles/core/src/Bakery/MigrateRefreshCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
try {
$rolledback = $migrator->rollback(['pretend' => false, 'steps' => $steps]);
} catch (\Exception $e) {
$this->io->writeln($migrator->getNotes());
$this->displayNotes($migrator);
$this->io->error($e->getMessage());
exit(1);
}

// Get notes and display them
$this->io->writeln($migrator->getNotes());
$this->displayNotes($migrator);

// Stop if nothing was rolledback
if (empty($rolledback)) {
Expand All @@ -88,7 +88,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

// Run back up again
$migrated = $migrator->run(['pretend' => false, 'step' => false]);
$this->io->writeln($migrator->getNotes());
$this->displayNotes($migrator);

// If all went well, there's no fatal errors and we have migrated
// something, show some success
Expand Down
4 changes: 2 additions & 2 deletions app/sprinkles/core/src/Bakery/MigrateResetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ protected function performReset(InputInterface $input)
try {
$resetted = $migrator->reset($pretend);
} catch (\Exception $e) {
$this->io->writeln($migrator->getNotes());
$this->displayNotes($migrator);
$this->io->error($e->getMessage());
exit(1);
}

// Get notes and display them
$this->io->writeln($migrator->getNotes());
$this->displayNotes($migrator);

// Delete the repository
if (!$pretend && $migrator->repositoryExists()) {
Expand Down
4 changes: 2 additions & 2 deletions app/sprinkles/core/src/Bakery/MigrateRollbackCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
$migrated = $migrator->rollback(['pretend' => $pretend, 'steps' => $steps]);
}
} catch (\Exception $e) {
$this->io->writeln($migrator->getNotes());
$this->displayNotes($migrator);
$this->io->error($e->getMessage());
exit(1);
}

// Get notes and display them
$this->io->writeln($migrator->getNotes());
$this->displayNotes($migrator);

// If all went well, there's no fatal errors and we have migrated
// something, show some success
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function getMigrations()
foreach ($migrationFiles as $migrationFile) {
// Note that PSR4 insists that all php files must end in PHP, so ignore all
// files that don't end in PHP.
if (preg_match('/php$/', $migrationFile)) {
if ($migrationFile->getExtension() == 'php') {
$migrations[] = $this->getMigrationDetails($migrationFile);
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/sprinkles/core/src/Database/Models/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function attributeExists($key)
*/
public static function findUnique($value, $identifier, $checkDeleted = true)
{
$query = static::where($identifier, $value);
$query = static::whereRaw("LOWER($identifier) = ?", [mb_strtolower($value)]);

if ($checkDeleted) {
$query = $query->withTrashed();
Expand Down
14 changes: 8 additions & 6 deletions app/sprinkles/core/src/Mail/Mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
namespace UserFrosting\Sprinkle\Core\Mail;

use Monolog\Logger;
use PHPMailer\PHPMailer\Exception as phpmailerException;
use PHPMailer\PHPMailer\PHPMailer;

/**
* Mailer Class.
Expand All @@ -37,14 +39,14 @@ class Mailer
* @param Logger $logger A Monolog logger, used to dump debugging info for SMTP server transactions.
* @param mixed[] $config An array of configuration parameters for phpMailer.
*
* @throws \phpmailerException Wrong mailer config value given.
* @throws phpmailerException Wrong mailer config value given.
*/
public function __construct($logger, $config = [])
{
$this->logger = $logger;

// 'true' tells PHPMailer to use exceptions instead of error codes
$this->phpMailer = new \PHPMailer(true);
$this->phpMailer = new PHPMailer(true);

// Configuration options
switch ($config['mailer']) {
Expand Down Expand Up @@ -79,7 +81,7 @@ public function __construct($logger, $config = [])
}
break;
default:
throw new \phpmailerException("'mailer' must be one of 'smtp', 'mail', 'qmail', or 'sendmail'.");
throw new phpmailerException("'mailer' must be one of 'smtp', 'mail', 'qmail', or 'sendmail'.");
}

// Set any additional message-specific options
Expand All @@ -97,7 +99,7 @@ public function __construct($logger, $config = [])
/**
* Get the underlying PHPMailer object.
*
* @return \PHPMailer
* @return PHPMailer
*/
public function getPhpMailer()
{
Expand All @@ -113,7 +115,7 @@ public function getPhpMailer()
* @param MailMessage $message
* @param bool $clearRecipients Set to true to clear the list of recipients in the message after calling send(). This helps avoid accidentally sending a message multiple times.
*
* @throws \phpmailerException The message could not be sent.
* @throws phpmailerException The message could not be sent.
*/
public function send(MailMessage $message, $clearRecipients = true)
{
Expand Down Expand Up @@ -163,7 +165,7 @@ public function send(MailMessage $message, $clearRecipients = true)
* @param MailMessage $message
* @param bool $clearRecipients Set to true to clear the list of recipients in the message after calling send(). This helps avoid accidentally sending a message multiple times.
*
* @throws \phpmailerException The message could not be sent.
* @throws phpmailerException The message could not be sent.
*/
public function sendDistinct(MailMessage $message, $clearRecipients = true)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public function register(ContainerInterface $container)
$container['config'] = function ($c) {
// Grab any relevant dotenv variables from the .env file
try {
$dotenv = new Dotenv(\UserFrosting\APP_DIR);
$dotenv = Dotenv::create(\UserFrosting\APP_DIR);
$dotenv->load();
} catch (InvalidPathException $e) {
// Skip loading the environment config file if it doesn't exist.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
namespace UserFrosting\Sprinkle\Core\Tests\Integration\Bakery;

use Mockery as m;
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;
use UserFrosting\Sprinkle\Core\Bakery\MigrateCommand;
Expand All @@ -21,6 +22,8 @@
*/
class BakeryMigrateCommandTest extends TestCase
{
use MockeryPHPUnitIntegration;

public function tearDown()
{
parent::tearDown();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
namespace UserFrosting\Sprinkle\Core\Tests\Integration\Bakery;

use Mockery as m;
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;
use UserFrosting\Sprinkle\Core\Bakery\MigrateRefreshCommand;
Expand All @@ -21,6 +22,8 @@
*/
class BakeryMigrateRefreshCommandTest extends TestCase
{
use MockeryPHPUnitIntegration;

public function tearDown()
{
parent::tearDown();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
namespace UserFrosting\Sprinkle\Core\Tests\Integration\Bakery;

use Mockery as m;
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;
use UserFrosting\Sprinkle\Core\Bakery\MigrateResetCommand;
Expand All @@ -21,6 +22,8 @@
*/
class BakeryMigrateResetCommandTest extends TestCase
{
use MockeryPHPUnitIntegration;

public function tearDown()
{
parent::tearDown();
Expand Down
Loading

0 comments on commit 87e59cb

Please sign in to comment.