Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions app/code/Magento/Backend/Block/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ protected function _addSubMenu($menuItem, $level, $limit, $id = null)
return $output;
}
$output .= '<div class="submenu"' . ($level == 0 && isset($id) ? ' aria-labelledby="' . $id . '"' : '') . '>';
$colStops = null;
$colStops = [];
if ($level == 0 && $limit) {
$colStops = $this->_columnBrake($menuItem->getChildren(), $limit);
$output .= '<strong class="submenu-title">' . $this->_getAnchorLabel($menuItem) . '</strong>';
Expand Down Expand Up @@ -387,7 +387,11 @@ public function renderNavigation($menu, $level = 0, $limit = 0, $colBrakes = [])
$itemName = substr($menuId, strrpos($menuId, '::') + 2);
$itemClass = str_replace('_', '-', strtolower($itemName));

if (count($colBrakes) && $colBrakes[$itemPosition]['colbrake'] && $itemPosition != 1) {
if (is_array($colBrakes)
&& count($colBrakes)
&& $colBrakes[$itemPosition]['colbrake']
&& $itemPosition != 1
) {
$output .= '</ul></li><li class="column"><ul role="menu">';
}

Expand All @@ -401,7 +405,7 @@ public function renderNavigation($menu, $level = 0, $limit = 0, $colBrakes = [])
$itemPosition++;
}

if (count($colBrakes) && $limit) {
if (is_array($colBrakes) && count($colBrakes) && $limit) {
$output = '<li class="column"><ul role="menu">' . $output . '</ul></li>';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*
*/
/* @var $block \Magento\Backend\Block\Widget\Grid */
$numColumns = sizeof($block->getColumns());
$numColumns = !is_null($block->getColumns()) ? sizeof($block->getColumns()) : 0;
?>
<?php if ($block->getCollection()): ?>

Expand Down
8 changes: 4 additions & 4 deletions app/code/Magento/Theme/Block/Html/Topmenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ protected function _addSubMenu($child, $childLevel, $childrenWrapClass, $limit)
return $html;
}

$colStops = null;
$colStops = [];
if ($childLevel == 0 && $limit) {
$colStops = $this->_columnBrake($child->getChildren(), $limit);
}
Expand Down Expand Up @@ -205,7 +205,7 @@ protected function _getHtml(
\Magento\Framework\Data\Tree\Node $menuTree,
$childrenWrapClass,
$limit,
$colBrakes = []
array $colBrakes = []
) {
$html = '';

Expand Down Expand Up @@ -244,7 +244,7 @@ protected function _getHtml(
}
}

if (count($colBrakes) && $colBrakes[$counter]['colbrake']) {
if (is_array($colBrakes) && count($colBrakes) && $colBrakes[$counter]['colbrake']) {
$html .= '</ul></li><li class="column"><ul>';
}

Expand All @@ -261,7 +261,7 @@ protected function _getHtml(
$counter++;
}

if (count($colBrakes) && $limit) {
if (is_array($colBrakes) && count($colBrakes) && $limit) {
$html = '<li class="column"><ul>' . $html . '</ul></li>';
}

Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Ui/DataProvider/AbstractDataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* @api
* @since 100.0.2
*/
abstract class AbstractDataProvider implements DataProviderInterface
abstract class AbstractDataProvider implements DataProviderInterface, \Countable
{
/**
* Data Provider name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
namespace Magento\Test\Bootstrap;

ob_start();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joanhe Is there a reason for this? I feel like it definitely does not belong here

Copy link

@joanhe joanhe Mar 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bbatsche This is to resolve test failure in php 7.2.
session_id(): Cannot change session id when headers already sent in

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe try adding this right above the call that's failing, or somewhere in one of the setUp*() methods. No code or function calls should be in this file and not inside of the class itself.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only place works.

class EnvironmentTest extends \PHPUnit\Framework\TestCase
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,24 @@
class ConfigTest extends \PHPUnit\Framework\TestCase
{
/** @var \Magento\Framework\Session\Config */
protected $_model;
private $_model;

/** @var string */
protected $_cacheLimiter = 'private_no_expire';
private $_cacheLimiter = 'private_no_expire';

/** @var \Magento\TestFramework\ObjectManager */
protected $_objectManager;
private $_objectManager;

/** @var string Default value for session.save_path setting */
protected $defaultSavePath;
private $defaultSavePath;

/** @var \Magento\Framework\App\DeploymentConfig | \PHPUnit_Framework_MockObject_MockObject */
protected $deploymentConfigMock;
private $deploymentConfigMock;

protected function setUp()
{
$this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
/** @var $sessionManager \Magento\Framework\Session\SessionManager */
$sessionManager = $this->_objectManager->create(\Magento\Framework\Session\SessionManager::class);
if ($sessionManager->isSessionExists()) {
$sessionManager->writeClose();
}

$this->deploymentConfigMock = $this->createMock(\Magento\Framework\App\DeploymentConfig::class);
$this->deploymentConfigMock
->method('get')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

use Magento\Framework\App\DeploymentConfig;
use Magento\Framework\Session\Config\ConfigInterface;
use Magento\Framework\Session\SaveHandler;
use Magento\Framework\App\ObjectManager;

class SaveHandlerTest extends \PHPUnit\Framework\TestCase
Expand Down Expand Up @@ -57,13 +56,6 @@ public function testSetSaveHandler($deploymentConfigHandler, $iniHandler)
);
}

public function tearDown()
{
if (isset($this->originalSaveHandler)) {
ini_set('session.save_handler', $this->originalSaveHandler);
}
}

public function saveHandlerProvider()
{
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ protected function tearDown()
{
global $mockPHPFunctions;
$mockPHPFunctions = false;
$this->_model->destroy();
}

public function testSessionNameFromIni()
Expand Down Expand Up @@ -149,7 +150,9 @@ public function testGetName()

public function testSetName()
{
$this->_model->destroy();
$this->_model->setName('test');
$this->_model->start();
$this->assertEquals('test', $this->_model->getName());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,12 @@ public function testGetSessionIdQueryParam()

public function testGetSessionIdQueryParamCustom()
{
$this->session->destroy();
$oldSessionName = $this->session->getName();
$this->session->setName($this->customSessionName);
$this->assertEquals($this->customSessionQueryParam, $this->model->getSessionIdQueryParam($this->session));
$this->session->setName($oldSessionName);
$this->session->start();
}

public function testSetGetUseSessionVar()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ private function isItTest($relativeFilePath)
private function getControllerPath($relativeFilePath)
{
if (preg_match('~(Magento\/.*Controller\/Adminhtml\/.*)\.php~', $relativeFilePath, $matches)) {
if (count($matches) === 2 && count($partPath = $matches[1]) >= 1) {
if (count($matches) === 2) {
$partPath = $matches[1];
return $partPath;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/Magento/Framework/DB/Tree/NodeSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* TODO implements iterators
*
*/
class NodeSet implements \Iterator
class NodeSet implements \Iterator, \Countable
{
/**
* @var Node[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
* @author Magento Core Team <[email protected]>
*/
class Collection implements \ArrayAccess, \IteratorAggregate
class Collection implements \ArrayAccess, \IteratorAggregate, \Countable
{
/**
* Elements storage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* @api
*/
class Collection implements \ArrayAccess, \IteratorAggregate
class Collection implements \ArrayAccess, \IteratorAggregate, \Countable
{
/**
* @var array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,10 @@ public function getConstructorExceptionData()
$tooShortInitVector = str_repeat('-', $this->_getInitVectorSize($cipher, $mode) - 1);
$tooLongInitVector = str_repeat('-', $this->_getInitVectorSize($cipher, $mode) + 1);
$result['tooLongKey-' . $cipher . '-' . $mode . '-false'] = [$tooLongKey, $cipher, $mode, false];
$result['key-' . $cipher . '-' . $mode . '-tooShortInitVector'] = [$this->_key, $cipher, $mode, $tooShortInitVector];
$result['key-' . $cipher . '-' . $mode . '-tooLongInitVector'] = [$this->_key, $cipher, $mode, $tooLongInitVector];
$result['key-' . $cipher . '-' . $mode . '-tooShortInitVector']
= [$this->_key, $cipher, $mode, $tooShortInitVector];
$result['key-' . $cipher . '-' . $mode . '-tooLongInitVector']
= [$this->_key, $cipher, $mode, $tooLongInitVector];
}
}
return $result;
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/Magento/Framework/File/Uploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ private function _setUploadFileId($fileId)

preg_match("/^(.*?)\[(.*?)\]$/", $fileId, $file);

if (count($file) > 0 && count($file[0]) > 0 && count($file[1]) > 0) {
if (is_array($file) && count($file) > 0 && count($file[0]) > 0 && count($file[1]) > 0) {
array_shift($file);
$this->_uploadType = self::MULTIPLE_STYLE;

Expand All @@ -547,7 +547,7 @@ private function _setUploadFileId($fileId)

$fileAttributes = $tmpVar;
$this->_file = $fileAttributes;
} elseif (count($fileId) > 0 && isset($_FILES[$fileId])) {
} elseif (!empty($fileId) && isset($_FILES[$fileId])) {
$this->_uploadType = self::SINGLE_STYLE;
$this->_file = $_FILES[$fileId];
} elseif ($fileId == '') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,12 @@ public function getImageType()
if ($this->_fileType) {
return $this->_fileType;
} else {
list($this->_imageSrcWidth, $this->_imageSrcHeight, $this->_fileType) = getimagesize($this->_fileName);
return $this->_fileType;
if ($this->_canProcess()) {
list($this->_imageSrcWidth, $this->_imageSrcHeight, $this->_fileType) = getimagesize($this->_fileName);
return $this->_fileType;
}
}
return null;
}

/**
Expand Down
3 changes: 1 addition & 2 deletions lib/internal/Magento/Framework/Session/SaveHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

use Magento\Framework\App\DeploymentConfig;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Exception\SessionException;
use Magento\Framework\Session\Config\ConfigInterface;

/**
Expand Down Expand Up @@ -53,7 +52,7 @@ public function __construct(

try {
$connection = $saveHandlerFactory->create($saveMethod);
} catch (SessionException $e) {
} catch (\LogicException $e) {
$connection = $saveHandlerFactory->create($default);
$this->setSaveHandler($default);
}
Expand Down
11 changes: 7 additions & 4 deletions setup/src/Magento/Setup/Fixtures/ConfigurableProductsFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,8 @@ private function getSearchTerms()
if ($searchTerms !== null) {
$searchTerms = array_key_exists(0, $searchTerms['search_term'])
? $searchTerms['search_term'] : [$searchTerms['search_term']];
} else {
$searchTerms = [];
}
return $searchTerms;
}
Expand Down Expand Up @@ -845,10 +847,11 @@ private function getDescriptionClosure(
$minAmountOfWordsDescription,
$descriptionPrefix
) {
$count = $searchTerms === null
$countSearchTerms = is_array($searchTerms) ? count($searchTerms) : 0;
$count = !$searchTerms
? 0
: round(
$searchTerms[$index % count($searchTerms)]['count'] * (
$searchTerms[$index % $countSearchTerms]['count'] * (
$configurableProductsCount / ($simpleProductsCount + $configurableProductsCount)
)
);
Expand All @@ -858,8 +861,8 @@ private function getDescriptionClosure(
$maxAmountOfWordsDescription,
$descriptionPrefix . '-' . $index
) .
($index <= ($count * count($searchTerms)) ? ' ' .
$searchTerms[$index % count($searchTerms)]['term'] : '');
($index <= ($count * $countSearchTerms) ? ' ' .
$searchTerms[$index % $countSearchTerms]['term'] : '');
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ public function generate($products, $fixtureMap)
],
],
];
if (count($fixtureMap['website_ids'](1, 0)) === 1) {
$websiteIdsFixtures = $fixtureMap['website_ids'](1, 0);
if ((is_array($websiteIdsFixtures) && count($websiteIdsFixtures) === 1) || $websiteIdsFixtures != null) {
// Get website id from fixture in case when one site is assigned per product
$customTableMap['catalog_product_website'] = [
'fields' => [
Expand Down
3 changes: 2 additions & 1 deletion setup/src/Magento/Setup/Module/I18n/Pack/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ public function generate(
$locale = $this->factory->createLocale($locale);
$dictionary = $this->dictionaryLoader->load($dictionaryPath);

if (!count($dictionary->getPhrases())) {
$phrases = $dictionary->getPhrases();
if (!is_array($phrases) || !count($phrases)) {
throw new \UnexpectedValueException('No phrases have been found by the specified path.');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ public function testGenerateEmptyFile()
->method('load')
->with($dictionaryPath)
->will($this->returnValue($this->dictionaryMock));
$this->dictionaryMock->expects($this->once())
->method('getPhrases')
->will($this->returnValue([]));

$this->_generator->generate($dictionaryPath, $localeString, $mode, $allowDuplicates);
}
Expand Down