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

Remove self-reference in PelIfd::$maker_notes #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
16 changes: 7 additions & 9 deletions src/PelIfd.php
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,6 @@ public function __construct($type)
/**
* Stores Maker Notes data for an IFD (Probably PelIfd::EXIF only).
*
* @param PelIfd $parent
* the parent PelIfd of the current PelIfd
* @param PelDataWindow $data
* the data window that will provide the data.
* @param PelIfd $parent
Expand All @@ -539,10 +537,9 @@ public function __construct($type)
* the offset within the window where the directory will
* be found.
*/
public function setMakerNotes($parent, $data, $components, $offset)
protected function setMakerNotes($data, $components, $offset)
{
$this->maker_notes = [
'parent' => $parent,
'data' => $data,
'components' => $components,
'offset' => $offset
Expand All @@ -552,7 +549,7 @@ public function setMakerNotes($parent, $data, $components, $offset)
/**
* Returns the Maker Notes data for an IFD (Probably PelIfd::EXIF only).
*
* @return array The maker_notes of IDF
* @return array The maker_notes of IFD
*/
public function getMakerNotes()
{
Expand Down Expand Up @@ -664,7 +661,7 @@ private function mapTagToIfdType(PelDataWindow $d, $offset, $tag, $components, $
} elseif ($tag == PelTag::MAKER_NOTE) {
// Store maker notes infos, because we need PelTag::MAKE of PelIfd::IFD0 for MakerNotes
// Thus MakerNotes will be loaded at the end of loading PelIfd::IFD0
$this->setMakerNotes($this, $d, $components, $o);
$this->setMakerNotes($d, $components, $o);
$this->loadSingleValue($d, $offset, $i, $tag);
}
return $ifdType;
Expand Down Expand Up @@ -706,16 +703,17 @@ private function checkIfLoadingFinished()
{
if ($this->type == PelIfd::IFD0 && isset($this->sub[PelIfd::EXIF])) {
// Get MakerNotes from EXIF IFD and check if they are set
$mk = $this->sub[PelIfd::EXIF]->getMakerNotes();
$subIfd = $this->sub[PelIfd::EXIF];
$mk = $subIfd->getMakerNotes();
if (! empty($mk)) {
// get Make tag and load maker notes if tag is valid
$manufacturer = $this->getEntry(PelTag::MAKE);
if ($manufacturer !== null) {
$manufacturer = $manufacturer->getValue();
$mkNotes = PelMakerNotes::createMakerNotesFromManufacturer($manufacturer, $mk['parent'], $mk['data'], $mk['components'], $mk['offset']);
$mkNotes = PelMakerNotes::createMakerNotesFromManufacturer($manufacturer, $subIfd, $mk['data'], $mk['components'], $mk['offset']);
if ($mkNotes !== null) {
// remove pre-loaded undefined MakerNotes
$mk['parent']->offsetUnset(PelTag::MAKER_NOTE);
$subIfd->offsetUnset(PelTag::MAKER_NOTE);
$mkNotes->load();
}
}
Expand Down