vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   php5 and the change of array_merge (https://vborg.vbsupport.ru/showthread.php?t=73945)

reteep 01-07-2005 12:00 PM

php5 and the change of array_merge
 
Hey there,

Quote:

Warning: array_merge() [function.array-merge]: Argument #2 is not an array in /*/vb/includes/init.php on line 522
It's a common Error for people (like me) who are running php5 and lots of hacks are affected.

Now I searched through the forum and found lots of topics about it, however there's no common fix so far.

In fact it should be possible to replace all that array_merge functions with the new one, isn't it? How would that look like by example?

Xenon 01-07-2005 12:09 PM

actually the fix is very easy:

make sure all your files have

PHP Code:

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();

// get special data templates from the datastore
$specialtemplates = array();

// pre-cache templates used by all actions
$globaltemplates = array();

// pre-cache templates used by specific actions
$actiontemplates = array(); 

before they call global.php

reteep 01-07-2005 12:13 PM

Ahh, good to know.

Thanks for your post!

Xenon 01-07-2005 12:32 PM

keine ursache :)

Revan 01-07-2005 11:42 PM

Aber hacks vielleicht hat andere array's dass array_merge gebrauchen, aber nicht eine "if (!is_array($neededarray))" hat? ;)

Ok, now you probably understand why I only get a C in german.

But hacks possibly have other arrays that uses the array_merge, but don't have an "if (!is_array($neededarray))"? ;)

Xenon 01-08-2005 11:59 AM

@Fillip: don't ask who i got in english classes ^^

The Realist 01-26-2005 10:59 AM

Sorry for jumping in on someone elses thread........... but interesting read.

I did not think that PHP 5 causes problems like this. I have been scratching my head for days and then I read this post.

I have a similar problem as follows:

I installed a few hacks and all was fine until I noticed errors are the top of some pages. This error below is from the top of my arcade hack:

Quote:

Warning: array_merge() [function.array-merge]: Argument #1 is not an array in /global.php on line 376

Warning: Invalid argument supplied for foreach() in /includes/functions.php on line 2188
Is this problem with PHP 5 cos Im running 5.0.3 thats causing my errors? and if so how do I fix it.

Regards.

Quote:

Originally Posted by Xenon
actually the fix is very easy:

make sure all your files have

PHP Code:

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();

// get special data templates from the datastore
$specialtemplates = array();

// pre-cache templates used by all actions
$globaltemplates = array();

// pre-cache templates used by specific actions
$actiontemplates = array(); 

before they call global.php

Well I be bugger :)

Placed the code above that Xenon posted in my global and functions php files ane the errors are now gone and all is working.

Where else should I place this code?

Thanks

noppid 01-26-2005 11:25 AM

Declaring Variables before using them? What a novel idea! ;)

sabret00the 01-26-2005 11:52 AM

Quote:

Originally Posted by noppid
Declaring Variables before using them? What a novel idea! ;)

why do i always find the worst jokes so hilarious.

noppid 01-26-2005 12:01 PM

Quote:

Originally Posted by sabret00the
why do i always find the worst jokes so hilarious.

I just have this sick sense of humor and sitting here alone I amuse myself by pointing out the obvious.

If you are a C programmer it might be funny. ;)

No ill intent meant. Just amusing myself.

To be more on topic while I'm having fun, this is usually a hot topic, talking about declaring variables. I found alot of debate on the subject, some very amusing, when after using C for a long time, I had a need to mod some Visual Basic code.

Well off I went and got vB6 and a book. Installed it and did some set up. Now if you have a C background, you can't help yourself, you declare variables, there's no way around it. So I set up the code to not allow dynamic declaration of variables and attemped a complie. It did nothing but complain. Nothing was declared. So to mod this huge piece of code I just removed the statement that made the compiler force declarations. And I was off to delveoping all the bad habits C programmers joke about.

Now I use php, same thing, back to bad habits. Opps, I need a variable here and bam, there it is. I do try to init variables usually, but If you look at any code I wrote, I'm inconsistant. SO part of the amusment above was on myself, I know better and don't do it.

So now php 5 seems to need Array() declared/initialized for this function to accept them. Are we going to declarations in php as a whole? Isn't there a performance benefit to delcaration and proper address space allocated without the compiler having to dynamically sort out types?

I don't hang out at php.net or anywhere that discusses such things, so this thread has sparked my curiousity.


All times are GMT. The time now is 03:55 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01003 seconds
  • Memory Usage 1,748KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete