From 182207fc4beb9c4149e79b725bf7db85dfa77c3d Mon Sep 17 00:00:00 2001 From: modela bitweaver Date: Tue, 2 Feb 2021 16:18:16 -0500 Subject: PHP7 ::getAttachment static only --- includes/classes/LibertyMime.php | 10 ++-------- includes/edit_storage_inc.php | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/includes/classes/LibertyMime.php b/includes/classes/LibertyMime.php index 17c7f54..94d019c 100644 --- a/includes/classes/LibertyMime.php +++ b/includes/classes/LibertyMime.php @@ -629,7 +629,7 @@ class LibertyMime extends LibertyContent { * @access public * @return attachment details */ - public function getAttachment( $pAttachmentId, $pParams = NULL ) { + public static function getAttachment( $pAttachmentId, $pParams = NULL ) { global $gLibertySystem, $gBitSystem; $ret = NULL; @@ -638,13 +638,7 @@ class LibertyMime extends LibertyContent { if( $result = $gBitSystem->mDb->query( $query, array( (int)$pAttachmentId ))) { if( $row = $result->fetchRow() ) { if( $func = $gLibertySystem->getPluginFunction( $row['attachment_plugin_guid'], 'load_function', 'mime' )) { - $prefs = array(); - // if the object is available, we'll copy the preferences by reference to allow the plugin to update them as needed - if( !empty( $this ) && !empty( $this->mStoragePrefs[$pAttachmentId] )) { - $prefs = &$this->mStoragePrefs[$pAttachmentId]; - } else { - $prefs = static::getAttachmentPreferences( $pAttachmentId ); - } + $prefs = static::getAttachmentPreferences( $pAttachmentId ); $ret = $func( $row, $prefs, $pParams ); } } diff --git a/includes/edit_storage_inc.php b/includes/edit_storage_inc.php index 3d40b0f..bba99ad 100644 --- a/includes/edit_storage_inc.php +++ b/includes/edit_storage_inc.php @@ -35,7 +35,7 @@ if( !empty( $_REQUEST['deleteAttachment'] )) { } $attachmentId = $_REQUEST['deleteAttachment']; - $attachmentInfo = $gContent->getAttachment( $attachmentId ); + $attachmentInfo = LibertyMime::getAttachment( $attachmentId ); // the second part of this check seems odd (never used?) to me, but I'll leave it in for now - spiderr 10/17/2007 if( $gContent->hasAdminPermission() || ( $gContent->isOwner( $attachmentInfo ) && $gBitUser->hasPermission( 'p_liberty_delete_attachment' ))) { -- cgit v1.3 From d7b0c69c5e1a534fe67e19fb89af145b8f702c2d Mon Sep 17 00:00:00 2001 From: modela bitweaver Date: Tue, 2 Feb 2021 16:23:51 -0500 Subject: PHP7 static only ::getAttachmentPreferences --- includes/classes/LibertyMime.php | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/includes/classes/LibertyMime.php b/includes/classes/LibertyMime.php index 94d019c..7821cc1 100644 --- a/includes/classes/LibertyMime.php +++ b/includes/classes/LibertyMime.php @@ -758,25 +758,14 @@ class LibertyMime extends LibertyContent { * @param string Default value to return if the preference is empty * @param int Optional content_id for arbitrary content preference */ - function getAttachmentPreferences( $pAttachmentId ) { + protected static function getAttachmentPreferences( $pAttachmentId ) { global $gBitSystem; $ret = array(); if( BitBase::verifyId( $pAttachmentId ) ) { - if( !empty( $this ) && is_subclass_of( $this, "LibertyMime" ) ) { - // we're loading from within object - if( is_null( $this->mStoragePrefs )) { - $this->loadAttachmentPreferences(); - } - - if( @BitBase::verifyId( $pAttachmentId ) && isset( $this->mStoragePrefs[$pAttachmentId] )) { - $ret = $this->mStoragePrefs[$pAttachmentId]; - } - } else { - // if the object isn't loaded, we need to get the prefs from the database - $sql = "SELECT `pref_name`, `pref_value` FROM `".BIT_DB_PREFIX."liberty_attachment_prefs` WHERE `attachment_id` = ?"; - $ret = $gBitSystem->mDb->getAssoc( $sql, array( (int)$pAttachmentId )); - } + // if the object isn't loaded, we need to get the prefs from the database + $sql = "SELECT `pref_name`, `pref_value` FROM `".BIT_DB_PREFIX."liberty_attachment_prefs` WHERE `attachment_id` = ?"; + $ret = $gBitSystem->mDb->getAssoc( $sql, array( (int)$pAttachmentId )); } return $ret; -- cgit v1.3