: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* @throws ReflectionException
private function process4comments($post_id, $feed_id){
$dbm = LAUtils::dbm($this->context);
$comments = $conn->getAll('SELECT * FROM ?n WHERE `post_id` = ?s', $dbm->comments_table_name, $post_id);
$expiration = $time - 3600; // 1 hour
// if no comments or comments are outdated
if(count($comments) === 0 || ($comments[0]["updated_time"] < $expiration) ){
$sources = $dbm->sources();
$this->initContextBeforeCreateFeedInstances();
/** @var LAFeedWithComments $instance */
$instance = $this->createFeedInstance($sources[$feed_id]);
if ($instance instanceof LAFeedWithComments){
$comments = $instance->getComments($post_id);
if (sizeof($comments) > 0 && $conn->beginTransaction()){
$dbm->removeComments($post_id);
foreach ( $comments as $comment ) {
$comment->updated_time = $time;
if (is_object($comment->from)) $comment->from = json_encode($comment->from);
$dbm->addComments($post_id, $comment);
} catch ( Exception $e) {
$conn->rollbackAndClose();
error_log($e->getMessage());
* @throws ReflectionException
private function createFeedInstances($feeds) {
$this->initContextBeforeCreateFeedInstances();
foreach ($feeds as $feed) {
$result[$feed->id] = $this->createFeedInstance($feed);
* @throws ReflectionException
private function createFeedInstance($feed) {
if ($feed->type == 'linkedin') {
$feed->type = 'linkedIn';
if (FF_USE_WP && $feed->type == 'wordpress'){
$clazz = new ReflectionClass( 'flow\\social\\FF' . ucfirst($feed->$wpt) );//don`t change this line
/** @var FFFeed $instance */
$instance = $clazz->newInstance();
$feed = $this->prepareFeed($feed, $this->generalSettings);
if (LASettingsUtils::YepNope2ClassicStyle($feed->boosted, false)){
$instance = new FFRemoteFeed($instance);
$instance->init($this->context, $feed);
* @param $options LAGeneralSettings
protected function prepareFeed($feed, $options){
$feed->{'use-excerpt'} = LASettingsUtils::YepNope2ClassicStyleSafe($feed, 'use-excerpt');
$feed->{'include-post-title'} = LASettingsUtils::YepNope2ClassicStyleSafe($feed, 'include-post-title');
$feed->{'only-text'} = LASettingsUtils::YepNope2ClassicStyleSafe($feed, 'only-text');
$feed->{'rich-text'} = LASettingsUtils::YepNope2ClassicStyleSafe($feed, 'rich-text');
$feed->{'hide-caption'} = LASettingsUtils::YepNope2ClassicStyleSafe($feed, 'hide-caption');
$feed->{'playlist-order'} = LASettingsUtils::YepNope2ClassicStyleSafe($feed, 'playlist-order');
$feed->replies = LASettingsUtils::notYepNope2ClassicStyleSafe($feed, 'replies');
$feed->retweets = LASettingsUtils::YepNope2ClassicStyleSafe($feed, 'retweets');
$feed->{'use-geo'} = LASettingsUtils::YepNope2ClassicStyleSafe($feed, 'use-geo');
//$feed->boosted = FFSettingsUtils::YepNope2ClassicStyleSafe($feed, 'boosted');
$original = $options->original();
$feed->linkedin_access_token = @$original['linkedin_access_token'];
$feed->dribbble_access_token = @$original['dribbble_access_token'];
$feed->foursquare_access_token = @$original['foursquare_access_token'];
$feed->foursquare_client_id = @$original['foursquare_client_id'];
$feed->foursquare_client_secret = @$original['foursquare_client_secret'];
$feed->google_api_key = @$original['google_api_key'];
$feed->instagram_access_token = @$original['instagram_access_token'];
$feed->instagram_login = @$original['instagram_login'];
$feed->instagram_password = @$original['instagram_pass'];
$feed->soundcloud_api_key = @$original['soundcloud_api_key'];
$feed->twitter_access_settings = [
'oauth_access_token' => @$original['oauth_access_token'],
'oauth_access_token_secret' => @$original['oauth_access_token_secret'],
'consumer_key' => @$original['consumer_key'],
'consumer_secret' => @$original['consumer_secret']
$feed->use_curl_follow_location = $options->useCurlFollowLocation();
$feed->use_ipv4 = $options->useIPv4();
* @param LAStreamSettings|null $stream
* @noinspection PhpUnusedParameterInspection
private function prepareResult(array $all, $errors, $hash, $stream = null) {
$page = isset($_REQUEST['page']) ? (int)$_REQUEST['page'] : 0;
$oldHash = isset($_REQUEST['hash']) ? $_REQUEST['hash'] : $hash;
if (isset($_REQUEST['recent']) && $hash != null){
list($status, $errors) = $this->status($stream);
$result = FF_USE_WP ? apply_filters('ff_build_public_response', [], $all, $this->context, $errors, $oldHash, $page, $status, $stream) :
$this->buildResponse( [], $all, $this->context, $errors, $oldHash, $page, $status, $stream);
if (($result === false) && (JSON_ERROR_UTF8 === json_last_error())){
foreach ( $all as $item ) {
if (JSON_ERROR_UTF8 === json_last_error()){
$item->text = mb_convert_encoding($item->text, "UTF-8", "auto");
$result = FF_USE_WP ? apply_filters('ff_build_public_response', $result, $all, $this->context, $errors, $oldHash, $page, $status, $stream) :
$this->buildResponse($result, $all, $this->context, $errors, $oldHash, $page, $status, $stream);
$result['server_time'] = time();
$json = json_encode($result);
switch (json_last_error()) {
$errors[] = 'Json encoding error: Maximum stack depth exceeded';
case JSON_ERROR_STATE_MISMATCH:
$errors[] = 'Json encoding error: Underflow or the modes mismatch';
case JSON_ERROR_CTRL_CHAR:
$errors[] = 'Json encoding error: Unexpected control character found';
$errors[] = 'Json encoding error: Syntax error, malformed JSON';
for ( $i = 0; sizeof( $result['items'] ) > $i; $i++ ) {
if (function_exists('mb_convert_encoding'))
$result['items'][$i]->text = mb_convert_encoding($result['items'][$i]->text, "UTF-8", "auto");
$json = json_encode($result);
$errors[] = 'Json encoding error: Malformed UTF-8 characters, possibly incorrectly encoded';
$errors[] = 'Json encoding error';
$result = FF_USE_WP ? apply_filters('ff_build_public_response', [], [], $this->context, $errors, $oldHash, $page, 'errors', $stream) :
$this->buildResponse($result, $all, $this->context, $errors, $oldHash, $page, 'errors', $stream);
$json = json_encode($result);
* @param LAStreamSettings $stream
private function status($stream) {
$dbm = LAUtils::dbm($this->context);
$status_info = LADB::getStatusInfo($dbm->conn(), $dbm->cache_table_name, $dbm->streams_sources_table_name, (int)$stream->getId(), false);
if ($status_info['status'] == '0'){
return [ 'errors', isset($status_info['error']) ? $status_info['error'] : '' ];
if ($status_info['status'] == '1'){
$feed_count = sizeof($stream->getAllFeeds());
$status = ($feed_count == (int)$status_info['feeds_count']) ? 'get' : 'building';
throw new Exception('Was received the unknown status');