Welcome, Guest
Username: Password: Remember me

TOPIC: [FAQ]_fork in generated component giving undefined...

_fork in generated component giving undefined... 24 Sep 2013 20:00 #11188

  • BTB300
  • BTB300's Avatar
  • Offline
  • Moderator
  • Posts: 415
  • Thank you received: 132
  • Karma: 47
Hi Admin
Just noticed that a few of my projects have been acting up recently...

i noticed that my upgraded (installed over the top) components now have a new directory "_fork"

my directories now look like this
[COM_SITE] /_forked and [COM_SITE] /forked

i do believe that this "new" directory is generated in the front end and administrator sides

checked the relative helper files and they still look for the directory fork

is _forked the new directory for forked files? or is it just a typo in the generator?
The administrator has disabled public write access.

_fork in generated component giving undefined... 24 Sep 2013 22:31 #11189

  • dyoungers
  • dyoungers's Avatar
  • Offline
  • Premium Member
  • Posts: 123
  • Thank you received: 16
  • Karma: 0
Based on the fork system documentation, in particular the image of the directory structure (see www.j-cook.pro/index.php/f/forks), it looks like _fork is correct and is where the generated "base" files should go (and we are supposed to create the fork directory and copy the files we need to change.)

Having said that, at some point in the past, the generator created all the files in the fork directory (as that is what I see in some of my installed projects) but I suspect that was not what was intended. (Maybe for performance reasons we should only have changed files in the fork directory and not all the files?)

Just my guess (and I await admin's answer)

Dave
The administrator has disabled public write access.
The following user(s) said Thank You: admin

_fork in generated component giving undefined... 25 Sep 2013 15:06 #11190

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
Exactly, this is normal.
Now everytime you reinstall your component over an existing one, then the _fork directory is filled up again with new forkables classes.

Before this, you had to find those new files in the install package.
Coding is now a piece of cake
The administrator has disabled public write access.
The following user(s) said Thank You: BTB300

_fork in generated component giving undefined... 28 Sep 2013 07:57 #11210

  • BTB300
  • BTB300's Avatar
  • Offline
  • Moderator
  • Posts: 415
  • Thank you received: 132
  • Karma: 47
Um... but in a fresh component the "fork" directory no longer exists

its not hard to put i in there but i guess this is where some of my issues can up when trouble shooting

somewhere along the line I un-installed the component which as expected would remove the fork directory

the component then complained because the original "fork" directory was not present
- in previous builds the "fork" directory was created along with the files now found in the new "_fork" directory
- when the helper was called it looked for the forked helper file in components/com_name/forked/helpers/helper.php
- and it complained it when it could not find components/com_name/forked/helpers/helper.php

Its Fixed Now But
I can only guess that at the time there was an issue (for what ever reason???) the fall back was present
// Fallback if no fork has been found
if (!class_exists('MybooksHelper')){ class MybooksHelper extends MybooksCkHelper{} }
Last Edit: 28 Sep 2013 07:59 by BTB300.
The administrator has disabled public write access.

_fork in generated component giving undefined... 02 Oct 2013 19:57 #11285

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
I do not get your point.

Can you please give an example ?
Coding is now a piece of cake
The administrator has disabled public write access.

_fork in generated component giving undefined... 08 Oct 2013 15:54 #11335

  • BTB300
  • BTB300's Avatar
  • Offline
  • Moderator
  • Posts: 415
  • Thank you received: 132
  • Karma: 47
Sorry for slow reply Admin,

Anyhow, I guess what i was trying to point out was... (please feel free to correct me if any of the points below are incorrect)

For those that have not visited a component project for a few months and then download a current build
- the "[COM_SITE]/fork" directory is no longer created on a clean / fresh install
- the "forkables" are now located in the "[COM_SITE]/_fork"
- the overrides need to still be located in the "[COM_SITE]/fork" directory
- on a fresh component install you will need to create the "[COM_SITE]/fork" directory and place your overrides in there
- a quick way of creating the "[COM_SITE]/fork" directory is to remove the underscore from the _fork directories on the admin and site sides
- and don't be confused when you install a newer version over the top of an existing component you will have both [COM_SITE]/fork and [COM_SITE]/_fork directories
(the same applies for the admin side)

however I must say Great Work!
I appreciate the the fact that we can now drop just one or two files into the fork directory instead of having every "forkable" file loaded by default

May I suggest to avoid confusion with "fork" and "_fork" could the "_fork" directories perhaps be called "forkables" or "_forkables"?

Further Explanation below for those that are a little lost

The builds from about a month ago contained the forkable files in
[COM_SITE]/fork and [COM_ADMIN_SITE]/fork

The current builds contain the forkable files in
[COM_SITE]/_fork and [COM_ADMIN_SITE]/_fork

The helper file from a current build looks for the fork directory as shown below
// Search for a fork to be able to override this class
JLoader::register('TestaltpkHelper', JPATH_ADMIN_TESTALTPK .DS. 'fork' .DS. 'helpers' .DS. 'helper.php');
JLoader::load('TestaltpkHelper');
// Fallback if no fork has been found
if (!class_exists('TestaltpkHelper')){ class TestaltpkHelper extends TestaltpkCkHelper{} }

my problem was
- earlier builds used the fork directory to store all of the "forkables"
- when i did an uninstall and reinstall of my component the "[COM_ADMIN_SITE]/fork" directory was no longer present
- when i noticed the new directory...
- i dropped my previously forked files into " [COM_ADMIN_SITE]/_fork" (thinking that this was the new place that overrides would need to located)

Upon further investigation - it was not that the fall back did not work
The problem was simply that my forked files were in the wrong directory - this naturally gave an error that indicated an undefined function in.... because TestaltpkHelper::myExtendedFunction() did not exist in the directory [COM_ADMIN_SITE]/fork/helpers

Hope this helps to explain better
Last Edit: 08 Oct 2013 16:11 by BTB300.
The administrator has disabled public write access.
The following user(s) said Thank You: admin

_fork in generated component giving undefined... 08 Oct 2013 19:38 #11341

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
This is not anymore required.
JLoader::load('TestaltpkHelper');

Memory optimization.
Coding is now a piece of cake
Last Edit: 08 Oct 2013 19:40 by admin.
The administrator has disabled public write access.
Time to create page: 0.206 seconds

Get Started