Skip to content

Commit

Permalink
Merge pull request #12796 from jeabakker/misc-fixes
Browse files Browse the repository at this point in the history
Misc fixes
  • Loading branch information
jdalsem committed Aug 28, 2019
2 parents 912fb8f + c8a4106 commit 719b7b0
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 18 deletions.
2 changes: 1 addition & 1 deletion engine/classes/Elgg/Cache/SimpleCache.php
Expand Up @@ -149,7 +149,7 @@ private function getPath() {
* @return bool
*/
public function invalidate() {
elgg_delete_directory($this->getPath());
elgg_delete_directory($this->getPath(), true);

$time = time();
$this->config->save("simplecache_lastupdate", $time);
Expand Down
13 changes: 10 additions & 3 deletions engine/lib/filestore.php
Expand Up @@ -70,13 +70,14 @@ function elgg_save_resized_image($source, $destination = null, array $params = [
/**
* Delete a directory and all its contents
*
* @param string $directory Directory to delete
* @param string $directory Directory to delete
* @param bool $leave_base_directory Leave the base directory intact (default: false)
*
* @return bool
*
* @since 3.1
*/
function elgg_delete_directory(string $directory) {
function elgg_delete_directory(string $directory, bool $leave_base_directory = false) {

if (!file_exists($directory)) {
return true;
Expand Down Expand Up @@ -109,8 +110,14 @@ function elgg_delete_directory(string $directory) {
}
}

// remove empty directory
// close file handler
closedir($handle);

if ($leave_base_directory) {
return true;
}

// remove empty directory
return rmdir($directory);
}

Expand Down
26 changes: 26 additions & 0 deletions engine/tests/phpunit/unit/Elgg/Cache/SimpleCacheUnitTest.php
Expand Up @@ -61,5 +61,31 @@ public function testCanEnableSimplecache() {
_elgg_config()->save('simplecache_enabled', $is_enabled);

}

public function testInvalidateSimplecacheSymlinked() {

if (stripos(PHP_OS, 'WIN') !== false) {
$this->markTestSkipped('Unable to test symlinks on Windows');
}

$is_enabled = _elgg_config()->simplecache_enabled;
_elgg_config()->save('simplecache_enabled', true);

$this->assertTrue(_elgg_services()->simpleCache->isEnabled());

// create symlink
$this->assertTrue(_elgg_symlink_cache());

// invalidate cache
_elgg_services()->simpleCache->invalidate();

// ensure symlink still works
$this->assertTrue(_elgg_is_cache_symlinked());

_elgg_config()->save('simplecache_enabled', $is_enabled);

// cleanup symlink
$this->assertTrue(unlink(elgg_get_root_path() . 'cache'));
}

}
7 changes: 3 additions & 4 deletions mod/discussions/views/default/resources/discussion/add.php
Expand Up @@ -19,10 +19,9 @@
$body_vars = discussion_prepare_form_vars();
$content = elgg_view_form('discussion/save', [], $body_vars);

$params = [
'content' => $content,
$body = elgg_view_layout('default', [
'title' => $title,
];
$body = elgg_view_layout('default', $params);
'content' => $content,
]);

echo elgg_view_page($title, $body);
2 changes: 1 addition & 1 deletion mod/discussions/views/default/resources/discussion/all.php
Expand Up @@ -6,8 +6,8 @@
$content = elgg_view('discussion/listing/all');

$body = elgg_view_layout('default', [
'content' => $content,
'title' => $title,
'content' => $content,
]);

echo elgg_view_page($title, $body);
7 changes: 3 additions & 4 deletions mod/discussions/views/default/resources/discussion/edit.php
Expand Up @@ -14,10 +14,9 @@
$body_vars = discussion_prepare_form_vars($topic);
$content = elgg_view_form('discussion/save', [], $body_vars);

$params = [
'content' => $content,
$body = elgg_view_layout('default', [
'title' => $title,
];
$body = elgg_view_layout('default', $params);
'content' => $content,
]);

echo elgg_view_page($title, $body);
Expand Up @@ -20,8 +20,8 @@
]);

$body = elgg_view_layout('default', [
'content' => $content,
'title' => $title,
'content' => $content,
]);

echo elgg_view_page($title, $body);
4 changes: 2 additions & 2 deletions mod/discussions/views/default/resources/discussion/owner.php
Expand Up @@ -34,9 +34,9 @@
'entity' => $target,
]);

$body = elgg_view_layout('content', [
'content' => $content,
$body = elgg_view_layout('default', [
'title' => $title,
'content' => $content,
]);

echo elgg_view_page($title, $body);
5 changes: 3 additions & 2 deletions mod/discussions/views/default/resources/discussion/view.php
Expand Up @@ -15,10 +15,11 @@

$title = $topic->getDisplayName();

$body = elgg_view_layout('content', [
'content' => $content,
$body = elgg_view_layout('default', [
'title' => $title,
'content' => $content,
'entity' => $topic,
'filter_id' => 'discussion/view',
]);

echo elgg_view_page($title, $body);

0 comments on commit 719b7b0

Please sign in to comment.