Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
emodric committed Mar 30, 2017
2 parents f5824c0 + a5838bd commit 80026c0
Show file tree
Hide file tree
Showing 9 changed files with 154 additions and 5 deletions.
3 changes: 2 additions & 1 deletion autoload.php
Expand Up @@ -120,7 +120,8 @@ public static function autoload( $className )
{
// won't work, as eZDebug isn't initialized yet at that time
// eZDebug::writeError( "Kernel override is enabled, but var/autoload/ezp_override.php has not been generated\nUse bin/php/ezpgenerateautoloads.php -o", 'autoload.php' );
if ( $ezpKernelOverrideClasses = include __DIR__ . '/var/autoload/ezp_override.php' )
$ezpKernelOverridePath = __DIR__ . '/var/autoload/ezp_override.php';
if ( file_exists( $ezpKernelOverridePath ) && $ezpKernelOverrideClasses = include $ezpKernelOverridePath )
{
self::$ezpClasses = array_merge( self::$ezpClasses, $ezpKernelOverrideClasses );
}
Expand Down
6 changes: 6 additions & 0 deletions kernel/classes/eznodeviewfunctions.php
Expand Up @@ -346,6 +346,12 @@ static function generateViewCacheFile( $user, $nodeID, $offset, $layout, $langua
$cacheNameExtra = $user->attribute( 'contentobject_id' ) . '-';
}

// Add the request protocol to the cache key generation
if ( strpos( $viewCacheTweak, 'protocol' ) !== false )
{
$cacheHashArray[] = eZSys::isSSLNow();
}

// Make the cache unique for every case of view parameters
if ( strpos( $viewCacheTweak, 'ignore_viewparameters' ) === false && $viewParameters )
{
Expand Down
6 changes: 3 additions & 3 deletions kernel/common/ezautolinkoperator.php
Expand Up @@ -48,9 +48,9 @@ function formatUri( $url, $max )
*/
function addURILinks( $text, $max, $methods = 'http|https|ftp' )
{
return preg_replace(
"`(?<!href=\"|href='|src=\"|src='|value=\"|value=')($methods):\/\/[\w]+(.[\w]+)([\w\-\.,@?^=%&:\/~\+#;*\(\)\!]*[\w\-\@?^=%&\/~\+#;*\(\)\!])?`e",
'eZAutoLinkOperator::formatUri("$0", '. $max. ')',
return preg_replace_callback(
"`(?<!href=\"|href='|src=\"|src='|value=\"|value=')($methods):\/\/[\w]+(.[\w]+)([\w\-\.,@?^=%&:\/~\+#;*\(\)\!]*[\w\-\@?^=%&\/~\+#;*\(\)\!])?`",
function($matches) use ($max) { return eZAutoLinkOperator::formatUri( $matches[0], $max ); },
$text
);
}
Expand Down
4 changes: 4 additions & 0 deletions kernel/content/ezcontentoperationcollection.php
Expand Up @@ -1373,6 +1373,10 @@ static public function updateObjectState( $objectID, $selectedStateIDList )
$state = eZContentObjectState::fetchById( $selectedStateID );
$object->assignState( $state );
}
eZAudit::writeAudit( 'state-assign', array( 'Content object ID' => $object->attribute( 'id' ),
'Content object name' => $object->attribute( 'name' ),
'Selected State ID Array' => implode( ', ' , $selectedStateIDList ),
'Comment' => 'Updated states of the current object: eZContentOperationCollection::updateObjectState()' ) );
//call appropriate method from search engine
eZSearch::updateObjectState($objectID, $selectedStateIDList);

Expand Down
3 changes: 3 additions & 0 deletions settings/audit.ini
Expand Up @@ -47,6 +47,9 @@ AuditFileNames[role-assign]=role_assign.log
# Who assigns which section at which node (user / section id / section name)
AuditFileNames[section-assign]=section_assign.log

# Who updated the object states
AuditFileNames[state-assign]=state_assign.log

# Who deleted which order in shop (user / order id)
AuditFileNames[order-delete]=order_delete.log

1 change: 1 addition & 0 deletions settings/site.ini
Expand Up @@ -1137,6 +1137,7 @@ CachedViewModes=full;sitemap;pdf
# currently supported settings:
# disabled: Same as setting cache_ttl=0 in template, just a bit more efficient by knowing about it in advance
# pr_user: cache page pr user, more efficient then disabling view cache and using cache-blocks
# protocol: builds different cache based on the request protocol (http vs https)
# ignore_discountlist do not include users shop discountlist in cache hash
# ignore_userroles do not include users roles in cache hash
# ignore_userlimitedlist do not include users limted policy assignement list in cache hash
Expand Down
131 changes: 131 additions & 0 deletions tests/tests/kernel/common/ezautolinkoperator_test.php
@@ -0,0 +1,131 @@
<?php
/**
* File containing the eZAutoLinkOperatorTest class
*
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
* @version //autogentag//
* @package tests
*/

/**
* Test case for eZAutoLinkOperator class
*/
class eZAutoLinkOperatorTest extends ezpTestCase
{
public function __construct()
{
parent::__construct();
$this->setName( "eZAutoLinkOperator Tests" );
}

public function setUp()
{
}

public function tearDown()
{
}

/**
* test autolink operator with simple http url
*/
public function testeZAutoLinkOperatorSimpleHttpFullUrlLink()
{
$maxChars = 32;
$argument = 'Heath ( http://example.com/p/10979 )';
$expectedResult = 'Heath ( <a href="http://example.com/p/10979" title="http://example.com/p/10979">http://example.com/p/10979</a> )';

$this->runModify( 'autolink', $maxChars, $argument, $expectedResult );
}

/**
* test autolink operator with simple https url
*/
public function testeZAutoLinkOperatorSimpleHttpsFullUrlLink()
{
$maxChars = 32;
$argument = 'Heath ( https://example.com/p/10979 )';
$expectedResult = 'Heath ( <a href="https://example.com/p/10979" title="https://example.com/p/10979">https://example.com/p/10979</a> )';

$this->runModify( 'autolink', $maxChars, $argument, $expectedResult );
}

/**
* test autolink operator with simple email address
*/
public function testeZAutoLinkOperatorSimpleEmailLink()
{
$maxChars = 72;
$argument = 'Heath ( heath@example.com )';
$expectedResult = "Heath ( <a href='mailto:heath@example.com'>heath@example.com</a> )";

$this->runModify( 'autolink', $maxChars, $argument, $expectedResult );
}

/**
* test autolink operator with simple ftp url
*/
public function testeZAutoLinkOperatorSimpleFtpFullUrlLink()
{
$maxChars = 72;
$argument = 'Heath ( ftp://example.com/pub/mockbinaryfile.tar.gz )';
$expectedResult = 'Heath ( <a href="ftp://example.com/pub/mockbinaryfile.tar.gz" title="ftp://example.com/pub/mockbinaryfile.tar.gz">ftp://example.com/pub/mockbinaryfile.tar.gz</a> )';

$this->runModify( 'autolink', $maxChars, $argument, $expectedResult );
}

/**
* test autolink operator function
*/
private function runModify( $operatorName, $maxChars, $argument, $expectedResult )
{
// TEST SETUP --------------------------------------------------------
$ini = eZINI::instance();
$defaultAccess = $ini->variable( 'SiteSettings', 'DefaultAccess' );
$this->setSiteAccess( $defaultAccess );

// Make sure to preserve ini settings in case other tests depend on them
$orgRemoveSiteaccess = $ini->variable( 'SiteAccessSettings', 'RemoveSiteAccessIfDefaultAccess' );

// ENABLE RemoveSiteAccessIfDefaultAccess
$ini->setVariable( 'SiteAccessSettings', 'RemoveSiteAccessIfDefaultAccess', 'enabled' );
// -------------------------------------------------------------------

// TEST --------------------------------------------------------------
$operator = new eZAutoLinkOperator();
$tpl = eZTemplate::instance();

$operatorValue = $argument;

$operatorParameters = array();

$namedParameters = array(
'max_chars' => $maxChars
);

$operator->modify(
$tpl, $operatorName, $operatorParameters, '', '', $operatorValue, $namedParameters, false
);

$this->assertEquals( $expectedResult, $operatorValue );
// -------------------------------------------------------------------
// TEST TEAR DOWN ----------------------------------------------------
$ini->setVariable( 'SiteAccessSettings', 'RemoveSiteAccessIfDefaultAccess', $orgRemoveSiteaccess );
eZSys::clearAccessPath();
// -------------------------------------------------------------------
}

/* -----------------------------------------------------------------------
* HELPER FUNCTIONS
* -----------------------------------------------------------------------
*/
private function setSiteAccess( $accessName )
{
eZSiteAccess::change( array( 'name' => $accessName,
'type' => eZSiteAccess::TYPE_URI,
'uri_part' => array( $accessName ) ) );
}
}

?>
Expand Up @@ -83,7 +83,9 @@ public function testRunRegression( $name )
private static function normalizedVarExport( $var )
{
$var = var_export( $var, true );
if ( PHP_VERSION_ID < 50430 )
// 50430 is PHP 5.4.30
// version from 50500 to 50513 are also affected
if ( PHP_VERSION_ID < 50430 || ( PHP_VERSION_ID >= 50500 && PHP_VERSION_ID < 50514 ) )
{
$var = preg_replace( '%(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})%', '$1.000000', $var );
}
Expand Down
1 change: 1 addition & 0 deletions tests/tests/kernel/suite.php
Expand Up @@ -52,6 +52,7 @@ public function __construct()
$this->addTestSuite( 'eZBinaryFileTypeRegression' );
$this->addTestSuite( 'eZContentClassRegression' );
$this->addTestSuite( 'eZURLOperatorTest' );
$this->addTestSuite( 'eZAutoLinkOperatorTest' );
$this->addTestSuite( 'eZNamePatternResolverRegression' );

$this->addTestSuite( 'ezpTopologicalSortTest' );
Expand Down

0 comments on commit 80026c0

Please sign in to comment.