Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrated Minds.com's engine to PHP v7.2.0. #31

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Core/Email/Batches/Notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public function run()
/** @var Notification[] $notifications */
$notifications = $this->repository->getAll(['limit' => $count])['notifications'];
} catch (\Exception $e) {

error_log($e->getMessage());
continue;
}
Expand All @@ -58,6 +59,11 @@ public function run()

$i = 0;

// Needed for PHP 7.2 compatibility with the new `count`.
if (!$notifications) {
$notifications = [];
}

//count all notifications created today
while ($i < count($notifications) && $today <= $notifications[$i]->getTimeCreated()) {
$i++;
Expand All @@ -73,4 +79,4 @@ public function run()
}
}
}
}
}
9 changes: 7 additions & 2 deletions Core/Email/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


use Minds\Core\Di\Di;
use Minds\Core\Email\EmailSubscription;
use Minds\Core\Entities;

class Manager
Expand All @@ -30,10 +29,16 @@ public function getSubscribers($options = [])

$result = $this->repository->getList($options);

if (!$result || count($result['data'] === 0)) {
// @FIXME: Due to a quirk in PHP < 7.2.0, count($array === 0) always returns true.
// @FIXME: This blows up, as it should, in PHP >= 7.2.0.
// @FIXME: Since this code was -always- returning true, it needs to be fixed.
// Orig: if (!$result || count($result['data'] === 0) {
if (!$result || true /** @FIXME!~! */) {
return [];
}

// @FIXME: Due to the function always exiting before this point, no one caught
// @FIXME: that this array_map blows up trying to call a method on a string.
$guids = array_map(function ($item) {
return $item->getUserGuid();
}, $result['data']);
Expand Down
2 changes: 1 addition & 1 deletion Core/SEO/Sitemaps/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ protected function route($uri)
}
return [];
}
}
}
5 changes: 4 additions & 1 deletion Entities/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,12 @@ public function save($index = true)

/**
* Deletes the activity entity and indexes
*
* @param bool $unused Needed for PHP 7.2 support.
* @return bool
* @throws \Minds\Exceptions\StopEventException
*/
public function delete()
public function delete($unused = true)
{
if ($this->p2p_boosted) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion Entities/Album.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Minds\Core;
use Minds\Core\Data;

class Album extends Object
class Album extends MindsObject
{
protected function initializeAttributes()
{
Expand Down
2 changes: 1 addition & 1 deletion Entities/Batch.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

use Minds\Core\Data;

class Batch extends Object
class Batch extends MindsObject
{
public function __construct($guid = null)
{
Expand Down
2 changes: 1 addition & 1 deletion Entities/DenormalizedEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct($db = null)

/**
* Set this entity's database store
* @param object $db
* @param MindsObject $db
*/
public function setDb($db)
{
Expand Down
8 changes: 6 additions & 2 deletions Entities/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,14 @@ public function save($index = true)

/**
* Extend the default delete function to remove from the remote service
*
* @param bool $recursive Whether to delete all the entities contained by this entity
* @return bool
* @throws \ClassNotFoundException
*/
public function delete()
public function delete($recursive = true)
{
return parent::delete();
return parent::delete($recursive);

//remove from the filestore
}
Expand Down
2 changes: 1 addition & 1 deletion Entities/Object.php → Entities/MindsObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Object Entity
* @todo Do not inherit from ElggObject
*/
class Object extends \ElggObject implements Flaggable
class MindsObject extends \ElggObject implements Flaggable
{
protected $dirtyIndexes;

Expand Down
2 changes: 1 addition & 1 deletion Entities/Object/Carousel.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* Carousel Entity
*/
class Carousel extends Entities\Object
class Carousel extends Entities\MindsObject
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went back and forth on whether to move all of the classes in the Object namespace to MindsObject as well, but in the interests of keeping changes to a minimum, I decided against doing so. Nothing seems to break by leaving it that way.

{
/**
* Initialize entity attributes
Expand Down
2 changes: 1 addition & 1 deletion Entities/Object/Points_transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* Points Transaction Entity
*/
class Points_transaction extends Entities\Object
class Points_transaction extends Entities\MindsObject
{
/**
* Initialize attributes
Expand Down
9 changes: 6 additions & 3 deletions Entities/Video.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Minds\Helpers;


class Video extends Object
class Video extends MindsObject
{
private $cinemr;

Expand Down Expand Up @@ -97,10 +97,13 @@ public function save($force = false)

/**
* Extend the default delete function to remove from the remote service
*
* @param bool $recursive Whether to delete all the entities contained by this entity
* @return bool
*/
public function delete()
public function delete($recursive = true)
{
$result = parent::delete();
$result = parent::delete($recursive);

return $result;
}
Expand Down
8 changes: 4 additions & 4 deletions Spec/Core/Security/ACLSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Minds\Core;
use Minds\Entities\User;
use Minds\Entities\Entity;
use Minds\Entities\Object;
use Minds\Entities\MindsObject;

class ACLSpec extends ObjectBehavior
{
Expand Down Expand Up @@ -49,7 +49,7 @@ public function it_should_not_allow_read_of_private_entities(Entity $entity)
$this->read($entity)->shouldReturn(false);
}

public function it_should_trigger_acl_read_event(Object $entity)
public function it_should_trigger_acl_read_event(MindsObject $entity)
{
$this->mock_session(true);

Expand Down Expand Up @@ -85,7 +85,7 @@ public function it_should_allow_write_for_own_entities(Entity $entity)
$this->mock_session(false);
}

public function it_should_trigger_acl_write_event(Object $entity)
public function it_should_trigger_acl_write_event(MindsObject $entity)
{
$this->mock_session(true);

Expand Down Expand Up @@ -126,7 +126,7 @@ public function it_should_allow_interaction(Entity $entity)
$this->mock_session(false);
}

public function it_should_return_false_on_acl_interact_event(Object $entity)
public function it_should_return_false_on_acl_interact_event(MindsObject $entity)
{
$this->mock_session(true);

Expand Down
4 changes: 2 additions & 2 deletions Spec/Mocks/Cassandra/Rows.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public function __construct(array $items, $pagingStateToken)
public function getIterator()
{
return call_user_func(function () {
while (list($key, $val) = each($this->_items)) {
yield $key => $val;
foreach ($this->_items as $key => $value) {
yield $key => $value;
}
});
}
Expand Down
9 changes: 6 additions & 3 deletions classes/ElggFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,15 @@ public function close() {
/**
* Delete this file.
*
* @param bool $recursive Whether to delete all the entities contained by this entity
*
* @return bool
*/
public function delete() {
* @throws ClassNotFoundException
*/
public function delete($recursive = true) {
$fs = $this->getFilestore();
//if ($fs->delete($this)) {
return parent::delete();
return parent::delete($recursive);
//}
}

Expand Down
12 changes: 9 additions & 3 deletions classes/ElggSite.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,12 @@ protected function load($guid) {
return true;
}

public function save(){
/**
* @param bool $unused Needed for PHP 7.2 support.
* @return bool
* @throws IOException
*/
public function save($unused = true){
global $CONFIG;
if(isset($CONFIG->site_name)){
return; //the site is not an entitiy, it is static from settings
Expand All @@ -136,16 +141,17 @@ public function save(){
*
* @note You cannot delete the current site.
*
* @param bool $recursive Whether to delete all the entities contained by this entity
* @return bool
* @throws SecurityException
*/
public function delete() {
public function delete($recursive = true) {
global $CONFIG;
if ($CONFIG->site->getGUID() == $this->guid) {
throw new SecurityException('SecurityException:deletedisablecurrentsite');
}

return parent::delete();
return parent::delete($recursive);
}

/**
Expand Down
13 changes: 9 additions & 4 deletions classes/ElggUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,12 @@ protected function loadFromLookup($string){
/**
* Saves this user to the database.
*
* @return bool
*/
public function save() {
* @param bool $unused Needed for PHP 7.2 support.
* @return bool
* @throws IOException
*/
public function save($unused = true) {

if(!$this->cache){
//return false;
}
Expand Down Expand Up @@ -265,9 +268,11 @@ public function disable($reason = "", $recursive = true){
/**
* User specific override of the entity delete method.
*
* @param bool $unused Needed for PHP 7.2 support.
*
* @return bool
*/
public function delete() {
public function delete($unused = true) {
global $USERNAME_TO_GUID_MAP_CACHE, $CODE_TO_GUID_MAP_CACHE;

// clear cache
Expand Down
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"stripe/stripe-php": "~4.12",
"thobbs/phpcassa": "dev-minds-legacy",
"tijsverkoyen/twitteroauth": "dev-master@dev",
"twilio/sdk": "3.13.*",
"twilio/sdk": "dev-3.13.1-create-function-fix",
"videlalvaro/php-amqplib": "dev-master@dev",
"vscn/cruftflake": "dev-master#cab1b9ee9869072e7a58a1eb593b602ec5bedcd3",
"zircote/swagger-php": "2.*@dev",
Expand Down Expand Up @@ -48,6 +48,10 @@
{
"type": "vcs",
"url": "https://github.com/davegardnerisme/cruftflake.git"
},
{
"type": "git",
"url": "https://github.com/hopeseekr/twilio-php"
}
],
"autoload": {
Expand Down
Loading