Browse Source

Fix a memory leak in the Ajax Controller

Fix old and dead code
Rename a few core functions
Update the dependencies
pull/1169/head
Timothée Jaussoin 3 years ago
parent
commit
9b3a054b99
  1. 2
      app/Contact.php
  2. 90
      app/helpers/UtilsHelper.php
  3. 32
      composer.lock
  4. 2
      lib/moxl/src/Xec/Action/Avatar/Get.php
  5. 2
      lib/moxl/src/Xec/Action/Vcard/Get.php
  6. 6
      lib/moxl/src/Xec/Handler.php
  7. 5
      src/Movim/Bootstrap.php
  8. 1
      src/Movim/Console/DaemonCommand.php
  9. 14
      src/Movim/Controller/Ajax.php
  10. 1
      src/Movim/Daemon/Api.php
  11. 3
      src/Movim/Daemon/Core.php
  12. 8
      src/Movim/Widget/Base.php

2
app/Contact.php

@ -112,7 +112,7 @@ class Contact extends Model
}
}
public function createThumbnails()
public function saveBinAvatar()
{
if (!$this->photobin) {
return;

90
app/helpers/UtilsHelper.php

@ -529,96 +529,6 @@ function getPresencesTxt()
];
}
function getMood()
{
return [
'afraid' => __('mood.afraid'), // Impressed with fear or apprehension; in fear; apprehensive.
'amazed' => __('mood.amazed'), // Astonished; confounded with fear, surprise or wonder.
'amorous' => __('mood.amorous'), // Inclined to love; having a propensity to love, or to sexual enjoyment; loving, fond, affectionate, passionate, lustful, sexual, etc.
'angry' => __('mood.angry'), // Displaying or feeling anger, i.e., a strong feeling of displeasure, hostility or antagonism towards someone or something, usually combined with an urge to harm.
'annoyed' => __('mood.annoyed'), // To be disturbed or irritated, especially by continued or repeated acts.
'anxious' => __('mood.anxious'), // Full of anxiety or disquietude; greatly concerned or solicitous, esp. respecting something future or unknown; being in painful suspense.
'aroused' => __('mood.aroused'), // To be stimulated in one's feelings, especially to be sexually stimulated.
'ashamed' => __('mood.ashamed'), // Feeling shame or guilt.
'bored' => __('mood.bored'), // Suffering from boredom; uninterested, without attention.
'brave' => __('mood.brave'), // Strong in the face of fear; courageous.
'calm' => __('mood.calm'), // Peaceful, quiet.
'cautious' => __('mood.cautious'), // Taking care or caution; tentative.
'cold' => __('mood.cold'), // Feeling the sensation of coldness, especially to the point of discomfort.
'confident' => __('mood.confident'), // Feeling very sure of or positive about something, especially about one's own capabilities.
'confused' => __('mood.confused'), // Chaotic, jumbled or muddled.
'contemplative' => __('mood.contemplative'), // Feeling introspective or thoughtful.
'contented' => __('mood.contented'), // Pleased at the satisfaction of a want or desire; satisfied.
'cranky' => __('mood.cranky'), // Grouchy, irritable; easily upset.
'crazy' => __('mood.crazy'), // Feeling out of control; feeling overly excited or enthusiastic.
'creative' => __('mood.creative'), // Feeling original, expressive, or imaginative.
'curious' => __('mood.curious'), // Inquisitive; tending to ask questions, investigate, or explore.
'dejected' => __('mood.dejected'), // Feeling sad and dispirited.
'depressed' => __('mood.depressed'), // Severely despondent and unhappy.
'disappointed' => __('mood.disappointed'), // Defeated of expectation or hope; let down.
'disgusted' => __('mood.disgusted'), // Filled with disgust; irritated and out of patience.
'dismayed' => __('mood.dismayed'), // Feeling a sudden or complete loss of courage in the face of trouble or danger.
'distracted' => __('mood.distracted'), // Having one's attention diverted; preoccupied.
'embarrassed' => __('mood.embarrassed'), // Having a feeling of shameful discomfort.
'envious' => __('mood.envious'), // Feeling pain by the excellence or good fortune of another.
'excited' => __('mood.excited'), // Having great enthusiasm.
'flirtatious' => __('mood.flirtatious'), // In the mood for flirting.
'frustrated' => __('mood.frustrated'), // Suffering from frustration; dissatisfied, agitated, or discontented because one is unable to perform an action or fulfill a desire.
'grateful' => __('mood.grateful'), // Feeling appreciation or thanks.
'grieving' => __('mood.grieving'), // Feeling very sad about something, especially something lost; mournful; sorrowful.
'grumpy' => __('mood.grumpy'), // Unhappy and irritable.
'guilty' => __('mood.guilty'), // Feeling responsible for wrongdoing; feeling blameworthy.
'happy' => __('mood.happy'), // Experiencing the effect of favourable fortune; having the feeling arising from the consciousness of well-being or of enjoyment; enjoying good of any kind, as peace, tranquillity, comfort; contented; joyous.
'hopeful' => __('mood.hopeful'), // Having a positive feeling, belief, or expectation that something wished for can or will happen.
'hot' => __('mood.hot'), // Feeling the sensation of heat, especially to the point of discomfort.
'humbled' => __('mood.humbled'), // Having or showing a modest or low estimate of one's own importance; feeling lowered in dignity or importance.
'humiliated' => __('mood.humiliated'), // Feeling deprived of dignity or self-respect.
'hungry' => __('mood.hungry'), // Having a physical need for food.
'hurt' => __('mood.hurt'), // Wounded, injured, or pained, whether physically or emotionally.
'impressed' => __('mood.impressed'), // Favourably affected by something or someone.
'in_awe' => __('mood.in_awe'), // Feeling amazement at something or someone; or feeling a combination of fear and reverence.
'in_love' => __('mood.in_love'), // Feeling strong affection, care, liking, or attraction..
'indignant' => __('mood.indignant'), // Showing anger or indignation, especially at something unjust or wrong.
'interested' => __('mood.interested'), // Showing great attention to something or someone; having or showing interest.
'intoxicated' => __('mood.intoxicated'), // Under the influence of alcohol; drunk.
'invincible' => __('mood.invincible'), // Feeling as if one cannot be defeated, overcome or denied.
'jealous' => __('mood.jealous'), // Fearful of being replaced in position or affection.
'lonely' => __('mood.lonely'), // Feeling isolated, empty, or abandoned.
'lost' => __('mood.lost'), // Unable to find one's way, either physically or emotionally.
'lucky' => __('mood.lucky'), // Feeling as if one will be favored by luck.
'mean' => __('mood.mean'), // Causing or intending to cause intentional harm; bearing ill will towards another; cruel; malicious.
'moody' => __('mood.moody'), // Given to sudden or frequent changes of mind or feeling; temperamental.
'nervous' => __('mood.nervous'), // Easily agitated or alarmed; apprehensive or anxious.
'neutral' => __('mood.neutral'), // Not having a strong mood or emotional state.
'offended' => __('mood.offended'), // Feeling emotionally hurt, displeased, or insulted.
'outraged' => __('mood.outraged'), // Feeling resentful anger caused by an extremely violent or vicious attack, or by an offensive, immoral, or indecent act.
'playful' => __('mood.playful'), // Interested in play; fun, recreational, unserious, lighthearted; joking, silly.
'proud' => __('mood.proud'), // Feeling a sense of one's own worth or accomplishment.
'relaxed' => __('mood.relaxed'), // Having an easy-going mood; not stressed; calm.
'relieved' => __('mood.relieved'), // Feeling uplifted because of the removal of stress or discomfort.
'remorseful' => __('mood.remorseful'), // Feeling regret or sadness for doing something wrong.
'restless' => __('mood.restless'), // Without rest; unable to be still or quiet; uneasy; continually moving.
'sad' => __('mood.sad'), // Feeling sorrow; sorrowful, mournful.
'sarcastic' => __('mood.sarcastic'), // Mocking and ironical.
'satisfied' => __('mood.satisfied'), // Pleased at the fulfillment of a need or desire.
'serious' => __('mood.serious'), // Without humor or expression of happiness; grave in manner or disposition; earnest; thoughtful; solemn.
'shocked' => __('mood.shocked'), // Surprised, startled, confused, or taken aback.
'shy' => __('mood.shy'), // Feeling easily frightened or scared; timid; reserved or coy.
'sick' => __('mood.sick'), // Feeling in poor health; ill.
'sleepy' => __('mood.sleepy'), // Feeling the need for sleep.
'spontaneous' => __('mood.spontaneous'), // Acting without planning; natural; impulsive.
'stressed' => __('mood.stressed'), // Suffering emotional pressure.
'strong' => __('mood.strong'), // Capable of producing great physical force; or, emotionally forceful, able, determined, unyielding.
'surprised' => __('mood.surprised'), // Experiencing a feeling caused by something unexpected.
'thankful' => __('mood.thankful'), // Showing appreciation or gratitude.
'thirsty' => __('mood.thirsty'), // Feeling the need to drink.
'tired' => __('mood.tired'), // In need of rest or sleep.
'undefined' => __('mood.undefined'), // [Feeling any emotion not defined here.]
'weak' => __('mood.weak'), // Lacking in force or ability, either physical or emotional.
'worried' => __('mood.worried') // Thinking about unpleasant things that have happened or that might happen; feeling afraid and unhappy.
];
}
/**
* Map the XMPP form vars to Material icons
*/

32
composer.lock

@ -68,16 +68,16 @@
},
{
"name": "cakephp/core",
"version": "4.4.10",
"version": "4.4.11",
"source": {
"type": "git",
"url": "https://github.com/cakephp/core.git",
"reference": "20e50de2f461b5983a1a1296fe5c3762857b9edd"
"reference": "3730ce60f0153b609c9d756fe1b60978bc9c9fee"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/cakephp/core/zipball/20e50de2f461b5983a1a1296fe5c3762857b9edd",
"reference": "20e50de2f461b5983a1a1296fe5c3762857b9edd",
"url": "https://api.github.com/repos/cakephp/core/zipball/3730ce60f0153b609c9d756fe1b60978bc9c9fee",
"reference": "3730ce60f0153b609c9d756fe1b60978bc9c9fee",
"shasum": ""
},
"require": {
@ -121,20 +121,20 @@
"issues": "https://github.com/cakephp/cakephp/issues",
"source": "https://github.com/cakephp/core"
},
"time": "2022-10-07T16:40:13+00:00"
"time": "2023-02-09T19:55:09+00:00"
},
{
"name": "cakephp/database",
"version": "4.4.10",
"version": "4.4.11",
"source": {
"type": "git",
"url": "https://github.com/cakephp/database.git",
"reference": "c12a8f30f802968a885774e2ac3c099f470bf07c"
"reference": "904c09ac6ac41bddd65ef62f11676870aa8837a0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/cakephp/database/zipball/c12a8f30f802968a885774e2ac3c099f470bf07c",
"reference": "c12a8f30f802968a885774e2ac3c099f470bf07c",
"url": "https://api.github.com/repos/cakephp/database/zipball/904c09ac6ac41bddd65ef62f11676870aa8837a0",
"reference": "904c09ac6ac41bddd65ef62f11676870aa8837a0",
"shasum": ""
},
"require": {
@ -177,11 +177,11 @@
"issues": "https://github.com/cakephp/cakephp/issues",
"source": "https://github.com/cakephp/database"
},
"time": "2023-01-03T20:29:38+00:00"
"time": "2023-01-31T17:52:27+00:00"
},
{
"name": "cakephp/datasource",
"version": "4.4.10",
"version": "4.4.11",
"source": {
"type": "git",
"url": "https://github.com/cakephp/datasource.git",
@ -239,16 +239,16 @@
},
{
"name": "cakephp/utility",
"version": "4.4.10",
"version": "4.4.11",
"source": {
"type": "git",
"url": "https://github.com/cakephp/utility.git",
"reference": "aa7bba6c39b56751f5c917464f113c924d4ba10f"
"reference": "3694d44728fb00ab474d9e031d51ed47f3d0e31c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/cakephp/utility/zipball/aa7bba6c39b56751f5c917464f113c924d4ba10f",
"reference": "aa7bba6c39b56751f5c917464f113c924d4ba10f",
"url": "https://api.github.com/repos/cakephp/utility/zipball/3694d44728fb00ab474d9e031d51ed47f3d0e31c",
"reference": "3694d44728fb00ab474d9e031d51ed47f3d0e31c",
"shasum": ""
},
"require": {
@ -294,7 +294,7 @@
"issues": "https://github.com/cakephp/cakephp/issues",
"source": "https://github.com/cakephp/utility"
},
"time": "2022-11-06T06:40:44+00:00"
"time": "2023-01-07T14:14:31+00:00"
},
{
"name": "cboden/ratchet",

2
lib/moxl/src/Xec/Action/Avatar/Get.php

@ -20,7 +20,7 @@ class Get extends Action
{
$contact = \App\Contact::firstOrNew(['id' => $this->_to]);
$contact->photobin = (string)$stanza->pubsub->items->item->data;
$contact->createThumbnails();
$contact->saveBinAvatar();
$contact->save();
$this->pack($contact);

2
lib/moxl/src/Xec/Action/Vcard/Get.php

@ -34,7 +34,7 @@ class Get extends Action
{
$contact = \App\Contact::firstOrNew(['id' => $this->_to]);
$contact->set($stanza, $this->_to);
$contact->createThumbnails();
$contact->saveBinAvatar();
$notify = true;

6
lib/moxl/src/Xec/Handler.php

@ -78,12 +78,12 @@ class Handler
} else {
\Utils::info("Handler : No memory instance found for {$id}");
$handled = Handler::handleNode($child);
Handler::handleNode($child);
foreach ($child->children() as $s1) {
$handled = Handler::handleNode($s1, $child);
Handler::handleNode($s1, $child);
foreach ($s1->children() as $s2) {
$handled = Handler::handleNode($s2, $child);
Handler::handleNode($s2, $child);
}
}
}

5
src/Movim/Bootstrap.php

@ -245,11 +245,6 @@ class Bootstrap
date_default_timezone_set("UTC");
}
private function setLogLevel()
{
define('LOG_LEVEL', (int)Configuration::get()->loglevel);
}
private function startingSession()
{
if (SESSION_ID !== null) {

1
src/Movim/Console/DaemonCommand.php

@ -18,7 +18,6 @@ use Ratchet\WebSocket\WsServer;
use Movim\Daemon\Core;
use Movim\Daemon\Api;
use Movim\i18n\Locale;
use App\User;
use Phinx\Migration\Manager;

14
src/Movim/Controller/Ajax.php

@ -71,18 +71,24 @@ class Ajax extends Base
/**
* Check if the widget is registered
*/
public function isRegistered($widget)
public function isRegistered($widget): bool
{
return array_key_exists($widget, $this->widgetlist);
return in_array($widget, $this->widgetlist);
}
/**
* Defines a new function.
* Register a widget
*/
public function defun($widget, $funcname, array $params)
public function register(string $widget)
{
array_push($this->widgetlist, $widget);
}
/**
* Defines a new function.
*/
public function defineFunction(string $widget, string $funcname, array $params)
{
$http = 0;
if (preg_match('#^ajaxHttp#', $funcname)) $http = 1;
if (preg_match('#^ajaxHttpDaemon#', $funcname)) $http = 2;

1
src/Movim/Daemon/Api.php

@ -9,7 +9,6 @@ namespace Movim\Daemon;
use Movim\Bootstrap;
use Psr\Http\Message\ServerRequestInterface;
use React\EventLoop\LoopInterface;
use React\Http\HttpServer;
use React\Http\Message\Response;

3
src/Movim/Daemon/Core.php

@ -6,10 +6,9 @@
namespace Movim\Daemon;
use App\Cache;
use Ratchet\MessageComponentInterface;
use Ratchet\ConnectionInterface;
use Symfony\Component\Console\Input\InputInterface;
use Dflydev\FigCookies\Cookies;
use Movim\Daemon\Session;

8
src/Movim/Widget/Base.php

@ -19,8 +19,6 @@ class Base
protected $name;
protected $view;
protected $pure; // To render the widget without the container
protected $_view;
public $events;
@ -62,13 +60,15 @@ class Base
$params[] = $param->name;
}
$this->ajax->defun(
$this->ajax->defineFunction(
$this->name,
$method->name,
$params
);
}
}
$this->ajax->register($this->name);
}
if (php_sapi_name() != 'cli') {
@ -84,8 +84,6 @@ class Base
$this->view->objectConfigure($config);
$this->view->assign('c', $this);
$this->pure = false;
}
}

Loading…
Cancel
Save