Skip to content

[PURR-82] added __isset() to Relational class#1662

Merged
nkissebe merged 2 commits intodevfrom
purr82-alt
Oct 5, 2023
Merged

[PURR-82] added __isset() to Relational class#1662
nkissebe merged 2 commits intodevfrom
purr82-alt

Conversation

@JackS9
Copy link
Contributor

@JackS9 JackS9 commented Aug 10, 2023

This is an alternate solution to PR 1661

  • JIRA issue: https://sdx-sdsc.atlassian.net/browse/PURR-82
  • Support ticket: https://purr.purdue.edu/support/ticket/2439?show=324&search=&limit=20&start=0
  • Summary of issue: In the publication curation workflow the title of the citation does not appear. In fact the citation is essentially blank.
  • Summary of fix: The test for the presence of a citation key (such as title) was incorrectly returning false even though it was set. Added a magic __isset() to core/libraries/Hubzero/Database/Relational.php that checks whether the attribute is set.
  • Summary of testing: The issue was replicated on my dev machine and now works with this fix.
  • Hotfix needed? Possibly on PURR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Typo in comment Chvk ig

Copy link
Contributor

Choose a reason for hiding this comment

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

param can only be string (I know there are similar errors in other functions in this file)

@zooley
Copy link
Contributor

zooley commented Aug 10, 2023

Just a note that this functionality already exists on the Relational class in the form of the hasAttribute() method. Adding an __isset magic method isn't a bad idea, though, but should probably just return the other method (or vice-versa).

	/**
	 * Check if attributes (i.e. field) on the model is set
	 *
	 * @param  string  $name   The key to check if set
	 * @return  boolean 
	 */
	public function __isset($name)
	{
		return $this->hasAttribute($name);
	}

@JackS9
Copy link
Contributor Author

JackS9 commented Aug 10, 2023

I changed to what Shawn suggested; however, I noticed that __get() could also use hasAttribute()

	// Next check for an attribute on the model
	if (isset($this->attributes[$name]))
	{
		return $this->attributes[$name];
	}

@nkissebe nkissebe merged commit 40a7915 into dev Oct 5, 2023
@nkissebe nkissebe deleted the purr82-alt branch April 18, 2024 23:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments