OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Looking for practical methods for creating galley files

Are you responsible for making OJS work -- installing, upgrading, migrating or troubleshooting? Do you think you've found a bug? Post in this forum.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
What to do if you have a technical problem with OJS:

1. Search the forum. You can do this from the Advanced Search Page or from our Google Custom Search, which will search the entire PKP site. If you are encountering an error, we especially recommend searching the forum for said error.

2. Check the FAQ to see if your question or error has already been resolved.

3. Post a question, but please, only after trying the above two solutions. If it's a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a development question, try the OJS Development subforum.

Postby asmecher » Thu Apr 12, 2007 9:53 pm

Hi James,

Typically, a blank page indicates a PHP error. Check your system logs, or else try adding this somewhere near the top of index.php (making sure not to put it in a comment block):
Code: Select all
ini_set('display_errors', E_ALL);
Regards,
Alec Smecher
Open Journal Systems Team
---
Don't miss the First International PKP Scholarly Publishing Conference
July 11 - 13, 2007, Vancouver, BC, Canada
http://ocs.sfu.ca/pkp2007/
asmecher
 
Posts: 8470
Joined: Wed Aug 10, 2005 12:56 pm

Postby shimrah » Fri Apr 13, 2007 9:40 am

Hmm... still no dice. I added that line as you suggested, but I still get that blank screen after uploading a galley.

It seems to upload successfully (if I refresh the Editing screen the date/filename/size has updated), but still does not detect it correctly as an HTML (upon trying to view it, still no pics).

Perhaps I should try editing this manually to see if that fixes the HTML problem... how would I go about that?

Thanks!
shimrah
 
Posts: 45
Joined: Thu Apr 05, 2007 10:01 am

Postby asmecher » Fri Apr 13, 2007 9:59 am

Hi James,

What is your php.ini memory_limit set to? If it's only 8M, try setting it to 12M or 16M. Otherwise, there should definitely be an error message somewhere to correspond with the blank page.

I have heard of situations where uploads were interrupted because firewalls misinterpreted them as SQL injections (i.e. if the request contains the words "DELETE" and "FROM" in that order). You may want to try updating, configuring, or temporarily disabling your firewall for testing.

Even if you edit the HTML manually to include the article ID etc. in the image link, you'll still have trouble with other features where OJS depends on knowing the difference between PDF and HTML.

Regards,
Alec Smecher
Open Journal Systems Team
---
Don't miss the First International PKP Scholarly Publishing Conference
July 11 - 13, 2007, Vancouver, BC, Canada
http://ocs.sfu.ca/pkp2007/
asmecher
 
Posts: 8470
Joined: Wed Aug 10, 2005 12:56 pm

Postby shimrah » Mon Apr 16, 2007 1:27 pm

Hi Alec,

Still no luck. The memory_limit is set to 21M (I tried changing it to 32M, but there was no effect). We set up an error log (which we've tested with another page), but no error is generated when I get the blank screen.

Our firewall is a simple port blocker, but we've also tried this over LAN (with no firewall). Same result.

If it would help, we can provide you access to any files that would help you troubleshoot this...

Many thanks (again)!
shimrah
 
Posts: 45
Joined: Thu Apr 05, 2007 10:01 am

Postby asmecher » Mon Apr 16, 2007 1:39 pm

Hi James,

Hmm -- well, the only thing that comes to mind is the MIME type detection code. If you're handy with PHP, could you try adding some debugging output to the mime_content_type function in classes/core/String.inc.php to see whether or not the type is being correctly detected for the uploaded file?

Regards,
Alec Smecher
Open Journal Systems Team
---
Don't miss the First International PKP Scholarly Publishing Conference
July 11 - 13, 2007, Vancouver, BC, Canada
http://ocs.sfu.ca/pkp2007/
asmecher
 
Posts: 8470
Joined: Wed Aug 10, 2005 12:56 pm

Postby shimrah » Tue Apr 17, 2007 9:00 am

Hey Alec,

We tried adding debugging code to the module as you suggested. It seems that the module isn't being called at all -- the error log doesn't have any entires in it after I upload a galley (and get the blank screen).



Code: Select all
function mime_content_type($filename) {
error_log("!! **ENTERED mime_content_type FUNCTION**...", 0);
   if (function_exists('mime_content_type')) {
         error_log("!!**IF**...", 0);
         return mime_content_type($filename);
   } elseif (function_exists('finfo_open')) {
         error_log("!!**ELSEIF**...", 0);
         static $fi;
         if (!isset($fi)) {
               error_log("!!**ELSEIF,1**...", 0);
               $fi = finfo_open(FILEINFO_MIME,
'C:\PHP\extras\magic');
         }
         if ($fi !== false) {
               error_log("!!**ELSEIF,2**...", 0);
               return finfo_file($fi, $filename);
         }
   }
   
   // Fall back on an external "file" tool
   error_log("!!**GOT PAST IF/ELSEIF**...", 0);
   $f = escapeshellarg($filename);
   $result = trim(`file -bi $f`);
   // Make sure we just return the mime type.
   if (($i = strpos($result, ';')) !== false) {
         $result = trim(substr($result, 0, $i));
   }
   return $result;
   error_log("!!**GOT TO END OF mime_content_type FUNCTION**...", 0);
}


Just to make sure the error_log function was working, we copied the code to a test.php file and specified a specific test.htm file on our drive. We got the following output from this test file:

Code: Select all
[17-Apr-2007 11:43:01] !! **ENTERED mime_content_type FUNCTION**...
[17-Apr-2007 11:43:01] !!**ELSEIF**...
[17-Apr-2007 11:43:01] !!**ELSEIF,1**...
[17-Apr-2007 11:43:01] !!**ELSEIF,2**...
[17-Apr-2007 11:43:01] Result is:application/x-dpkg


So it seems that the mime_content_type function isn't being called at all, unless the error log is being blocked somehow. :? Where would be the next best place to look?

Thanks!
shimrah
 
Posts: 45
Joined: Thu Apr 05, 2007 10:01 am

Postby asmecher » Tue Apr 17, 2007 9:03 am

Hi James,

Perhaps something is failing before the mime_content_type function gets called. You'll have to step through the request handling code bit by bit until you find out where it's failing. Start with pages/sectionEditor/SectionEditorHandler.inc.php in the uploadGalley function and work through from there to the place where execution stops.

In particular, I'd suggest double-checking any modifications you've made to the PHP code for syntax errors. Sometimes if PHP encounters a fatal syntax error (i.e. mismatching "{" and "}" blocks) it'll die without any message.

Regards,
Alec Smecher
Open Journal Systems Team
---
Don't miss the First International PKP Scholarly Publishing Conference
July 11 - 13, 2007, Vancouver, BC, Canada
http://ocs.sfu.ca/pkp2007/
asmecher
 
Posts: 8470
Joined: Wed Aug 10, 2005 12:56 pm

Postby shimrah » Tue Apr 17, 2007 12:15 pm

Hey Alec,

Could you send me a copy of your magic.mime file (or a link to one)? We're not certain, but ours may be corrupt.

Thanks...
shimrah
 
Posts: 45
Joined: Thu Apr 05, 2007 10:01 am

Postby asmecher » Tue Apr 17, 2007 12:34 pm

Hi James,

I've posted a copy at http://pkp.sfu.ca/ojs/magic.mime.

Regards,
Alec Smecher
Open Journal Systems Team
---
Don't miss the First International PKP Scholarly Publishing Conference
July 11 - 13, 2007, Vancouver, BC, Canada
http://ocs.sfu.ca/pkp2007/
asmecher
 
Posts: 8470
Joined: Wed Aug 10, 2005 12:56 pm

Postby shimrah » Tue Apr 17, 2007 12:54 pm

Thanks ... this seems to be identical to the one we have, but I figured it was worth a shot.

Okay...

So we're getting the error logs to spit out some useful debugging info now. This is the output:

Code: Select all

[17-Apr-2007 15:48:05] **ENTERED SubmissionEditHandler.inc.php,uploadGalley1**...
[17-Apr-2007 15:48:05] **ENTERED SubmissionEditHandler.inc.php,uploadGalley2**...
[17-Apr-2007 15:48:06] **ENTERED SubmissionEditHandler.inc.php,uploadGalley3**...
[17-Apr-2007 15:48:06] **ENTERED SubmissionEditHandler.inc.php,uploadGalley4**...
[17-Apr-2007 15:48:06] **ENTERED SubmissionEditHandler.inc.php,uploadGalley5**...
[17-Apr-2007 15:48:06] !! **ENTERED mime_content_type FUNCTION**...
[17-Apr-2007 15:48:06] !!**ELSEIF**...
[17-Apr-2007 15:48:06] !!**ELSEIF,1**...
[17-Apr-2007 15:48:06] !!**ELSEIF,2**Resource id #196C:\PHP\uploadtemp\phpA6.tmp...



And these are the modified functions:

Code: Select all
function uploadGalley($fileName = null) {
      error_log("**ENTERED SubmissionEditHandler.inc.php,uploadGalley1**...", 0);
      $articleId = Request::getUserVar('articleId');
      error_log("**ENTERED SubmissionEditHandler.inc.php,uploadGalley2**...", 0);
      list($journal, $submission) = SubmissionEditHandler::validate($articleId, SECTION_EDITOR_ACCESS_EDIT);
      error_log("**ENTERED SubmissionEditHandler.inc.php,uploadGalley3**...", 0);
      import('submission.form.ArticleGalleyForm');
      error_log("**ENTERED SubmissionEditHandler.inc.php,uploadGalley4**...", 0);       
      $galleyForm = &new ArticleGalleyForm($articleId);
      error_log("**ENTERED SubmissionEditHandler.inc.php,uploadGalley5**...", 0);
      $galleyId = $galleyForm->execute($fileName);
      error_log("**ENTERED SubmissionEditHandler.inc.php,uploadGalley6**...", 0);       
      Request::redirect(null, null, 'editGalley', array($articleId, $galleyId));
      error_log("**ENTERED SubmissionEditHandler.inc.php,uploadGalley7**...", 0);
   }



Code: Select all
function mime_content_type($filename) {
error_log("!! **ENTERED mime_content_type FUNCTION**...", 0);
   if (function_exists('mime_content_type')) {
         error_log("!!**IF**...", 0);
         return mime_content_type($filename);
   } elseif (function_exists('finfo_open')) {
         error_log("!!**ELSEIF**...", 0);
         static $fi;
         if (!isset($fi)) {
               error_log("!!**ELSEIF,1**...", 0);
               $fi = finfo_open(FILEINFO_MIME, 'C:\PHP\extras\magic');
         }
         if ($fi !== false) {
               error_log("!!**ELSEIF,2**" . $fi . $filename . "...", 0);
               return finfo_file($fi, $filename);
         }
   }



Sorry to spit so much at you, but I thought this would make it easier to analyze. The uploadGalley function doesn't seem to get past $galleyId = $galleyForm->execute($fileName); but I'm not sure where to go from there.

Thanks again!
shimrah
 
Posts: 45
Joined: Thu Apr 05, 2007 10:01 am

Postby asmecher » Tue Apr 17, 2007 1:15 pm

Hi James,

Nothing in your debugging output definitively indicates the problem -- could you try the same approach in classes/submission/form/ArticleGalleyForm.inc.php in the validate function?

Regards,
Alec Smecher
Open Journal Systems Team
---
Don't miss the First International PKP Scholarly Publishing Conference
July 11 - 13, 2007, Vancouver, BC, Canada
http://ocs.sfu.ca/pkp2007/
asmecher
 
Posts: 8470
Joined: Wed Aug 10, 2005 12:56 pm

Postby shimrah » Tue Apr 17, 2007 1:43 pm

Hmm. I don't see a validate function in that file.

Do you mean the validate function in \classes\form\Form.inc.php ?

(I added some debugging code to that function, but it doesn't seem to be called...)
shimrah
 
Posts: 45
Joined: Thu Apr 05, 2007 10:01 am

Postby asmecher » Tue Apr 17, 2007 1:57 pm

Hi James,

My mistake -- I meant the execute function.

Regards,
Alec Smecher
Open Journal Systems Team
asmecher
 
Posts: 8470
Joined: Wed Aug 10, 2005 12:56 pm

Postby shimrah » Tue Apr 17, 2007 2:22 pm

Okay... let's see...

Suddenly, I'm not getting the blank screen any more. Things are uploading okay... but still not detecting properly as HTML...


Code: Select all
   /**
    * Save changes to the galley.
    * @return int the galley ID
    */
   function execute($fileName = null) {
error_log("!! **ENTERED execute FUNCTION**...", 0);
      import('file.ArticleFileManager');
      $articleFileManager = &new ArticleFileManager($this->articleId);
      $galleyDao = &DAORegistry::getDAO('ArticleGalleyDAO');

      $fileName = isset($fileName) ? $fileName : 'galleyFile';

      if (isset($this->galley)) {
error_log("!! **execute FUNCTION 1**...", 0);
         $galley = &$this->galley;

         // Upload galley file
         if ($articleFileManager->uploadedFileExists($fileName)) {
            if($galley->getFileId()) {
error_log("!! **execute FUNCTION 2**...", 0);
               $articleFileManager->uploadPublicFile($fileName, $galley->getFileId());
            } else {
error_log("!! **execute FUNCTION 3**...", 0);
               $fileId = $articleFileManager->uploadPublicFile($fileName);
               $galley->setFileId($fileId);
            }
error_log("!! **execute FUNCTION 4**...", 0);
            // Update file search index
            import('search.ArticleSearchIndex');
            ArticleSearchIndex::updateFileIndex($this->articleId, ARTICLE_SEARCH_GALLEY_FILE, $galley->getFileId());
         }
         if ($articleFileManager->uploadedFileExists('styleFile')) {
error_log("!! **execute FUNCTION 5**...", 0);
            // Upload stylesheet file
            $styleFileId = $articleFileManager->uploadPublicFile('styleFile', $galley->getStyleFileId());
            $galley->setStyleFileId($styleFileId);

         } else if($this->getData('deleteStyleFile')) {
error_log("!! **execute FUNCTION 6**...", 0);
            // Delete stylesheet file
            $styleFile = &$galley->getStyleFile();
            if (isset($styleFile)) {
               $articleFileManager->deleteFile($styleFile->getFileId());
            }
         }
error_log("!! **execute FUNCTION 7**...", 0);
         // Update existing galley
         $galley->setLabel($this->getData('label'));
         $galleyDao->updateGalley($galley);

      } else {
error_log("!! **execute FUNCTION 8**...", 0);
         // Upload galley file
         if ($articleFileManager->uploadedFileExists($fileName)) {
            $fileType = $articleFileManager->getUploadedFileType($fileName);
            $fileId = $articleFileManager->uploadPublicFile($fileName);

            // Update file search index
            import('search.ArticleSearchIndex');
            ArticleSearchIndex::updateFileIndex($this->articleId, ARTICLE_SEARCH_GALLEY_FILE, $fileId);
         } else {
error_log("!! **execute FUNCTION 9**...", 0);
            $fileId = 0;
         }

         if (isset($fileType) && strstr($fileType, 'html')) {
error_log("!! **execute FUNCTION 10**...", 0);
            // Assume HTML galley
            $galley = &new ArticleHTMLGalley();
         } else {
error_log("!! **execute FUNCTION 11**...", 0);
            $galley = &new ArticleGalley();
         }
error_log("!! **execute FUNCTION 12**...", 0);
         $galley->setArticleId($this->articleId);
         $galley->setFileId($fileId);

         if ($this->getData('label') == null) {
            // Generate initial label based on file type
            if ($galley->isHTMLGalley()) {
error_log("!! **execute FUNCTION 13**...", 0);
               $galley->setLabel('HTML');

            } else if (isset($fileType)) {
error_log("!! **execute FUNCTION 14**...", 0);
               if(strstr($fileType, 'pdf')) {
error_log("!! **execute FUNCTION 15**...", 0);
                  $galley->setLabel('PDF');

               } else if (strstr($fileType, 'postscript')) {
error_log("!! **execute FUNCTION 16**...", 0);
                  $galley->setLabel('PostScript');
               } else if (strstr($fileType, 'xml')) {
error_log("!! **execute FUNCTION 17**...", 0);
                  $galley->setLabel('XML');
               }
            }

            if ($galley->getLabel() == null) {
error_log("!! **execute FUNCTION 18**...", 0);
               $galley->setLabel(Locale::translate('common.untitled'));
            }

         } else {
error_log("!! **execute FUNCTION 19**...", 0);
            $galley->setLabel($this->getData('label'));
         }
error_log("!! **execute FUNCTION 20**...", 0);
         // Insert new galley
         $galleyDao->insertGalley($galley);
         $this->galleyId = $galley->getGalleyId();
      }
error_log("!! **END execute FUNCTION**...", 0);
      return $this->galleyId;
   }


For uploading a new galley:

Code: Select all

[17-Apr-2007 17:12:50] **ENTERED SubmissionEditHandler.inc.php 1**...
[17-Apr-2007 17:12:50] **ENTERED validate FUNCTION**...
[17-Apr-2007 17:12:50] **validate FUNCTION 3**...
[17-Apr-2007 17:12:50] **validate FUNCTION 4**...
[17-Apr-2007 17:12:50] **REACHED END OF validate FUNCTION**...
[17-Apr-2007 17:12:50] !! **ENTERED execute FUNCTION**...
[17-Apr-2007 17:12:50] !! **execute FUNCTION 1**...
[17-Apr-2007 17:12:50] !! **execute FUNCTION 3**...
[17-Apr-2007 17:12:50] !! **execute FUNCTION 4**...
[17-Apr-2007 17:12:50] !! **execute FUNCTION 7**...
[17-Apr-2007 17:12:50] !! **END execute FUNCTION**...
[17-Apr-2007 17:12:51] **ENTERED SubmissionEditHandler.inc.php 1**...
[17-Apr-2007 17:12:51] **ENTERED SubmissionEditHandler.inc.php,submissionEditing**...



For clicking "edit" then updating an existing galley:

Code: Select all

[17-Apr-2007 17:12:59] **ENTERED SubmissionEditHandler.inc.php 1**...
[17-Apr-2007 17:13:05] **ENTERED SubmissionEditHandler.inc.php 1**...
[17-Apr-2007 17:13:05] **ENTERED validate FUNCTION**...
[17-Apr-2007 17:13:05] **validate FUNCTION 3**...
[17-Apr-2007 17:13:05] **validate FUNCTION 4**...
[17-Apr-2007 17:13:05] **REACHED END OF validate FUNCTION**...
[17-Apr-2007 17:13:05] !! **ENTERED execute FUNCTION**...
[17-Apr-2007 17:13:05] !! **execute FUNCTION 1**...
[17-Apr-2007 17:13:05] !! **execute FUNCTION 2**...
[17-Apr-2007 17:13:05] !! **execute FUNCTION 4**...
[17-Apr-2007 17:13:05] !! **execute FUNCTION 7**...
[17-Apr-2007 17:13:05] !! **END execute FUNCTION**...
[17-Apr-2007 17:13:05] **ENTERED SubmissionEditHandler.inc.php 1**...
[17-Apr-2007 17:13:05] **ENTERED SubmissionEditHandler.inc.php,submissionEditing**...
[/code]
shimrah
 
Posts: 45
Joined: Thu Apr 05, 2007 10:01 am

Postby asmecher » Tue Apr 17, 2007 2:33 pm

Hi James,

I'm sorry, but I'll lose my eyesight wading through those outputs! If the galleys are now being created (did you correct a typo or something to accomplish this?) but the types aren't properly being detected, you're back to debugging the mime_content_type function. Check what it's returning when you upload an HTML galley and go from there.

Regards,
Alec Smecher
Open Journal Systems Team
---
Don't miss the First International PKP Scholarly Publishing Conference
July 11 - 13, 2007, Vancouver, BC, Canada
http://ocs.sfu.ca/pkp2007/
asmecher
 
Posts: 8470
Joined: Wed Aug 10, 2005 12:56 pm

PreviousNext

Return to OJS Technical Support

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot] and 3 guests