2015-03-07 21:24:39 +01:00
< ? php
2020-02-09 15:45:36 +01:00
/**
* @ copyright Copyright ( C ) 2020 , Friendica
*
* @ license GNU AGPL version 3 or any later version
*
* This program is free software : you can redistribute it and / or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation , either version 3 of the
* License , or ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU Affero General Public License for more details .
*
* You should have received a copy of the GNU Affero General Public License
* along with this program . If not , see < https :// www . gnu . org / licenses />.
*
*/
2018-02-04 05:49:48 +01:00
2017-11-15 22:12:33 +01:00
namespace Friendica\Worker ;
2018-10-29 22:20:46 +01:00
use Friendica\Core\Logger ;
2018-07-20 14:19:26 +02:00
use Friendica\Database\DBA ;
2018-04-09 23:34:23 +02:00
2018-02-04 05:49:48 +01:00
class TagUpdate
{
public static function execute ()
{
2018-07-20 14:19:26 +02:00
$messages = DBA :: p ( " SELECT `oid`,`item`.`guid`, `item`.`created`, `item`.`received` FROM `term` INNER JOIN `item` ON `item`.`id`=`term`.`oid` WHERE `term`.`otype` = 1 AND `term`.`guid` = '' " );
2018-02-04 05:49:48 +01:00
2018-10-29 22:20:46 +01:00
Logger :: log ( 'fetched messages: ' . DBA :: numRows ( $messages ));
2018-07-20 14:19:26 +02:00
while ( $message = DBA :: fetch ( $messages )) {
2018-02-04 05:49:48 +01:00
if ( $message [ 'uid' ] == 0 ) {
$global = true ;
2018-07-20 14:19:26 +02:00
DBA :: update ( 'term' , [ 'global' => true ], [ 'otype' => TERM_OBJ_POST , 'guid' => $message [ 'guid' ]]);
2018-02-04 05:49:48 +01:00
} else {
2018-07-20 14:19:26 +02:00
$global = ( DBA :: count ( 'term' , [ 'uid' => 0 , 'otype' => TERM_OBJ_POST , 'guid' => $message [ 'guid' ]]) > 0 );
2018-02-04 05:49:48 +01:00
}
2018-04-09 23:34:23 +02:00
$fields = [ 'guid' => $message [ 'guid' ], 'created' => $message [ 'created' ],
'received' => $message [ 'received' ], 'global' => $global ];
2018-07-20 14:19:26 +02:00
DBA :: update ( 'term' , $fields , [ 'otype' => TERM_OBJ_POST , 'oid' => $message [ 'oid' ]]);
2018-02-04 05:49:48 +01:00
}
2018-07-20 14:19:26 +02:00
DBA :: close ( $messages );
2018-02-04 05:49:48 +01:00
2018-07-20 14:19:26 +02:00
$messages = DBA :: select ( 'item' , [ 'guid' ], [ 'uid' => 0 ]);
2018-02-04 05:49:48 +01:00
2018-10-29 22:20:46 +01:00
Logger :: log ( 'fetched messages: ' . DBA :: numRows ( $messages ));
2019-01-07 19:24:11 +01:00
while ( $message = DBA :: fetch ( $messages )) {
2018-07-20 14:19:26 +02:00
DBA :: update ( 'item' , [ 'global' => true ], [ 'guid' => $message [ 'guid' ]]);
2018-02-04 05:49:48 +01:00
}
2018-07-20 14:19:26 +02:00
DBA :: close ( $messages );
2017-11-15 22:12:33 +01:00
}
2015-03-07 21:24:39 +01:00
}