magicsunday / webtrees-pedigree-chart

SVG based pedigree chart module for webtrees genealogy application.
GNU General Public License v3.0
48 stars 15 forks source link

Uncaught TypeError: WebtreesDescendantsChart.DescendantsChart is not a constructor #54

Closed psyco42 closed 1 year ago

psyco42 commented 1 year ago

I got the following error in the console when I open the page with the module. Nothing is render under the filters. I have no error in the PHP error log.

VM309:15 Uncaught TypeError: WebtreesDescendantsChart.DescendantsChart is not a constructor

line 46 in module_v4/webtrees-descendants-chart/resources/views/modules/charts/chart.phtml

The "WebtreesDescendantsChart" object isn't in the original webtrees code, and it present only in the magicsunday plugins.

Context Plugin version 1.4.0 Webtrees version 2.1.15 Tested under PHP 8.0 and 8.1

I migrated from my old to my new server. I did a copy of the DB and the whole Webtrees directory, then I import it to my new server. More or less a recovery plan from a backup.

Everything works with my new server except for two plugins from Magicsunday. In both cases, I have the same javascript error.

I cannot find the difference between the two servers, which can lead to this bug in the interface. It is a strict copy in terms of files and DB, same PHP extensions.

The two plugins github.com/magicsunday/webtrees-pedigree-chart/ github.com/magicsunday/webtrees-descendants-chart

Screenshot 2023-01-09 at 22 40 28
arbor95 commented 1 year ago

The module_v4/webtrees-descendants-chart/resources/views/modules/charts/chart.phtml has only 25 lines, what is less than 46. You use the wrong chart.phtml there. That one is from the ....../descendants-chart/chart.phtml!

magicsunday commented 1 year ago

As @arbor95 said, something went wrong copying to the new instance. Please try to install the modules again.

psyco42 commented 1 year ago

Thanks for your help.

I did a few things to understand my issue better.

First of all, I re-install a fresh setup of webtrees in my same server with a problematic instance. I add the pedigree module, and it works perfectly.

The module directory is clean and working properly in the fresh instance (same server setup, MySQL, webtrees version).

So, I have definitively something corrupted in my instance, but I couldn't figure out what (and why it affects only those two modules).

arbor95 commented 1 year ago

"So, I have definitively something corrupted in my instance, but I couldn't figure out what (and why it affects only those two modules)."

So simply delete the two dirs in the module dir and make them fresh!

psyco42 commented 1 year ago

Sorry to insist but I did that first, and it didn't help.

A fresh module directory in my fresh webtrees setup works. A fresh module directory into my existing webtrees instance doesn't.

But I found something very interesting in my initial steps of debugging.

If I open a new page with the generated URL, the chart is displayed normally. https://github.com/magicsunday/webtrees-pedigree-chart/blob/master/resources/views/modules/pedigree-chart/chart.phtml#L28

So, I would say something is declared on top of it for the script not to work

psyco42 commented 1 year ago

In other words, if I manually open data-wt-ajax-url in a new tab, it displays the module correctly.

Screenshot 2023-01-21 at 10 50 04
magicsunday commented 1 year ago

So why not using the fresh install? Rename your directory for Backup. Copy fresh stuff in place. Remove the data Directory From your fresh install and copy it over from your Backup. Maybe some file from the webtrees source is corrupted.

psyco42 commented 1 year ago

Hi,

I transfer everything to the fresh setup, and everything works.

So, we won't know the root cause but it is definitively not from the module source code itself.