GetLinksTo() seems to be returning no results even though there are image pages with links to them. It seems to be a problem with the select statement within the File class. I looked at the query and if I run the query within mySQL it works if I remove the extra quotes.
Are other people having trouble with this method? Mary Beebe -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Tim Starling Sent: Monday, January 10, 2011 6:32 PM To: [email protected] Subject: Re: [Wikitech-l] Image.php is deprecated need to replace with something else On 11/01/11 08:56, Beebe, Mary J wrote: > Within one of our older internal extensions, we have these 2 > lines: $targetAsImage = Image::newFromTitle($onePage); > $allPagesLinkedToTarget = $targetAsImage->getLinksTo(); > > We were trying to get a list of wiki titles that link to an image. > This does not seem to work anymore with media wiki 1.15. Now that > it is truly deprecated, what should we replace this with? > $targetAsImage = wfFindFile( $onePage ); if ( $targetAsImage ) { $allPagesLinkedToTarget = $targetAsImage->getLinksTo(); } wfFindFile() will return false if the image does not exist, so you need to guard against that case to avoid a fatal error. _______________________________________________ Wikitech-l mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/wikitech-l _______________________________________________ Wikitech-l mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/wikitech-l
