2015-03-07 15:24:39 -05:00
< ? php
2018-02-03 23:49:48 -05:00
2017-11-15 16:12:33 -05:00
namespace Friendica\Worker ;
2018-10-29 17:20:46 -04:00
use Friendica\Core\Logger ;
2018-07-20 08:19:26 -04:00
use Friendica\Database\DBA ;
2018-04-09 17:34:23 -04:00
2018-02-03 23:49:48 -05:00
class TagUpdate
{
public static function execute ()
{
2018-07-20 08:19:26 -04: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-03 23:49:48 -05:00
2018-10-29 17:20:46 -04:00
Logger :: log ( 'fetched messages: ' . DBA :: numRows ( $messages ));
2018-07-20 08:19:26 -04:00
while ( $message = DBA :: fetch ( $messages )) {
2018-02-03 23:49:48 -05:00
if ( $message [ 'uid' ] == 0 ) {
$global = true ;
2018-07-20 08:19:26 -04:00
DBA :: update ( 'term' , [ 'global' => true ], [ 'otype' => TERM_OBJ_POST , 'guid' => $message [ 'guid' ]]);
2018-02-03 23:49:48 -05:00
} else {
2018-07-20 08:19:26 -04:00
$global = ( DBA :: count ( 'term' , [ 'uid' => 0 , 'otype' => TERM_OBJ_POST , 'guid' => $message [ 'guid' ]]) > 0 );
2018-02-03 23:49:48 -05:00
}
2018-04-09 17:34:23 -04:00
$fields = [ 'guid' => $message [ 'guid' ], 'created' => $message [ 'created' ],
'received' => $message [ 'received' ], 'global' => $global ];
2018-07-20 08:19:26 -04:00
DBA :: update ( 'term' , $fields , [ 'otype' => TERM_OBJ_POST , 'oid' => $message [ 'oid' ]]);
2018-02-03 23:49:48 -05:00
}
2018-07-20 08:19:26 -04:00
DBA :: close ( $messages );
2018-02-03 23:49:48 -05:00
2018-07-20 08:19:26 -04:00
$messages = DBA :: select ( 'item' , [ 'guid' ], [ 'uid' => 0 ]);
2018-02-03 23:49:48 -05:00
2018-10-29 17:20:46 -04:00
Logger :: log ( 'fetched messages: ' . DBA :: numRows ( $messages ));
2019-01-07 13:24:11 -05:00
while ( $message = DBA :: fetch ( $messages )) {
2018-07-20 08:19:26 -04:00
DBA :: update ( 'item' , [ 'global' => true ], [ 'guid' => $message [ 'guid' ]]);
2018-02-03 23:49:48 -05:00
}
2018-07-20 08:19:26 -04:00
DBA :: close ( $messages );
2017-11-15 16:12:33 -05:00
}
2015-03-07 15:24:39 -05:00
}