]> git.mxchange.org Git - friendica.git/commitdiff
Merge pull request #5789 from friendica/master
authorHypolite Petovan <hypolite@mrpetovan.com>
Sun, 23 Sep 2018 22:55:20 +0000 (18:55 -0400)
committerGitHub <noreply@github.com>
Sun, 23 Sep 2018 22:55:20 +0000 (18:55 -0400)
Update develop from master-2019.09

16 files changed:
mod/editpost.php
mod/message.php
src/Core/Cache/ArrayCache.php
src/Core/Worker.php
src/Model/Item.php
src/Object/Post.php
tests/src/Core/Cache/CacheTest.php
tests/src/Core/Lock/ArrayCacheLockDriverTest.php
tests/src/Core/Lock/LockTest.php
tests/src/Core/Lock/MemcacheCacheLockDriverTest.php
tests/src/Core/Lock/MemcachedCacheLockDriverTest.php
tests/src/Core/Lock/RedisCacheLockDriverTest.php
tests/src/Core/Lock/SemaphoreLockDriverTest.php
view/theme/frio/js/modal.js
view/theme/frio/js/textedit.js
view/theme/frio/templates/jot.tpl

index 258585ef1c3b95cba2e9e1914bcde84014e19100..9f4aee31d6c63421a2692990b123a3926ac17ec8 100644 (file)
@@ -21,12 +21,18 @@ function editpost_content(App $a)
        }
 
        $post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
+       $return_url = (($a->argc > 2) ? base64_decode($a->argv[2]) : '');
 
        if (!$post_id) {
                notice(L10n::t('Item not found') . EOL);
                return;
        }
 
+       // Fallback to SESSION return_path
+       if (empty($return_url)) {
+               $return_url = $_SESSION['return_url'];
+       }
+
        $fields = ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid',
                'type', 'body', 'title', 'file', 'wall', 'post-type'];
 
@@ -95,7 +101,7 @@ function editpost_content(App $a)
 
        $o .= replace_macros($tpl, [
                '$is_edit' => true,
-               '$return_path' => $_SESSION['return_url'],
+               '$return_path' => $return_url,
                '$action' => 'item',
                '$share' => L10n::t('Save'),
                '$upload' => L10n::t('Upload photo'),
index 223976ddbef637731dc24877e22c14735622924a..d0a583967b047c3a61a6261f5dd10f9f6657693c 100644 (file)
@@ -92,7 +92,7 @@ function message_post(App $a)
                $a->argc = 2;
                $a->argv[1] = 'new';
        } else {
-               goaway($_SESSION['return_url']);
+               goaway($a->cmd . '/' . $ret);
        }
 }
 
index b1982871487c241830dea1d70e5eb6a0750cd2ac..d1302c1d6ec327d5f04a0a570b58c4da747954b5 100644 (file)
@@ -53,6 +53,11 @@ class ArrayCache extends AbstractCacheDriver implements IMemoryCacheDriver
         */
        public function clear($outdated = true)
        {
+               // Array doesn't support TTL so just don't delete something
+               if ($outdated) {
+                       return true;
+               }
+
                $this->cachedData = [];
                return true;
        }
index 9dd973728dcbfb6c8256883d538c624e62b50855..3400f00ae1755229a24a20e16fc6844f1c7592c5 100644 (file)
@@ -117,12 +117,14 @@ class Worker
                                // Count active workers and compare them with a maximum value that depends on the load
                                if (self::tooMuchWorkers()) {
                                        logger('Active worker limit reached, quitting.', LOGGER_DEBUG);
+                                       Lock::release('worker');
                                        return;
                                }
 
                                // Check free memory
                                if ($a->min_memory_reached()) {
                                        logger('Memory limit reached, quitting.', LOGGER_DEBUG);
+                                       Lock::release('worker');
                                        return;
                                }
                                Lock::release('worker');
index d10a211a59511d98b579583d748c2ff004471a4f..748dccadfab598c0385d23fbf2e83e924aa95917 100644 (file)
@@ -1936,6 +1936,7 @@ class Item extends BaseObject
                } else {
                        // This shouldn't happen.
                        logger('Could not insert activity for URI ' . $item['uri'] . ' - should not happen');
+                       Lock::release('item_insert_activity');
                        return false;
                }
                if ($locked) {
index 038ca270d79dddc35bce9158ebc404e631502e1a..c52078e521ef046150abb72fcb96782bb2ef0603 100644 (file)
@@ -157,7 +157,7 @@ class Post extends BaseObject
                        if ($item["event-id"] != 0) {
                                $edpost = ["events/event/" . $item['event-id'], L10n::t("Edit")];
                        } else {
-                               $edpost = ["editpost/" . $item['id'], L10n::t("Edit")];
+                               $edpost = ["editpost/" . $item['id'] . "/" . base64_encode($a->cmd), L10n::t("Edit")];
                        }
                        $dropping = in_array($item['uid'], [0, local_user()]);
                } else {
index 105142f0b74250eb048d10a87806d10a78b3dd8c..5c56c2072f4f13add69b2552cc03531fedadab7f 100644 (file)
@@ -81,18 +81,32 @@ abstract class CacheTest extends DatabaseTest
                        '3_value1' => $this->instance->get('3_value1'),
                ]);
 
+               $this->assertTrue($this->instance->clear());
+
+               $this->assertEquals([
+                       '1_value1' => 'ipsum lorum1',
+                       '1_value2' => 'ipsum lorum2',
+                       '2_value1' => 'ipsum lorum3',
+                       '3_value1' => 'ipsum lorum4',
+               ], [
+                       '1_value1' => $this->instance->get('1_value1'),
+                       '1_value2' => $this->instance->get('1_value2'),
+                       '2_value1' => $this->instance->get('2_value1'),
+                       '3_value1' => $this->instance->get('3_value1'),
+               ]);
+
                $this->assertTrue($this->instance->clear(false));
 
                $this->assertEquals([
                        '1_value1' => null,
                        '1_value2' => null,
-                       '2_value1' => null,
-                       '3_value1' => null,
+                       '2_value3' => null,
+                       '3_value4' => null,
                ], [
                        '1_value1' => $this->instance->get('1_value1'),
                        '1_value2' => $this->instance->get('1_value2'),
-                       '2_value1' => $this->instance->get('2_value1'),
-                       '3_value1' => $this->instance->get('3_value1'),
+                       '2_value3' => $this->instance->get('2_value3'),
+                       '3_value4' => $this->instance->get('3_value4'),
                ]);
        }
 
index dc044f5c5c007ce5cd1e839cfbc2eb09fe908646..671341718b78168e5d15ffaadcd05d50747ed34d 100644 (file)
@@ -8,21 +8,9 @@ use Friendica\Core\Lock\CacheLockDriver;
 
 class ArrayCacheLockDriverTest extends LockTest
 {
-       /**
-        * @var \Friendica\Core\Cache\IMemoryCacheDriver
-        */
-       private $cache;
-
        protected function getInstance()
        {
-               $this->cache = new ArrayCache();
-               return new CacheLockDriver($this->cache);
-       }
-
-       public function tearDown()
-       {
-               $this->cache->clear();
-               parent::tearDown();
+               return new CacheLockDriver(new ArrayCache());
        }
 
        public function testLockTTL()
index 9698f0bdea42ef587a0692e5989db16c7b927c1b..a7bbea265f1a9fb9caf8e80ab3cc01b215864cb5 100644 (file)
@@ -19,6 +19,7 @@ abstract class LockTest extends DatabaseTest
        {
                parent::setUp();
                $this->instance = $this->getInstance();
+               $this->instance->releaseAll();
 
                // Reusable App object
                $this->app = BaseObject::getApp();
@@ -31,11 +32,18 @@ abstract class LockTest extends DatabaseTest
                Config::set('system', 'theme', 'system_theme');
        }
 
+       protected function tearDown()
+       {
+               parent::tearDown();
+               $this->instance->releaseAll();
+       }
+
        /**
         * @small
         */
        public function testLock() {
-               $this->instance->acquireLock('foo', 1);
+               $this->assertFalse($this->instance->isLocked('foo'));
+               $this->assertTrue($this->instance->acquireLock('foo', 1));
                $this->assertTrue($this->instance->isLocked('foo'));
                $this->assertFalse($this->instance->isLocked('bar'));
        }
@@ -44,7 +52,8 @@ abstract class LockTest extends DatabaseTest
         * @small
         */
        public function testDoubleLock() {
-               $this->instance->acquireLock('foo', 1);
+               $this->assertFalse($this->instance->isLocked('foo'));
+               $this->assertTrue($this->instance->acquireLock('foo', 1));
                $this->assertTrue($this->instance->isLocked('foo'));
                // We already locked it
                $this->assertTrue($this->instance->acquireLock('foo', 1));
@@ -54,7 +63,8 @@ abstract class LockTest extends DatabaseTest
         * @small
         */
        public function testReleaseLock() {
-               $this->instance->acquireLock('foo', 1);
+               $this->assertFalse($this->instance->isLocked('foo'));
+               $this->assertTrue($this->instance->acquireLock('foo', 1));
                $this->assertTrue($this->instance->isLocked('foo'));
                $this->instance->releaseLock('foo');
                $this->assertFalse($this->instance->isLocked('foo'));
@@ -64,9 +74,9 @@ abstract class LockTest extends DatabaseTest
         * @small
         */
        public function testReleaseAll() {
-               $this->instance->acquireLock('foo', 1);
-               $this->instance->acquireLock('bar', 1);
-               $this->instance->acquireLock('nice', 1);
+               $this->assertTrue($this->instance->acquireLock('foo', 1));
+               $this->assertTrue($this->instance->acquireLock('bar', 1));
+               $this->assertTrue($this->instance->acquireLock('nice', 1));
 
                $this->assertTrue($this->instance->isLocked('foo'));
                $this->assertTrue($this->instance->isLocked('bar'));
@@ -83,9 +93,12 @@ abstract class LockTest extends DatabaseTest
         * @small
         */
        public function testReleaseAfterUnlock() {
-               $this->instance->acquireLock('foo', 1);
-               $this->instance->acquireLock('bar', 1);
-               $this->instance->acquireLock('nice', 1);
+               $this->assertFalse($this->instance->isLocked('foo'));
+               $this->assertFalse($this->instance->isLocked('bar'));
+               $this->assertFalse($this->instance->isLocked('nice'));
+               $this->assertTrue($this->instance->acquireLock('foo', 1));
+               $this->assertTrue($this->instance->acquireLock('bar', 1));
+               $this->assertTrue($this->instance->acquireLock('nice', 1));
 
                $this->instance->releaseLock('foo');
 
@@ -103,10 +116,12 @@ abstract class LockTest extends DatabaseTest
         * @medium
         */
        function testLockTTL() {
+               $this->assertFalse($this->instance->isLocked('foo'));
+               $this->assertFalse($this->instance->isLocked('bar'));
 
                // TODO [nupplaphil] - Because of the Datetime-Utils for the database, we have to wait a FULL second between the checks to invalidate the db-locks/cache
-               $this->instance->acquireLock('foo', 1, 1);
-               $this->instance->acquireLock('bar', 1, 3);
+               $this->assertTrue($this->instance->acquireLock('foo', 2, 1));
+               $this->assertTrue($this->instance->acquireLock('bar', 2, 3));
 
                $this->assertTrue($this->instance->isLocked('foo'));
                $this->assertTrue($this->instance->isLocked('bar'));
index c54cf9c59941ab4ce79441d2a9a9b4218bee58e5..ca9b9b46391ae3cf3320b26461b9e5f34a8de187 100644 (file)
@@ -3,7 +3,6 @@
 
 namespace Friendica\Test\src\Core\Lock;
 
-
 use Friendica\Core\Cache\CacheDriverFactory;
 use Friendica\Core\Lock\CacheLockDriver;
 
@@ -12,20 +11,8 @@ use Friendica\Core\Lock\CacheLockDriver;
  */
 class MemcacheCacheLockDriverTest extends LockTest
 {
-       /**
-        * @var \Friendica\Core\Cache\IMemoryCacheDriver
-        */
-       private $cache;
-
        protected function getInstance()
        {
-               $this->cache = CacheDriverFactory::create('memcache');
-               return new CacheLockDriver($this->cache);
-       }
-
-       public function tearDown()
-       {
-               $this->cache->clear();
-               parent::tearDown();
+               return new CacheLockDriver(CacheDriverFactory::create('memcache'));
        }
 }
index 27886261b2591080ed94a7c0bfc5438520fa38c6..71311d5baa36d5f6fa53022daf255730c73b82a6 100644 (file)
@@ -3,7 +3,6 @@
 
 namespace Friendica\Test\src\Core\Lock;
 
-
 use Friendica\Core\Cache\CacheDriverFactory;
 use Friendica\Core\Lock\CacheLockDriver;
 
@@ -12,20 +11,8 @@ use Friendica\Core\Lock\CacheLockDriver;
  */
 class MemcachedCacheLockDriverTest extends LockTest
 {
-       /**
-        * @var \Friendica\Core\Cache\IMemoryCacheDriver
-        */
-       private $cache;
-
        protected function getInstance()
        {
-               $this->cache = CacheDriverFactory::create('memcached');
-               return new CacheLockDriver($this->cache);
-       }
-
-       public function tearDown()
-       {
-               $this->cache->clear();
-               parent::tearDown();
+               return new CacheLockDriver(CacheDriverFactory::create('memcached'));
        }
 }
index eaafbf4e443007e505c55f474f7a8c67a978d232..43cedb9cbc323eaa2855f04b6e27cecac2c1e92a 100644 (file)
@@ -3,7 +3,6 @@
 
 namespace Friendica\Test\src\Core\Lock;
 
-
 use Friendica\Core\Cache\CacheDriverFactory;
 use Friendica\Core\Lock\CacheLockDriver;
 
@@ -12,21 +11,9 @@ use Friendica\Core\Lock\CacheLockDriver;
  */
 class RedisCacheLockDriverTest extends LockTest
 {
-       /**
-        * @var \Friendica\Core\Cache\IMemoryCacheDriver
-        */
-       private $cache;
-
        protected function getInstance()
        {
-               $this->cache = CacheDriverFactory::create('redis');
-               return new CacheLockDriver($this->cache);
+               return new CacheLockDriver(CacheDriverFactory::create('redis'));
 
        }
-
-       public function tearDown()
-       {
-               $this->cache->clear();
-               parent::tearDown();
-       }
 }
index cd4b9157334a1da5119e2adc9d889229ddd7e64d..39f0763fb13c0b015c5c1a85677a42431879fa1e 100644 (file)
@@ -2,26 +2,13 @@
 
 namespace Friendica\Test\src\Core\Lock;
 
-
 use Friendica\Core\Lock\SemaphoreLockDriver;
 
 class SemaphoreLockDriverTest extends LockTest
 {
-       /**
-        * @var \Friendica\Core\Lock\SemaphoreLockDriver
-        */
-       private $semaphoreLockDriver;
-
        protected function getInstance()
        {
-               $this->semaphoreLockDriver = new SemaphoreLockDriver();
-               return $this->semaphoreLockDriver;
-       }
-
-       public function tearDown()
-       {
-               $this->semaphoreLockDriver->releaseAll();
-               parent::tearDown();
+               return new SemaphoreLockDriver();
        }
 
        function testLockTTL()
index 9a15cab52a67862845b5482dbd69bb52d13637bd..80694b64da52971d890adf9be0fa130975b15b0d 100644 (file)
@@ -343,6 +343,8 @@ function toggleJotNav (elm) {
        // For some some tab panels we need to execute other js functions.
        if (tabpanel === "jot-preview-content") {
                preview_post();
+               // Make Share button visivle in preview
+               $('#jot-preview-share').removeClass("minimize").attr("aria-hidden" ,"false");
        } else if (tabpanel === "jot-fbrowser-wrapper") {
                $(function() {
                        Dialog.showJot();
index 2079c20cdc40a12080da8546045253ecf25a42af..ad5f9502341bc7e5fa5b4e205fa3ebc68e9eaabd 100644 (file)
@@ -27,6 +27,22 @@ function insertFormatting(BBcode, id) {
        return true;
 }
 
+function insertFormattingToPost(BBcode) {
+       textarea = document.getElementById("profile-jot-text");
+       if (document.selection) {
+               textarea.focus();
+               selected = document.selection.createRange();
+               selected.text = "[" + BBcode + "]" + selected.text + "[/" + BBcode + "]";
+       } else if (textarea.selectionStart || textarea.selectionStart == "0") {
+               var start = textarea.selectionStart;
+               var end = textarea.selectionEnd;
+               textarea.value = textarea.value.substring(0, start) + "[" + BBcode + "]" + textarea.value.substring(start, end) + "[/" + BBcode + "]" + textarea.value.substring(end, textarea.value.length);
+       }
+
+       $(textarea).trigger('change');
+
+       return true;
+}
 
 function showThread(id) {
        $("#collapsed-comments-" + id).show()
index 423be5a5d99b8f12bd5190dcf4bf3afe518d051d..14f383ac8d346e8d4e3867616474a0ce22c40f54 100644 (file)
                                        </div>
 
                                        <ul id="profile-jot-submit-wrapper" class="jothidden nav nav-pills">
+                                               <li role="presentation"><button type="button" class="hidden-xs btn-link icon underline" style="cursor: pointer;" aria-label="{{$eduline}}" title="{{$eduline}}" onclick="insertFormattingToPost('u');"><i class="fa fa-underline"></i></button></li>
+                                               <li role="presentation"><button type="button" class="hidden-xs btn-link icon italic" style="cursor: pointer;" aria-label="{{$editalic}}" title="{{$editalic}}" onclick="insertFormattingToPost('i');"><i class="fa fa-italic"></i></button></li>
+                                               <li role="presentation"><button type="button" class="hidden-xs btn-link icon bold" style="cursor: pointer;" aria-label="{{$edbold}}" title="{{$edbold}}" onclick="insertFormattingToPost('b');"><i class="fa fa-bold"></i></button></li>
+                                               <li role="presentation"><button type="button" class="hidden-xs btn-link icon quote" style="cursor: pointer;" aria-label="{{$edquote}}" title="{{$edquote}}" onclick="insertFormattingToPost('quote');"><i class="fa fa-quote-left"></i></button></li>
                                                <li role="presentation"><button type="button" class="btn-link" id="profile-link"  ondragenter="return linkdropper(event);" ondragover="return linkdropper(event);" ondrop="linkdrop(event);" onclick="jotGetLink();" title="{{$weblink}}"><i class="fa fa-link"></i></button></li>
                                                <li role="presentation"><button type="button" class="btn-link" id="profile-video" onclick="jotVideoURL();" title="{{$video}}"><i class="fa fa-film" aria-hidden="true"></i></button></li>
                                                <li role="presentation"><button type="button" class="btn-link" id="profile-audio" onclick="jotAudioURL();" title="{{$audio}}"><i class="fa fa-music" aria-hidden="true"></i></button></li>
                                </div>
 
                                <div id="jot-preview-content" class="minimize" aria-labelledby="jot-preview-lnk" role="tabpanel" aria-hidden="true"></div>
+
+                               <div id="jot-preview-share" class="minimize" aria-labelledby="jot-preview-lnk" role="tabpanel" aria-hidden="true">
+                                       <ul id="profile-jot-preview-submit-wrapper" class="jothidden nav nav-pills">
+                                               <li role="presentation" class="pull-right"><button class="btn btn-primary" type="submit" id="profile-jot-peview-submit" name="submit" ><i class="fa fa-slideshare fa-fw" aria-hidden="true"></i> {{$share}}</button></li>
+                                       </ul>
+                               </div>
+
                        </form>
 
                        <div id="jot-fbrowser-wrapper" class="minimize" aria-labelledby="jot-browser-link" role="tabpanel" aria-hidden="true"></div>