Skip to content

Commit

Permalink
Fix variable usage consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
icc authored Jun 9, 2020
1 parent 8a29763 commit 050a684
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions h5peditor.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -379,21 +379,21 @@ public function getLibraryData($machineName, $majorVersion, $minorVersion, $lang
$library = $this->h5p->loadLibrary($machineName, $majorVersion, $minorVersion);

// Include name and version in data object for convenience
$libraryData->name = $machineName;
$libraryData->version = (object) array('major' => $majorVersion, 'minor' => $minorVersion);
$libraryData->name = $library['machineName'];
$libraryData->version = (object) array('major' => $library['majorVersion'], 'minor' => $library['minorVersion']);
$libraryData->title = $library['title'];

$libraryData->upgradesScript = $this->h5p->fs->getUpgradeScript($machineName, $majorVersion, $minorVersion);
$libraryData->upgradesScript = $this->h5p->fs->getUpgradeScript($library['machineName'], $library['majorVersion'], $library['minorVersion']);
if ($libraryData->upgradesScript !== NULL) {
// If valid add URL prefix
$libraryData->upgradesScript = $this->h5p->url . $prefix . $libraryData->upgradesScript;
}

$libraries = $this->findEditorLibraries($machineName, $majorVersion, $minorVersion);
$libraryData->semantics = $this->h5p->loadLibrarySemantics($machineName, $majorVersion, $minorVersion);
$libraryData->language = $this->getLibraryLanguage($machineName, $majorVersion, $minorVersion, $languageCode);
$libraryData->defaultLanguage = empty($defaultLanguage) ? NULL : $this->getLibraryLanguage($machineName, $majorVersion, $minorVersion, $defaultLanguage);
$libraryData->languages = $this->storage->getAvailableLanguages($machineName, $majorVersion, $minorVersion);
$libraries = $this->findEditorLibraries($library['machineName'], $library['majorVersion'], $library['minorVersion']);
$libraryData->semantics = $this->h5p->loadLibrarySemantics($library['machineName'], $library['majorVersion'], $library['minorVersion']);
$libraryData->language = $this->getLibraryLanguage($library['machineName'], $library['majorVersion'], $library['minorVersion'], $languageCode);
$libraryData->defaultLanguage = empty($defaultLanguage) ? NULL : $this->getLibraryLanguage($library['machineName'], $library['majorVersion'], $library['minorVersion'], $defaultLanguage);
$libraryData->languages = $this->storage->getAvailableLanguages($library['machineName'], $library['majorVersion'], $library['minorVersion']);

// Temporarily disable asset aggregation
$aggregateAssets = $this->h5p->aggregateAssets;
Expand Down

2 comments on commit 050a684

@fnoks
Copy link
Contributor

@fnoks fnoks commented on 050a684 Jun 10, 2020

Choose a reason for hiding this comment

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

Couldn't you do this instead?

...
$library = $this->h5p->loadLibrary($machineName, $majorVersion, $minorVersion);
$machineName = $library['machineName'];
$majorVersion = $library['majorVersion'];
$minorVersion = $library['minorVersion'];
...

@icc
Copy link
Member Author

@icc icc commented on 050a684 Jun 10, 2020

Choose a reason for hiding this comment

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

Sure, but I didn't want to override the original values in case they were needed later. Also, didn't want to rely too much on the order of things in case someone starts fixing stuff here later.

Please sign in to comment.