• Welcome to Tux Reports: Where Penguins Fly. We hope you find the topics varied, interesting, and worthy of your time. Please become a member and join in the discussions.

XenForo 2, FQN, and Strings

rheinebene-at-full-moon-2147017_960_720.jpg


This week has been all about trial-and-error, reading, watching tutorials, and finally asking why code is failing. It turned out to be a silly error in not using the Fully Qualified Name (FQN) in a conditional. And now I'm sitting relaxed, smiling, and gleefully looking at the horizon. It's great to overcome a coding mistake.

Let me back up.

XenForo 2 requires namespaces. This is awesome. Class names can be shortened and developers are free to reuse obvious class names rather than prefixes and other hacks to avoid collisions.

I started to add namespaces to the top of XenWord 4 files and \XF:: visitor() stopped working. Numerous combinations were tried and nothing worked. It was exhausting.

After several developers kept pointing out that the connection was not being made to XenForo 2, I decided to strip code down. It turned out the issue was simple. The call to the connector in the bootstrap file was wrapped in a conditional which was not using the FQN.

Originally I thought my understanding of the use statement covered the class_exists conditional. I was wrong.

FQN are required whenever strings are involved and in the case of using class_exists then the FQN is wrapped in single quotes.

Now that this hurdle has been overcome, I'm spending time adding namespaces to XenWord 4.
  • Like
Reactions: robru

Blog entry information

Author
LPH
Views
3,108
Comments
1
Last update

More entries in General

More entries from LPH

Top