Resource icon

MetaMirror 1.6.1

No permission to download
The attachments option seems to work fine. I'm running my live site (http://metabunk.org) with attachments, and no problems with testing. Thanks to @JulianD for the code snippet. But I recommend people run some tests with the testing tool to make sure things look good. Maybe don't enable it for a while, just do some manual tests from time to time.

I see no indication of any problem, but the attachment system is tied into other stuff, so it's less obvious if there could be some problem compare to the file system.

Attachments are a bit slower, but should ultimately be simpler. I'll probably make the option be on by default.
 
Last edited:
Is there an option to go through the posts again and convert everything to attachments?

Sorry no. Although it would not be too hard to do - just specifically un-ignore /MetaMirrorCache/ links and force a full re-sweep by incrementing [Edit: wiping in the database] the magic number. I'll add it, maybe tomorrow.
 
Last edited:
Rehosted files can be identified in the attachment browser by their long file name starting with a.
Attachment Browser | Admin CP - Metabunk.webp

I've verified that the attachments behave as they are supposed to. When you permanently delete the post that the attachment is from, then the attachment is deleted too. The MetaMirror attachments can also be deleted from Attachment Browser (i.e. they are just regular attachments - I was worried they were not hooked in somewhere, but all seems well).
 
Last edited:
I'll be installing this the next time I re-build Apache, as I need to enable EXIF

Fatal error: Call to undefined function exif_imagetype()
 
I'll be installing this the next time I re-build Apache, as I need to enable EXIF

Fatal error: Call to undefined function exif_imagetype()

Hmm, that's only in PHP >= 4.3.0, I guess I should check for it at run time. I'd imagine the majority of people have PHP up there by now? That was from 2002.

Aha, just saw JulianD's answer. That will probably fix it for you.

XF uses a different method of sanitizing attachments. I might try to just co-opt that. There's no need for me to call exif_imagetype() if you are using the attachment system instead of the file system.
 
Last edited:
Hmm, that's only in PHP >= 4.3.0, I guess I should check for it at run time. I'd imagine the majority of people have PHP up there by now? That was from 2002.

Aha, just saw JulianD's answer. That will probably fix it for you.

XF uses a different method of sanitizing attachments. I might try to just co-opt that. There's no need for me to call exit_imagetype() if you are using the attachment system instead of the file system.
I'm on the latest version of PHP 5.4 (17). It wasn't built with --enable-exif set, so I'll need to re-build it.
 
That works fine, Matt you can just add it to the top of MetaMirror/CronEntry.php (before function loadImage(&$url)) as a patch. It will be in future releases
PHP:
if ( ! function_exists( 'exif_imagetype' ) ) {
    function exif_imagetype ( $filename ) {
        if ( ( list($width, $height, $type, $attr) = getimagesize( $filename ) ) !== false ) {
            return $type;
        }
        return false;
    }
}
 
That works fine, Matt you can just add it to the top of MetaMirror/CronEntry.php (before function loadImage(&$url)) as a patch. It will be in future releases
PHP:
if ( ! function_exists( 'exif_imagetype' ) ) {
    function exif_imagetype ( $filename ) {
        if ( ( list($width, $height, $type, $attr) = getimagesize( $filename ) ) !== false ) {
            return $type;
        }
        return false;
    }
}
Added that in, and it doesn't error any more, but it's throwing this into the error log in the ACP

Code:
ErrorException: Invalid argument supplied for foreach() - library/MetaMirror/CronEntry.php:559
Generated By: Unknown Account, 1 minute ago
Stack Trace
#0 /home/sffcouk/public_html/library/MetaMirror/CronEntry.php(559): XenForo_Application::handlePhpError(2, 'Invalid argumen...', '/home/sffcouk/p...', 559, Array)
#1 /home/sffcouk/public_html/library/MetaMirror/CronEntry.php(429): MetaMirror_CronEntry::runForContentType()
#2 [internal function]: MetaMirror_CronEntry::runMetaMirror(Array)
#3 /home/sffcouk/public_html/library/XenForo/Model/Cron.php(356): call_user_func(Array, Array)
#4 /home/sffcouk/public_html/library/XenForo/Deferred/Cron.php(20): XenForo_Model_Cron->runEntry(Array)
#5 /home/sffcouk/public_html/library/XenForo/Model/Deferred.php(197): XenForo_Deferred_Cron->execute(Array, Array, 9.99999809265, '')
#6 /home/sffcouk/public_html/library/XenForo/Model/Deferred.php(320): XenForo_Model_Deferred->runDeferred(Array, 9.99999809265, '', false)
#7 /home/sffcouk/public_html/library/XenForo/Model/Deferred.php(273): XenForo_Model_Deferred->_runInternal(Array, NULL, '', false)
#8 /home/sffcouk/public_html/deferred.php(15): XenForo_Model_Deferred->run(false)
#9 {main}
Request State
array(3) {
  ["url"] => string(47) "http://sheffieldfitnessforum.co.uk/deferred.php"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(4) {
    ["_xfRequestUri"] => string(17) "/admin.php?tools/"
    ["_xfNoRedirect"] => string(1) "1"
    ["_xfToken"] => string(8) "********"
    ["_xfResponseType"] => string(4) "json"
  }
}
 
Ah, once again I slightly broke the cron task, it will give you that error if it is disabled in the options, but the cron task is enabled. Once it is enabled, the error will stop happening. So still functional, just giving an error when disabled.

Fix in a bit.
 
Top Bottom