An unrecoverable error has occured. You can find the error message below. It is advised to copy it to the clipboard for reference. Please continue to the update summary
Fatal error: Cannot use string offset as an array in /home/blah/textlinkads/textlinkads.module on line 322
The update summary says:
The update process was aborted prematurely while running update #1 in textlinkads.module. All other errors have been logged. You may need to check the watchdog database table manually.
Then there are these in watchdog:
Table 'blah.textlinkads' doesn't exist query: textlinkads_get_links SELECT * FROM textlinkads WHERE text IS NOT NULL && beforetext IS NOT NULL && aftertext IS NOT NULL LIMIT 6 in /home/blah/includes/database.mysql.inc on line 120.
The same thing happened on two sites, but the table is there after I run the update.
| Comment | File | Size | Author |
|---|---|---|---|
| #28 | textlinkads.module.patch_0.txt | 1.16 KB | mcurry |
| #18 | tla.patch | 1.2 KB | kbahey |
| #16 | textlinkads.module.patch.txt | 1.06 KB | flevour |
Comments
Comment #1
robertdouglass commentedThanks. I'll look into it.
Comment #2
robertdouglass commentedIs data representing your links to be found in the table after it is created?
Comment #3
kbahey commentedAlso, when cron.php runs, the same error occurs:
If it helps, both sites have no text link ads yet, and the table is empty.
Comment #4
robertdouglass commentedMmmkay. I guess I didn't test the case where there were no links. You're running PHP5, right?
Comment #5
kbahey commentedYes. I am running PHP5.
Part of the problem is that $data does not have anything. In my case, a print_r() shows:
Comment #6
kbahey commentedChanging the title.
There are also other errors in the log from every page view, in addition to the cron error:
Comment #7
kbahey commentedNow I am in a bind ...
I use this module on a multisite install.
When I had those errors, I just hacked the code to prevent them from polluting cron and other log entries.
Then one site sold an ad, so I put the code back to what it is, and the link ads worked fine.
However, on the other site, I kept getting the errors above all the time.
So, I disabled the module on the second site.
That was fine for a few days, but then Text-Link-Ads.com sent me an email that the second site is not accessing the XML data, and will be taken off the inventory!
Catch-22 ...
Every site that has not sold ads will see these errors.
Can something be done about this?
(Another thing is that I am not getting emails from only this issue, don't know why).
Comment #8
robertdouglass commentedI'll do my best to look into this over the weekend. Thanks for your patience.
Comment #9
mcurry commentedComment #10
mcurry commentedHere's the offending XML returned by the TLA server for my publisher account (no ads yet.)
So, the function textlinkads_update_links() needs to handle this condition (no child elements of the <Links> element.
Comment #11
robertdouglass commentedPlease test and see if this minor change addresses all of the problems reported (posting patch here, but commited to CVS already):
Comment #12
mcurry commentedComment #13
robertdouglass commentedThanks for the excellent information. Let's try two things so that I can understand what is happening:
If you don't mind, I'd really like to get this cleared up... thanks for your help.
Comment #14
mcurry commentedShouldn't
be
according to http://us3.php.net/trim (and my tests verify this) trim() doesn't modify the original string. So..
I will check out your suggestions later - I really can't do anything with this right now.
Is it possible for you to build a dummy test XML string with my data for debugging purposes.
Change:
to:
Comment #15
kbahey commentedI upgraded to the latest 4.7 module from CVS.
Upon running cron, it is ok on the site that has ads. ON the other site I get this error:
Fatal error: Cannot use string offset as an array in /home/blah/modules/textlinkads/textlinkads.module on line 322
Comment #16
flevour commentedThis is a patch that fixes 2 errors that appeared in cron.php
The first part gets sure $data['LINKS'] is an array before accessing it, the second part makes $links an array just in case $links doesnt get populated by successive query.
Comment #17
flevour commentedUpdating status. Please review the patch.
Comment #18
kbahey commentedThis patch fixes the issue for sites with empty.
It had one hunk that failed though, so I am attaching a patch generated from the version that I am running.
Comment #19
kbahey commentedNot yet perfect but does not crash and stop cron. It generates this error when cron runs:
Invalid argument supplied for foreach() in /home/blah/textlinkads/textlinkads.module on line 329.
However, the ads are downloaded correctly on the other site that has ads.
I tried moving the foreach and INSERT inside the if check for array, but that caused the ads not to be downloaded.
Comment #20
piraxter@drupal.org commentedI update Textadlink module and now show me these warning.
user warning: Table 'we_drpl1.textlinkads' doesn't exist query: SELECT * FROM textlinkads WHERE text IS NOT NULL && beforetext IS NOT NULL && aftertext IS NOT NULL LIMIT 4 in /home2/we/public_html/huajuapan/includes/database.mysql.inc on line 120.
Comment #21
kbahey commentedIf this is an unrelated problem, then please file a new support request.
Setting back to a bug report.
I have it working OK now except for an annoying message in the log when cron runs. it does not cause cron to abort though as before, impacting other modules.
Comment #22
flevour commentedWhat kind of error? Can you post it here?
Comment #23
kbahey commentedI committed a fix for this with Rob's approval.
It is not perfect, since there is an error logged each time cron is run, but at least the functionality is there, and the module handles the case where ads are not sold on the site yet.
If someone is facing other errors, please open a new issue for that.
Comment #24
bryansd commentedI continue to get a similar error that was posted earlier. No ads currently being posted through textlinkads. Here is the error (slightly modifided):
Invalid argument supplied for foreach() in ../modules/textlinkads/textlinkads.module on line 329.Bryan
Comment #25
kbahey commentedYes, if you read above, my fix has the drawback that this error is logged. I also get it on my sites that have no ads.
However, it is a significant improvement over the previous situation, where TLA would stop adding your site to the inventory because the previous error caused cron to abort completely. It also had the side effect of cron not running for other modules because of that abort.
Someone else can provide a patch, and I (or Robert) will fix it.
Comment #26
(not verified) commentedComment #27
allen074 commentedwarning: Invalid argument supplied for foreach() in /home/centerne/public_html/modules/contrib/textlinkads/textlinkads.module on line 329.
i am still getting this error - where is this fix??
thanks
Comment #28
mcurry commentedI see this, too, on my site(s) having no ads.
For the record, again, here's what the data looks like on a site with no ads:
So, the existing code assumes that there are child elements of
<Links>named<Link>; when this is not true, $links = ' ' (a single-character string) and the foreach fails since $links is not an array. The code needs to deal with non-existent child data, which as far as I can see, it does not in the current version.Attached is a patch against the 4.7 code base that fixes the foreach problem on my site.
Please review and comment.
Comment #29
mcurry commentedMarking as normal priority, since this not that big of a problem (except for annoying error reports in the watchdog log)
Comment #30
kbahey commentedCommitted to 4.7. Thanks to inactivist.
Rob, is there a reason there is no HEAD version of that module?
Comment #31
robertdouglass commentedThanks for the bugfixes.
The reason there is no HEAD version is because I dislike the (now outdated) paradigm of the "versionless" HEAD. I usually only comitted versions that worked with actual distributions (4-6, 4-7, etc.).
Comment #32
mcurry commentedAh, thanks for the CVS version explanation. Problem is, it took me a few minutes to figure out why my CVS client was failing on checkout (defaults to the current head revision), so it wouldn't get any files. I had to manually specify the DRUPAL-4-7 branch before I could get the files from CVS.
Comment #33
(not verified) commented